登录加密自动登录
This commit is contained in:
parent
a4f1db365d
commit
3f69b484aa
|
|
@ -7,6 +7,7 @@ import { tansParams, blobValidate } from '@/utils/bonus'
|
|||
import cache from '@/plugins/cache'
|
||||
import { saveAs } from 'file-saver'
|
||||
import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm'
|
||||
import Cookies from 'js-cookie'
|
||||
const systemConfig = JSON.parse(localStorage.getItem('systemConfig')) || {
|
||||
requestConfig: { encryptRequest: false, checkIntegrity: false, encryptResponse: false }
|
||||
};
|
||||
|
|
@ -108,21 +109,43 @@ service.interceptors.response.use(res => {
|
|||
return res.data
|
||||
}
|
||||
if (code === 401) {
|
||||
if (!isRelogin.show) {
|
||||
isRelogin.show = true
|
||||
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
||||
confirmButtonText: '重新登录',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
isRelogin.show = false
|
||||
store.dispatch('LogOut').then(() => {
|
||||
location.href = '/canteen/adScreen/'
|
||||
const username = Cookies.get('username')
|
||||
const password = Cookies.get('password')
|
||||
const rememberMe = Cookies.get('rememberMe')
|
||||
if(rememberMe==true){
|
||||
let loginForm = {
|
||||
code: "",
|
||||
loginMethod: "password",
|
||||
loginType: "",
|
||||
mobile: "",
|
||||
mobileCodeType: "LOGIN",
|
||||
password: password,
|
||||
phoneUuid: "",
|
||||
rememberMe: rememberMe,
|
||||
username: username,
|
||||
uuid: "",
|
||||
verificationCode: ""
|
||||
}
|
||||
console.log(loginForm)
|
||||
store.dispatch('Login', loginForm).then(() => {})
|
||||
}else{
|
||||
if (!isRelogin.show) {
|
||||
isRelogin.show = true
|
||||
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
||||
confirmButtonText: '重新登录',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
isRelogin.show = false;
|
||||
store.dispatch('LogOut').then(() => {
|
||||
location.href = '/canteen/adScreen/'
|
||||
})
|
||||
}).catch(() => {
|
||||
isRelogin.show = false
|
||||
})
|
||||
}).catch(() => {
|
||||
isRelogin.show = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
|
||||
} else if (code === 500) {
|
||||
Message({ message: msg, type: 'error' })
|
||||
|
|
|
|||
|
|
@ -112,22 +112,9 @@ export default {
|
|||
this.initData(); // 你的业务逻辑
|
||||
},
|
||||
mounted() {
|
||||
// location.reload();
|
||||
// const rememberMe = Cookies.get('rememberMe')
|
||||
// console.log("rememberMe",rememberMe)
|
||||
// if(rememberMe=='zhadmin'){
|
||||
|
||||
// }else{
|
||||
// this.$router.push({ path: this.redirect || '/login' });
|
||||
// }
|
||||
this.timer = setInterval(() => {
|
||||
this.initData(); // 你的业务逻辑
|
||||
}, 5000);
|
||||
// console.log("sessionStorage.getItem('isRefreshed')",sessionStorage.getItem('isRefreshed2'))
|
||||
// if (!sessionStorage.getItem('isRefreshed2')) {
|
||||
// sessionStorage.setItem('isRefreshed2', 'true')
|
||||
|
||||
// }
|
||||
}, 10000);
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearInterval(this.timer); // 必须清除定时器!
|
||||
|
|
@ -143,9 +130,9 @@ export default {
|
|||
"canteenId": '378928314946949120'
|
||||
}
|
||||
getViewData(param).then(res => {
|
||||
this.currentSeat=res.data[0].currentSeat;
|
||||
this.mealNum=res.data[0].mealNum;
|
||||
this.initpartone();
|
||||
this.currentSeat=res.data[0].currentSeat;
|
||||
this.mealNum=res.data[0].mealNum;
|
||||
this.initpartone();
|
||||
});
|
||||
//partone
|
||||
// axios.post('/api', {
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@
|
|||
import { getCodeImg } from '@/api/login'
|
||||
import Cookies from 'js-cookie'
|
||||
import { decrypt, encrypt } from '@/utils/jsencrypt'
|
||||
import { decryptWithSM4,encryptWithSM4 } from '@/utils/sm'
|
||||
import dingding from '@/assets/images/dingding.svg'
|
||||
import wx from '@/assets/images/wx.svg'
|
||||
import qq from '@/assets/images/QQ.svg'
|
||||
|
|
@ -239,7 +240,7 @@ export default {
|
|||
const password = Cookies.get('password')
|
||||
const rememberMe = Cookies.get('rememberMe')
|
||||
this.loginForm.username = username || ''
|
||||
this.loginForm.password = password ? decrypt(password) : ''
|
||||
this.loginForm.password = password ? decryptWithSM4(password) : ''
|
||||
this.loginForm.rememberMe = rememberMe === 'true'
|
||||
},
|
||||
handleLogin() {
|
||||
|
|
@ -248,7 +249,7 @@ export default {
|
|||
this.loading = true
|
||||
if (this.loginForm.rememberMe) {
|
||||
Cookies.set('username', this.loginForm.username, { expires: 30 })
|
||||
Cookies.set('password', encrypt(this.loginForm.password), { expires: 30 })
|
||||
Cookies.set('password', encryptWithSM4(this.loginForm.password), { expires: 30 })
|
||||
Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 })
|
||||
} else {
|
||||
Cookies.remove('username')
|
||||
|
|
@ -256,10 +257,12 @@ export default {
|
|||
Cookies.remove('rememberMe')
|
||||
}
|
||||
this.loginForm.loginMethod = this.loginMethod
|
||||
this.loginForm.password = encryptWithSM4(this.loginForm.password)
|
||||
// console.log(this.loginForm)
|
||||
this.$store.dispatch('Login', this.loginForm)
|
||||
.then(res => {
|
||||
this.loading = false
|
||||
console.log(res)
|
||||
// console.log(res)
|
||||
this.$router.push({ path:'/view' });
|
||||
setTimeout(()=>{
|
||||
location.reload();
|
||||
|
|
@ -277,11 +280,11 @@ export default {
|
|||
// this.$router.push({ path:'/view' });
|
||||
// }
|
||||
// }
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false
|
||||
if (this.captchaEnabled) this.getCode()
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false
|
||||
if (this.captchaEnabled) this.getCode()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -112,22 +112,9 @@ export default {
|
|||
this.initData(); // 你的业务逻辑
|
||||
},
|
||||
mounted() {
|
||||
// location.reload();
|
||||
// const rememberMe = Cookies.get('rememberMe')
|
||||
// console.log("rememberMe",rememberMe)
|
||||
// if(rememberMe=='zhadmin'){
|
||||
|
||||
// }else{
|
||||
// this.$router.push({ path: this.redirect || '/login' });
|
||||
// }
|
||||
this.timer = setInterval(() => {
|
||||
this.initData(); // 你的业务逻辑
|
||||
}, 5000);
|
||||
// console.log("sessionStorage.getItem('isRefreshed')",sessionStorage.getItem('isRefreshed2'))
|
||||
// if (!sessionStorage.getItem('isRefreshed2')) {
|
||||
// sessionStorage.setItem('isRefreshed2', 'true')
|
||||
|
||||
// }
|
||||
}, 10000);
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearInterval(this.timer); // 必须清除定时器!
|
||||
|
|
@ -143,9 +130,9 @@ export default {
|
|||
"canteenId": '378928314946949120'
|
||||
}
|
||||
getViewData(param).then(res => {
|
||||
this.currentSeat=res.data[0].currentSeat;
|
||||
this.mealNum=res.data[0].mealNum;
|
||||
this.initpartone();
|
||||
this.currentSeat=res.data[0].currentSeat;
|
||||
this.mealNum=res.data[0].mealNum;
|
||||
this.initpartone();
|
||||
});
|
||||
//partone
|
||||
// axios.post('/api', {
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ module.exports = {
|
|||
// target: `http://192.168.2.75:58080`,
|
||||
// target: `http://192.168.0.61:58080`,
|
||||
// target: `http://192.168.0.44:58085`,
|
||||
target: `http://192.168.2.82:58080`,
|
||||
// target: `http://192.168.0.244:58580`,
|
||||
// target: `http://192.168.2.82:58080`,
|
||||
target: `http://192.168.0.244:38380`,
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
['^' + process.env.VUE_APP_BASE_API]: '',
|
||||
|
|
|
|||
Loading…
Reference in New Issue