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 () { data () {
return { return {
active: true, active: true,
fullPage: true fullPage: true,
dingCode: ''
} }
}, },
components: { components: {
@ -22,6 +23,12 @@ export default {
...mapState(['user']) ...mapState(['user'])
}, },
async mounted () { async mounted () {
console.log('dd: ', dd)
if (!dd.other) {
await this.handleGetDingtalkCode()
await this.handleDingtalkLogin()
}
this.GET_DEPLIST() this.GET_DEPLIST()
}, },
methods: { methods: {
@ -31,26 +38,29 @@ export default {
...mapActions(['GET_DEPLIST', 'SET_USER_INFO']), ...mapActions(['GET_DEPLIST', 'SET_USER_INFO']),
// //
handleGetDingtalkCode () { handleGetDingtalkCode () {
return new Promise((resolve, reject) => {
let _this = this let _this = this
dd.runtime.permission.requestAuthCode({ dd.runtime.permission.requestAuthCode({
corpId: 'ding267474e759bbca1c35c2f4657eb6378f', corpId: 'ding267474e759bbca1c35c2f4657eb6378f',
onSuccess (res) { onSuccess (res) {
console.log('result===', res) console.log('result===', res)
_this.handleDingtalkLogin(res)
_this.dingCode = res _this.dingCode = res
resolve()
}, },
onFail (err) { onFail (err) {
console.log('err===', err) console.log('err===', err)
_this.dingCode = err _this.dingCode = err
resolve()
} }
}) })
})
}, },
// //
handleDingtalkLogin (val) { async handleDingtalkLogin (val = this.dingCode) {
apiDingtalkLogin(val).then(res => { const res = await apiDingtalkLogin(val)
if (res && res.code === 0) { if (res && res.code === 0) {
this.$cookies.set('token', res.token) this.$cookies.set('token', res.token)
this.handleInfo() await this.handleInfo()
this.dataForm.verify = '登录成功,跳转中...' this.dataForm.verify = '登录成功,跳转中...'
window.open(window.location.protocol + '//' + window.location.host + '/digitization/kpi/workbench/home?code=' + this.dingCode.code) window.open(window.location.protocol + '//' + window.location.host + '/digitization/kpi/workbench/home?code=' + this.dingCode.code)
} else { } else {
@ -58,7 +68,6 @@ export default {
this.$message.error(this.dataForm.verify) this.$message.error(this.dataForm.verify)
this.$router.replace({ name: 'dingTalkLogin' }) this.$router.replace({ name: 'dingTalkLogin' })
} }
})
}, },
// //
async handleInfo () { async handleInfo () {