|
@ -3,7 +3,8 @@
|
|
|
var agentName = "wlyyAgent";
|
|
|
var server, userAgent, loginUrl, imserver, socketUrl;
|
|
|
|
|
|
|
|
|
var IMEI = localStorage.getItem('WLYY_IMEI') || uuid(16, 16)
|
|
|
localStorage.setItem('WLYY_IMEI', IMEI)
|
|
|
$.support.cors = true;
|
|
|
if(publish_version) { // 生产环境配置
|
|
|
|
|
@ -13,7 +14,7 @@
|
|
|
// server = "http://192.168.131.24:8080/"; //仕杰
|
|
|
imserver = "http://172.19.103.88:3000/api/v2";
|
|
|
socketUrl = "http://172.19.103.88:3000";
|
|
|
loginUrl = "http://172.19.103.88:9092/wlyy/auth/login.html"
|
|
|
loginUrl = "login.html"
|
|
|
}
|
|
|
|
|
|
|
|
@ -32,12 +33,10 @@
|
|
|
userAgent = JSON.parse(userAgent)
|
|
|
}catch(e){
|
|
|
toastr && toastr.warning("登录失效,请重新登录")
|
|
|
setTimeout(function() {
|
|
|
location.replace(loginUrl+'?redirect_url='+encodeURIComponent(location.href))
|
|
|
}, 2000)
|
|
|
toLoginPage()
|
|
|
}
|
|
|
} else {
|
|
|
location.replace(loginUrl+'?redirect_url='+encodeURIComponent(location.href))
|
|
|
toLoginPage()
|
|
|
}
|
|
|
|
|
|
function httpGet(url,options) {
|
|
@ -48,7 +47,11 @@
|
|
|
type: 'GET',
|
|
|
dataType: 'JSON',
|
|
|
beforeSend: function(request) {
|
|
|
request.setRequestHeader("userAgent", JSON.stringify(userAgent));
|
|
|
var agent = userAgent || {
|
|
|
imei: IMEI,
|
|
|
platform: 4
|
|
|
}
|
|
|
request.setRequestHeader("userAgent", JSON.stringify(agent));
|
|
|
},
|
|
|
error: function(res) {
|
|
|
reject(res)
|
|
@ -69,7 +72,10 @@
|
|
|
type: 'POST',
|
|
|
dataType: 'JSON',
|
|
|
beforeSend: function(request) {
|
|
|
request.setRequestHeader("userAgent", JSON.stringify(userAgent));
|
|
|
var agent = userAgent || {
|
|
|
imei: IMEI
|
|
|
}
|
|
|
request.setRequestHeader("userAgent", JSON.stringify(agent));
|
|
|
},
|
|
|
error: function(res) {
|
|
|
reject(res)
|
|
@ -124,6 +130,15 @@
|
|
|
})
|
|
|
}
|
|
|
|
|
|
function toLoginPage() {
|
|
|
if(location.href.indexOf('login.html')>-1) {
|
|
|
return ;
|
|
|
}
|
|
|
setTimeout(function() {
|
|
|
location.replace(loginUrl+'?redirect_url='+encodeURIComponent(location.href))
|
|
|
}, 2000)
|
|
|
}
|
|
|
|
|
|
function failCodeHandle(res) {
|
|
|
var tip = "";
|
|
|
if(res.status == 999) {
|
|
@ -135,13 +150,40 @@
|
|
|
}
|
|
|
if(tip) {
|
|
|
toastr && toastr.warning(tip)
|
|
|
|
|
|
setTimeout(function(){
|
|
|
location.replace(loginUrl+'?redirect_url='+encodeURIComponent(location.href))
|
|
|
}, 1000);
|
|
|
toLoginPage()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function uuid(len, radix) {
|
|
|
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
|
|
var uuid = [], i;
|
|
|
radix = radix || chars.length;
|
|
|
|
|
|
if (len) {
|
|
|
// Compact form
|
|
|
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
|
|
|
} else {
|
|
|
// rfc4122, version 4 form
|
|
|
var r;
|
|
|
|
|
|
// rfc4122 requires these characters
|
|
|
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
|
uuid[14] = '4';
|
|
|
|
|
|
// Fill in random data. At i==19 set the high bits of clock sequence as
|
|
|
// per rfc4122, sec. 4.1.5
|
|
|
for (i = 0; i < 36; i++) {
|
|
|
if (!uuid[i]) {
|
|
|
r = 0 | Math.random()*16;
|
|
|
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return uuid.join('');
|
|
|
}
|
|
|
|
|
|
|
|
|
APIService = {
|
|
|
server: server,
|
|
|
imserver: imserver,
|