Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(res => {
// 登录成功
if (res.data.data.code === 0) {
this.$vux.toast.show({
text: '登录成功'
})
// 本地保存 token 和 userInfo
// vux 中提供的base64方法
// base64.encode('VUX')
// base64.decode('VlVY')
window.localStorage.setItem('token', base64.encode(res.data.data.token))
window.localStorage.setItem('userInfo', JSON.stringify(
res.data.data.userInfo
))
this.UPDATE_USERINFO({
userInfo: res.data.data.userInfo
})
// 重定向到首页或者登录前的页面
let redirect = decodeURIComponent(
this.$route.query.redirect || '/'
)
setTimeout(() => {
this.$router.push({
path: redirect
})
}, 2000)
}