Commit cd8c4005 authored by zhangyanni's avatar zhangyanni

PC登录之后半小时内不用重新登录

parent f174104d
......@@ -42,4 +42,18 @@ export default {
return true;
}
},
//读取cookie
getUserInfoCookie: function() {
if (document.cookie.length > 0) {
var arr = document.cookie.split('; '); //这里显示的格式需要切割一下自己可输出看下
for (var i = 0; i < arr.length; i++) {
var arr2 = arr[i].split('='); //再次切割
//判断查找相对应的值
if (arr2[0] == 'userInfo') {
window.sessionStorage.setItem("userInfo",arr2[1]) //保存到保存数据的地方
}
}
}
},
}
......@@ -132,6 +132,14 @@ export default {
window.document.cookie = "userPwd" + "=" + c_pwd + ";path=/;expires=" + exdate.toGMTString();
},
//设置cookie
setUserInfoCookie(user_info) {
var exdate = new Date(); //获取时间
exdate.setTime(exdate.getTime() + 30 * 60 * 1000); //保存的天数
//字符串拼接cookie
window.document.cookie = "userInfo" + "=" + user_info + ";path=/;expires=" + exdate.toGMTString();
},
//清除cookie
clearCookie: function() {
this.setCookie("", "", -1); //修改2值都为空,天数为负1天就好了
......
......@@ -49,6 +49,7 @@
import validate from '../../common/validate';
import sliderCmpt from '../common/puzzleSlider';
import api from '../../views/loginregister/api/api';
import publicFunc from '../../common/public';
export default {
name: "emByCodeCmpt",
components:{
......@@ -153,6 +154,7 @@
window.sessionStorage.removeItem("userInfo");
}
window.sessionStorage.setItem("userInfo", this.Base64.encode(JSON.stringify(data)));
publicFunc.setUserInfoCookie(this.Base64.encode(JSON.stringify(data)));
this.hasSetPassword(data);
},
......
......@@ -130,6 +130,7 @@
window.sessionStorage.removeItem("userInfo");
}
window.sessionStorage.setItem("userInfo", this.Base64.encode(JSON.stringify(data)));
publicFunc.setUserInfoCookie(that.Base64.encode(JSON.stringify(data)));
if (data.locked == 1 && data.empType != 2) this.$router.replace("/completeInfoCmpt");
data.empType==0?this.$router.push({path:"/bigBusiness/list",query:{remind:true}}):data.empType==1?this.$router.push({path:"/seeprojectlist",query:{remind:true}}): data.roleList[0].roleType==1?this.$router.push("/sys.user"): this.$router.push("/seeprojectlist");
this.timeOutReturn();
......
......@@ -42,6 +42,7 @@
import api from '../../views/loginregister/api/api';
import validate from '../../common/validate';
import sliderCmpt from '../common/puzzleSlider';
import publicFunc from '../../common/public';
export default {
name: "mbByCodeCmpt",
components:{
......@@ -127,6 +128,7 @@
window.sessionStorage.removeItem("userInfo");
}
window.sessionStorage.setItem("userInfo",that.Base64.encode(JSON.stringify(data)));
publicFunc.setUserInfoCookie(that.Base64.encode(JSON.stringify(data)));
this.hasSetPassword(data);
},
......
......@@ -161,6 +161,7 @@
window.sessionStorage.removeItem("userInfo");
}
window.sessionStorage.setItem("userInfo",that.Base64.encode(JSON.stringify(data)));
publicFunc.setUserInfoCookie(that.Base64.encode(JSON.stringify(data)));
if (data.locked == 1 && data.empType != 2) this.$router.replace("/completeInfoCmpt");
data.empType==0?this.$router.push({path:"/bigBusiness/list",query:{remind:true}}):data.empType==1?this.$router.push({path:"/seeprojectlist",query:{remind:true}}): data.roleList[0].roleType==1?this.$router.push("/sys.user"): this.$router.push("/seeprojectlist");
that.timeOutReturn()
......
......@@ -103,6 +103,7 @@ const i18n = new VueI18n({
}
})();
publicFun.getUserInfoCookie();
router.beforeEach((to, from, next) => {
// console.log(window.__asxiosPromiseArr)
if (window.__asxiosPromiseArr) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment