12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- var genUrl = "http://121.201.66.101:9999";
- var baseUrl = "http://121.37.6.200:8088";
- // GET请求
- function getAjax(opts, data) {
- $.Deferred(function(){});
- return new Promise(function(resolve, reject) {
- $.ajax({
- url: opts.http + opts.url,
- type: opts.type,
- dataType: "json",
- data: data,
- headers: {
- "Authorization": opts.tok
- },
- error: function() {
- localStorage.removeItem("AjaxGen");
- localStorage.removeItem("ylToken");
- top.location.href = "../index.html";
- },
- success: function(dart) {
- if(dart.code == 401||(dart.status != undefined&&dart.status != 1)){
- let _src = window.location.pathname.split("/view/");
- localStorage.removeItem("AjaxGen");
- localStorage.removeItem("ylToken");
- top.location.href = "../index.html?id="+(_src[1].split(".html")[0]);
- }else{
- resolve(dart);
- }
- }
- });
- })
- }
- // POST请求
- function postAjax(opts, data) {
- $.Deferred(function(){});
- return new Promise(function(resolve, reject) {
- $.ajax({
- url: opts.http + opts.url,
- type: opts.type,
- dataType: "JSON",
- contentType: 'application/json; charset=UTF-8',
- data: JSON.stringify(data),
- headers: {
- "Authorization": opts.tok
- },
- error: function() {
- localStorage.removeItem("AjaxGen");
- localStorage.removeItem("ylToken");
- top.location.href = "../index.html";
- },
- success: function(dart) {
- if(dart.code == 401||dart.status == -1){
- let _src = window.location.pathname.split("/view/");
- localStorage.removeItem("AjaxGen");
- localStorage.removeItem("ylToken");
- top.location.href = "../index.html?id="+(_src[1].split(".html")[0]);
- }else{
- resolve(dart);
- }
- }
- });
- })
- }
- function getTime(_time) {
- let date = _time
- const yyyy = date.getFullYear();
- const MM = date.getMonth() + 1 > 9 ? date.getMonth() + 1 : '0' + (date.getMonth() + 1);
- const dd = date.getDate() > 9 ? date.getDate() : '0' + date.getDate();
- const HH = date.getHours() > 9 ? date.getHours() : '0' + date.getHours();
- const mm = date.getMinutes() > 9 ? date.getMinutes() : '0' + date.getMinutes();
- const ss = date.getSeconds() > 9 ? date.getSeconds() : '0' + date.getSeconds();
- return [yyyy + '-' + MM + '-' + dd, " " + HH + ':' + mm + ':' + ss];
- }
|