|
function ajaxRequest(opt) {
|
let m_token = localStorage.Token;
|
//console.log(m_token,opt,4)
|
let defaults = {
|
type: 'get',
|
headers: {},
|
data: {},
|
dataType: 'json',
|
async: true,
|
cache: true,
|
beforeSend: null,
|
success: null,
|
error: null,
|
complate: null,
|
contentType: 'application/x-www-form-urlencoded',
|
processData: true,
|
}
|
let o = $.extend({}, defaults, opt)
|
|
$.ajax({
|
type: o.type,
|
contentType: o.contentType,
|
processData: o.processData,
|
dataType: o.dataType,
|
url: o.url,
|
async: o.async,
|
cache: o.cache,
|
data: o.data,
|
beforeSend: function (request) {
|
if (m_token) {
|
request.setRequestHeader("Authorization", m_token);
|
}
|
},
|
success: function (result) {
|
o.success && o.success(result)
|
},
|
error: function (textStatus, errorThrown) {
|
o.error && o.error(textStatus, errorThrown)
|
}
|
});
|
}
|
|
// 注销账户 并清除cookie和localStorage
|
function logout() {
|
|
localStorage.isAuto = false;
|
localStorage.removeItem('EmployeeID');
|
localStorage.removeItem('DefaultStationID');
|
localStorage.removeItem('Token');
|
localStorage.removeItem('tokentime');
|
localStorage.removeItem('CreateUserID');
|
$.cookie(GlobalParas.CookieName.EmployeeID, "", { path: '/' });
|
$.cookie(GlobalParas.CookieName.UserID, "", { path: '/' });
|
$.cookie(GlobalParas.CookieName.CorpID, "", { path: '/' });
|
$.cookie(GlobalParas.CookieName.RealName, "", { path: '/' });
|
$.cookie(GlobalParas.CookieName.Token, "", { path: '/' });
|
$.cookie(GlobalParas.CookieName.CreateUserID, "", { path: '/' });
|
$.cookie('tokentime', "", { path: '/' });
|
|
window.location.replace("/Login/index");
|
}
|
|
function logintest() {
|
|
let postData = { SoftType: "BS", SoftTag: "SHI", LoginName: 'smiadmin', LoginPwd: 'admin', CorpID: 5 };
|
|
|
$.ajax({
|
type: 'post',
|
//dataType: 'json',
|
contentType: 'application/json',
|
cache: false,
|
url: 'http://101.133.133.173:9019/User/UserLogin/FromCorpStandard@V1.0',
|
data: JSON.stringify(postData),
|
success: function (result) {
|
|
console.log(result, 114);
|
if (result.Code != 0) {
|
$("#password").html("");
|
$("#password").focus();
|
$("#js-server-helpinfo").html(result.Message);
|
return;
|
}
|
var resp = result.Data;
|
|
if (resp.Status == -1) {
|
layer.alert("账户不存在!");
|
return;
|
}
|
if (resp.Status == -2) {
|
layer.alert("密码错误!");
|
return;
|
}
|
if (resp.Status == -3 || resp.Status == -4 || resp.Status == -5) {
|
layer.alert("您的账号已无法登录!");
|
return;
|
}
|
if (resp.Status == -99) {
|
layer.alert("登录失败!");
|
return;
|
}
|
//
|
var userInfo = resp.User;
|
let token = ''
|
if (resp.Token) {
|
token = ' Bearer ' + resp.Token
|
localStorage.tokentime = new Date().getTime();
|
}
|
|
localStorage.Token = token;
|
|
},
|
error: function (xhr, type, exception) {
|
$("#js-server-helpinfo").html("发生系统错误,请与系统管理员联系!");
|
}
|
});
|
}
|