优化
This commit is contained in:
parent
e1d918222c
commit
89c15198a0
@ -27,18 +27,11 @@ const user = {
|
|||||||
let res = await apiUserInfo()
|
let res = await apiUserInfo()
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
commit('SET_USER_INFO', res.user)
|
commit('SET_USER_INFO', res.user)
|
||||||
|
commit('SET_USER_INFO', res.data)
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(res.msg0)
|
this.$message.error(res.msg0)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
GET_PERMISSIONS: ({ commit }) => {
|
|
||||||
getDepList({type: 1}).then(response => {
|
|
||||||
const data = response.code === 200 ? response.data : []
|
|
||||||
commit('SET_USER_AUTH', data)
|
|
||||||
}).catch(error => {
|
|
||||||
console.log(error)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
GET_DEPLIST: ({ commit }) => {
|
GET_DEPLIST: ({ commit }) => {
|
||||||
getDepList({type: 1}).then(response => {
|
getDepList({type: 1}).then(response => {
|
||||||
const data = response.code === 200 ? response.data : []
|
const data = response.code === 200 ? response.data : []
|
||||||
|
|||||||
@ -1,6 +1,48 @@
|
|||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
router.beforeEach((to, from, next) => {
|
import store from '@/store'
|
||||||
next()
|
|
||||||
|
import * as dd from 'dingtalk-jsapi'
|
||||||
|
import { apiDingtalkLogin } from '@/api/login'
|
||||||
|
console.log('store: ', store)
|
||||||
|
|
||||||
|
// 钉钉免登录
|
||||||
|
async function handleDingtalkLogin (val) {
|
||||||
|
const res = await apiDingtalkLogin(val)
|
||||||
|
console.log('钉钉免登录res: ', res)
|
||||||
|
if (res && res.code === 200) {
|
||||||
|
this.$cookies.set('token', res.token)
|
||||||
|
return 1
|
||||||
|
// window.open(window.location.protocol + '//' + window.location.host + '/digitization/kpi/workbench/home?code=' + this.dingCode.code)
|
||||||
|
} else {
|
||||||
|
this.$message.error('登录失败')
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取钉钉鉴权码
|
||||||
|
function handleGetDingtalkCode () {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
dd.runtime.permission.requestAuthCode({
|
||||||
|
corpId: 'ding267474e759bbca1c35c2f4657eb6378f',
|
||||||
|
async onSuccess (res) {
|
||||||
|
console.log('result===', res)
|
||||||
|
let result = await handleDingtalkLogin(res)
|
||||||
|
resolve(result)
|
||||||
|
},
|
||||||
|
onFail (err) {
|
||||||
|
console.log('err: ', err)
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
router.beforeEach(async (to, from, next) => {
|
||||||
|
if (!store.getters.userInfo.userNo && !dd.other) {
|
||||||
|
let res = await handleGetDingtalkCode()
|
||||||
|
if (res === 1) next()
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user