优化
This commit is contained in:
parent
349cd5e4e9
commit
4363a682bd
21
src/App.vue
21
src/App.vue
@ -13,7 +13,8 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
active: true,
|
||||
fullPage: true
|
||||
fullPage: true,
|
||||
dingCode: ''
|
||||
}
|
||||
},
|
||||
components: {
|
||||
@ -22,6 +23,12 @@ export default {
|
||||
...mapState(['user'])
|
||||
},
|
||||
async mounted () {
|
||||
console.log('dd: ', dd)
|
||||
if (!dd.other) {
|
||||
await this.handleGetDingtalkCode()
|
||||
await this.handleDingtalkLogin()
|
||||
}
|
||||
|
||||
this.GET_DEPLIST()
|
||||
},
|
||||
methods: {
|
||||
@ -31,26 +38,29 @@ export default {
|
||||
...mapActions(['GET_DEPLIST', 'SET_USER_INFO']),
|
||||
// 获取钉钉鉴权码
|
||||
handleGetDingtalkCode () {
|
||||
return new Promise((resolve, reject) => {
|
||||
let _this = this
|
||||
dd.runtime.permission.requestAuthCode({
|
||||
corpId: 'ding267474e759bbca1c35c2f4657eb6378f',
|
||||
onSuccess (res) {
|
||||
console.log('result===', res)
|
||||
_this.handleDingtalkLogin(res)
|
||||
_this.dingCode = res
|
||||
resolve()
|
||||
},
|
||||
onFail (err) {
|
||||
console.log('err===', err)
|
||||
_this.dingCode = err
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 钉钉免登录
|
||||
handleDingtalkLogin (val) {
|
||||
apiDingtalkLogin(val).then(res => {
|
||||
async handleDingtalkLogin (val = this.dingCode) {
|
||||
const res = await apiDingtalkLogin(val)
|
||||
if (res && res.code === 0) {
|
||||
this.$cookies.set('token', res.token)
|
||||
this.handleInfo()
|
||||
await this.handleInfo()
|
||||
this.dataForm.verify = '登录成功,跳转中...'
|
||||
window.open(window.location.protocol + '//' + window.location.host + '/digitization/kpi/workbench/home?code=' + this.dingCode.code)
|
||||
} else {
|
||||
@ -58,7 +68,6 @@ export default {
|
||||
this.$message.error(this.dataForm.verify)
|
||||
this.$router.replace({ name: 'dingTalkLogin' })
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取用户信息
|
||||
async handleInfo () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user