This commit is contained in:
熊成强 2020-11-06 15:42:48 +08:00
parent 349cd5e4e9
commit 4363a682bd

View File

@ -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 () {