|
@@ -316,31 +316,43 @@ U.MD.D.error = function (errorMessage, scripturi, linenumber, columnnumber, erro
|
|
|
* 用户登录处理
|
|
|
*/
|
|
|
let LoginState = false
|
|
|
+let CookieS = ''
|
|
|
U.MD.D.getuser = function () {
|
|
|
// $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gif/longhuaBg.gif")'
|
|
|
var userInfo = US.userInfo;
|
|
|
var panId = userInfo && userInfo.accountNumber
|
|
|
- if (!panId && !U.UF.C.queryString('code') && !U.UF.C.queryString('tycode')) {
|
|
|
+ if (!LoginState && !panId && !U.UF.C.queryString('code') && !U.UF.C.queryString('tycode')) {
|
|
|
+ LoginState = true
|
|
|
var _cookie = U.UF.Cookie.get("cocorobo");
|
|
|
- if (!panId && _cookie) {
|
|
|
- U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
|
|
|
- if (res.value && res.value[0] && res.value[0][0]) {
|
|
|
- var _user = res.value[0][0];
|
|
|
- U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
|
|
|
- if (res.value && res.value[0] && res.value[0][0]) {
|
|
|
- US.userInfo = res.value[0][0]; //记录用户数据
|
|
|
- US.userInfo.userid = _user.userid;
|
|
|
- if ($("#U_MD_HomeC_Pop")[0]) {
|
|
|
- $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
|
|
|
+ try {
|
|
|
+ if (!panId && _cookie) {
|
|
|
+ U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
|
|
|
+ if (res.value && res.value[0] && res.value[0][0]) {
|
|
|
+ var _user = res.value[0][0];
|
|
|
+ U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
|
|
|
+ if (res.value && res.value[0] && res.value[0][0]) {
|
|
|
+ US.userInfo = res.value[0][0]; //记录用户数据
|
|
|
+ US.userInfo.userid = _user.userid;
|
|
|
+ // if ($("#U_MD_HomeC_Pop")[0]) {
|
|
|
+ // $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
|
|
|
+ // }
|
|
|
+ selectUser(_user.userid, (res) => {
|
|
|
+ loginSet(res.value[0][0], res);
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ LoginState = false
|
|
|
}
|
|
|
- selectUser(_user.userid, (res) => {
|
|
|
- loginSet(res.value[0][0], res);
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
- }, [], { "type": "GET", "withCredentials": true });
|
|
|
- }
|
|
|
- }, [], { "type": "GET", "withCredentials": true });
|
|
|
+ }, [], { "type": "GET", "withCredentials": true });
|
|
|
+ }else {
|
|
|
+ LoginState = false
|
|
|
+ }
|
|
|
+ }, [], { "type": "GET", "withCredentials": true });
|
|
|
+ }else {
|
|
|
+ LoginState = false
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ LoginState = false
|
|
|
}
|
|
|
}else if(!LoginState && !panId && U.UF.C.queryString('code').length === 32){
|
|
|
if($("#U_MD_HomeC_Pop")[0]){
|
|
@@ -660,6 +672,37 @@ U.MD.D.getuser = function () {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ var _cookie = U.UF.Cookie.get("cocorobo");
|
|
|
+ if(LoginState && !_cookie){
|
|
|
+ window.onbeforeunload = null
|
|
|
+ window.location.reload();
|
|
|
+ }else if(LoginState && !CookieS){
|
|
|
+ CookieS = _cookie
|
|
|
+ }else if(LoginState && _cookie != CookieS){
|
|
|
+ US.userInfo = {}
|
|
|
+ U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
|
|
|
+ if (res.value && res.value[0] && res.value[0][0]) {
|
|
|
+ var _user = res.value[0][0];
|
|
|
+ U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
|
|
|
+ if (res.value && res.value[0] && res.value[0][0]) {
|
|
|
+ US.userInfo = res.value[0][0]; //记录用户数据
|
|
|
+ US.userInfo.userid = _user.userid;
|
|
|
+
|
|
|
+ selectUser(_user.userid, (res) => {
|
|
|
+ loginSet(res.value[0][0], res);
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ LoginState = false
|
|
|
+ }
|
|
|
+
|
|
|
+ }, [], { "type": "GET", "withCredentials": true });
|
|
|
+ }else {
|
|
|
+ window.onbeforeunload = null
|
|
|
+ window.location.reload();
|
|
|
+ }
|
|
|
+ }, [], { "type": "GET", "withCredentials": true });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
U.MD.D.addLoginTime = function(){
|
|
@@ -1175,9 +1218,22 @@ function loginSet(userInfo, res){
|
|
|
|
|
|
|
|
|
function selectUser(uid, callback) {
|
|
|
+ var userInfo = US.userInfo;
|
|
|
+ var panId = userInfo && userInfo.accountNumber
|
|
|
+ if(panId){
|
|
|
+ let res = {value:[[userInfo]]}
|
|
|
+ if (callback) callback(res);
|
|
|
+ return
|
|
|
+ }
|
|
|
const requestUser = () => {
|
|
|
- U.A.Request(US.Config.pbl + "selectUser?userid=" + uid, [], function (res) {
|
|
|
- if (callback) callback(res);
|
|
|
+ U.A.Request(`${US.Config.pbl}selectUser?userid=${uid}`, [], function (res) {
|
|
|
+ if(res && res.value && res.value.length && res.value[0].length && res.value[0][0].userid){
|
|
|
+ if (callback) callback(res);
|
|
|
+ }else {
|
|
|
+ U.alert("获取用户信息失败,正在重试!")
|
|
|
+ LoginState = false
|
|
|
+ requestUser();
|
|
|
+ }
|
|
|
}, [], { "type": "GET", "withCredentials": true });
|
|
|
};
|
|
|
|
|
@@ -1185,6 +1241,7 @@ function selectUser(uid, callback) {
|
|
|
requestUser();
|
|
|
} catch (error) {
|
|
|
U.alert("登录失败,正在重试!")
|
|
|
+ LoginState = false
|
|
|
requestUser();
|
|
|
}
|
|
|
}
|