优化
This commit is contained in:
parent
349cd5e4e9
commit
4363a682bd
61
src/App.vue
61
src/App.vue
@ -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,34 +38,36 @@ export default {
|
|||||||
...mapActions(['GET_DEPLIST', 'SET_USER_INFO']),
|
...mapActions(['GET_DEPLIST', 'SET_USER_INFO']),
|
||||||
// 获取钉钉鉴权码
|
// 获取钉钉鉴权码
|
||||||
handleGetDingtalkCode () {
|
handleGetDingtalkCode () {
|
||||||
let _this = this
|
return new Promise((resolve, reject) => {
|
||||||
dd.runtime.permission.requestAuthCode({
|
let _this = this
|
||||||
corpId: 'ding267474e759bbca1c35c2f4657eb6378f',
|
dd.runtime.permission.requestAuthCode({
|
||||||
onSuccess (res) {
|
corpId: 'ding267474e759bbca1c35c2f4657eb6378f',
|
||||||
console.log('result===', res)
|
onSuccess (res) {
|
||||||
_this.handleDingtalkLogin(res)
|
console.log('result===', res)
|
||||||
_this.dingCode = res
|
_this.dingCode = res
|
||||||
},
|
resolve()
|
||||||
onFail (err) {
|
},
|
||||||
console.log('err===', err)
|
onFail (err) {
|
||||||
_this.dingCode = err
|
console.log('err===', 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 {
|
||||||
this.dataForm.verify = '身份验证失败' + res.msg
|
this.dataForm.verify = '身份验证失败' + res.msg
|
||||||
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 () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user