|
|
@@ -46,6 +46,7 @@ |
|
|
|
ref="verify" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
<el-checkbox v-model="rememberPwd">记住密码</el-checkbox> |
|
|
|
<el-form-item> |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
@@ -76,6 +77,7 @@ export default { |
|
|
|
code: "", |
|
|
|
state: "", |
|
|
|
}, |
|
|
|
rememberPwd:false, |
|
|
|
info:{}, |
|
|
|
loginForm: { |
|
|
|
username: "", |
|
|
@@ -103,7 +105,35 @@ export default { |
|
|
|
computed: { |
|
|
|
...mapGetters(["tagWel"]), |
|
|
|
}, |
|
|
|
mounted(){ |
|
|
|
this.getCookie(); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
setCookie(username, password, time) { |
|
|
|
let date = new Date(); // 获取时间 |
|
|
|
date.setTime(date.getTime() + 24 * 60 * 60 * 1000 * time); |
|
|
|
window.document.cookie = |
|
|
|
"username" + "=" + username + ";path=/;expires=" + date.toGMTString(); |
|
|
|
window.document.cookie = |
|
|
|
"password" + "=" + password + ";path=/;expires=" + date.toGMTString(); |
|
|
|
}, |
|
|
|
|
|
|
|
// 读取cookie 将用户名和密码回显到input框中 |
|
|
|
getCookie() { |
|
|
|
if (document.cookie.length > 0) { |
|
|
|
let arr = document.cookie.split("; "); |
|
|
|
for (let i = 0; i < arr.length; i++) { |
|
|
|
let arr2 = arr[i].split("="); |
|
|
|
console.log(arr2) |
|
|
|
if (arr2[0] === "username") { |
|
|
|
this.loginForm.username = arr2[1]; |
|
|
|
} else if (arr2[0] === "password") { |
|
|
|
this.loginForm.password = arr2[1]; |
|
|
|
this.rememberPwd = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
showPassword() { |
|
|
|
this.passwordType == "" |
|
|
|
? (this.passwordType = "password") |
|
|
@@ -132,6 +162,12 @@ export default { |
|
|
|
} else if (res.data.length == 1) { |
|
|
|
let idx = res.data[0].orgType; |
|
|
|
localStorage.setItem("orgType", idx); |
|
|
|
console.log("登陆成功啦!!!") |
|
|
|
if (this.rememberPwd) { |
|
|
|
this.setCookie(this.loginForm.username, this.loginForm.password, 7); |
|
|
|
} else { |
|
|
|
this.setCookie("", "", -1); |
|
|
|
} |
|
|
|
// 给定一个判断是否可以跳转的东西 |
|
|
|
localStorage.setItem("backFlag", false); |
|
|
|
// 当他只有质控后台时,不需要多余操作 |
|
|
|