parent
dd5c7b125b
commit
6a5f6b8531
6 changed files with 79 additions and 11 deletions
@ -0,0 +1,49 @@ |
||||
<template></template> |
||||
|
||||
<script> |
||||
import { mapActions, mapMutations } from "vuex"; |
||||
import util from "@/libs/util"; |
||||
import Setting from "@/setting"; |
||||
export default { |
||||
data: function() { |
||||
return { |
||||
token: this.$route.query.auth |
||||
}; |
||||
}, |
||||
mounted() { |
||||
this.token ? this.setLogin() : this.$router.replace('/login') |
||||
}, |
||||
methods: { |
||||
...mapMutations("user", [ |
||||
"SET_ROLENAME", 'SET_FROM' |
||||
]), |
||||
...mapActions("user", [ |
||||
"setCustomer", "setCustomerName" |
||||
]), |
||||
setLogin() { |
||||
this.SET_FROM(true) |
||||
util.local.set(Setting.tokenKey, window.atob(decodeURI(this.token)), Setting.tokenExpires); |
||||
this.getRole() |
||||
this.queryCustomer() |
||||
}, |
||||
// 获取当前用户角色 |
||||
getRole() { |
||||
this.$post(`${this.api.getUserAllRoleByToken}?platformId=${Setting.platformId}`).then(res => { |
||||
this.SET_ROLENAME(res) |
||||
}).catch(err => {}) |
||||
}, |
||||
queryCustomer() { // 查询是否是客户 |
||||
this.$get(this.api.isClient).then(res => { |
||||
util.successMsg('登录成功') |
||||
this.setCustomer(res.customer) |
||||
this.setCustomerName(res.customerName) |
||||
this.$router.replace('/index') |
||||
}).catch(res => {}) |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
|
||||
</style> |
Loading…
Reference in new issue