完整完成钉钉的三方接入

This commit is contained in:
YunaiV
2021-10-02 23:55:41 +08:00
parent e05d90590e
commit 9be00d6035
23 changed files with 401 additions and 94 deletions

View File

@ -1,4 +1,4 @@
import { login, logout, getInfo } from '@/api/login'
import {login, logout, getInfo, socialLogin, socialLogin2} from '@/api/login'
import { getToken, setToken, removeToken } from '@/utils/auth'
const user = {
@ -47,6 +47,42 @@ const user = {
})
},
// 社交登陆
SocialLogin({ commit }, userInfo) {
const code = userInfo.code
const state = userInfo.state
const type = userInfo.type
return new Promise((resolve, reject) => {
socialLogin(type, code, state).then(res => {
res = res.data;
setToken(res.token)
commit('SET_TOKEN', res.token)
resolve()
}).catch(error => {
reject(error)
})
})
},
// 社交登陆
SocialLogin2({ commit }, userInfo) {
const code = userInfo.code
const state = userInfo.state
const type = userInfo.type
const username = userInfo.username.trim()
const password = userInfo.password
return new Promise((resolve, reject) => {
socialLogin2(type, code, state, username, password).then(res => {
res = res.data;
setToken(res.token)
commit('SET_TOKEN', res.token)
resolve()
}).catch(error => {
reject(error)
})
})
},
// 获取用户信息
GetInfo({ commit, state }) {
return new Promise((resolve, reject) => {