|
@@ -169,6 +169,9 @@ import config from "@/config";
|
|
import loginService from "@/api/auth/loginService";
|
|
import loginService from "@/api/auth/loginService";
|
|
import userService from "@/api/sys/userService";
|
|
import userService from "@/api/sys/userService";
|
|
import tenantService from "@/api/sys/tenantService";
|
|
import tenantService from "@/api/sys/tenantService";
|
|
|
|
+
|
|
|
|
+//在运用页面引入
|
|
|
|
+import { Base64 } from 'js-base64' //引入base64加密,用于记住密码
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
@@ -251,6 +254,8 @@ export default {
|
|
this.$store.commit("clearIframeList");
|
|
this.$store.commit("clearIframeList");
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
|
|
+
|
|
|
|
+ this.getCookie()
|
|
// this.getCaptcha();
|
|
// this.getCaptcha();
|
|
if (this.inputForm.username) {
|
|
if (this.inputForm.username) {
|
|
this.getLoginCodeNumber(this.inputForm.username)
|
|
this.getLoginCodeNumber(this.inputForm.username)
|
|
@@ -264,6 +269,9 @@ export default {
|
|
methods: {
|
|
methods: {
|
|
// 提交表单
|
|
// 提交表单
|
|
async login() {
|
|
async login() {
|
|
|
|
+ var checked = this.checked
|
|
|
|
+ var password = this.inputForm.password
|
|
|
|
+ var username = this.inputForm.username
|
|
this.$refs.loginForm.validate((valid) => {
|
|
this.$refs.loginForm.validate((valid) => {
|
|
if (valid) {
|
|
if (valid) {
|
|
this.loading = true;
|
|
this.loading = true;
|
|
@@ -309,6 +317,17 @@ export default {
|
|
this.$TOOL.data.set("MENU", menuList);
|
|
this.$TOOL.data.set("MENU", menuList);
|
|
this.$TOOL.data.set("PERMISSIONS", permissions);
|
|
this.$TOOL.data.set("PERMISSIONS", permissions);
|
|
this.$TOOL.data.set("DICT_LIST", dictList);
|
|
this.$TOOL.data.set("DICT_LIST", dictList);
|
|
|
|
+
|
|
|
|
+ // let Base64 = require('js-base64').Base64
|
|
|
|
+ /* ------ 账号密码的存储 ------ */
|
|
|
|
+ if (checked) {
|
|
|
|
+ // eslint-disable-next-line no-undef
|
|
|
|
+ // let password = Base64.encode(passwordLogin) // base64加密
|
|
|
|
+ this.setCookie(Base64.encode(username), Base64.encode(password), 7)
|
|
|
|
+ } else {
|
|
|
|
+ this.setCookie('', '', -1) // 修改2值都为空,天数为负1天就好了
|
|
|
|
+ }
|
|
|
|
+ /* ------ http登录请求 ------ */
|
|
this.$notify({
|
|
this.$notify({
|
|
title: "登录成功",
|
|
title: "登录成功",
|
|
message: `欢迎回来!<br/>你上次的登录IP是 ${loginResp.oldLoginIp},登录时间是 ${loginResp.oldLoginDate}。`,
|
|
message: `欢迎回来!<br/>你上次的登录IP是 ${loginResp.oldLoginIp},登录时间是 ${loginResp.oldLoginDate}。`,
|
|
@@ -370,6 +389,34 @@ export default {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ // 设置cookie
|
|
|
|
+ setCookie (username, password, days) {
|
|
|
|
+ let date = new Date() // 获取时间
|
|
|
|
+ date.setTime(date.getTime() + 24 * 60 * 60 * 1000 * days) // 保存的天数
|
|
|
|
+ // 字符串拼接cookie
|
|
|
|
+ window.document.cookie =
|
|
|
|
+ 'username' + '=' + username + ';path=/;expires=' + date.toGMTString()
|
|
|
|
+ window.document.cookie =
|
|
|
|
+ 'password' + '=' + password + ';path=/;expires=' + date.toGMTString()
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 读取cookie 将用户名和密码回显到input框中
|
|
|
|
+ getCookie () {
|
|
|
|
+ // let Base64 = require('js-base64').Base64
|
|
|
|
+ if (document.cookie.length > 0) {
|
|
|
|
+ let arr = document.cookie.split('; ') // 分割成一个个独立的“key=value”的形式
|
|
|
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
|
+ let arr2 = arr[i].split('=') // 再次切割,arr2[0]为key值,arr2[1]为对应的value
|
|
|
|
+ if (arr2[0] === 'username') {
|
|
|
|
+ this.inputForm.username = Base64.decode(arr2[1])// base64解密
|
|
|
|
+ } else if (arr2[0] === 'password') {
|
|
|
|
+ // eslint-disable-next-line no-undef
|
|
|
|
+ this.inputForm.password = Base64.decode(arr2[1])// base64解密
|
|
|
|
+ this.checked = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
// 切换语言
|
|
// 切换语言
|
|
changeLanguage(language) {
|
|
changeLanguage(language) {
|
|
this.$TOOL.data.set("APP_LANG", language);
|
|
this.$TOOL.data.set("APP_LANG", language);
|