小程序整合完毕
This commit is contained in:
@@ -40,14 +40,13 @@ export default {
|
||||
const {encryptedData, errMsg, iv} = arg.detail
|
||||
if (errMsg == 'getPhoneNumber:ok') {
|
||||
tools.$getLoginCode().then(() => {
|
||||
// let body = {...this.userData, encryptedData, iv, code: res.code}
|
||||
this.$instance.post(`/app/appwechatuser/getWechatUserPhone`, {
|
||||
encryptedData, iv,
|
||||
code: this.code
|
||||
}, {withoutToken: true}).then(d => {
|
||||
if (d.data) {
|
||||
let data = {...this.userData, phone: d.data};
|
||||
this.autoLogin(data, this.$store).then(res => {
|
||||
this.autoLogin(data).then(res => {
|
||||
this.$emit("success", res);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ export const user = {
|
||||
})
|
||||
})
|
||||
},
|
||||
getToken({commit}, code) {
|
||||
if (code) {
|
||||
return http.post("/auth/wechat-con/token", {code}, {
|
||||
getToken({commit}, params) {
|
||||
if (params?.code) {
|
||||
return http.post("/auth/wechat-con/token", params, {
|
||||
headers: {"Authorization": "Basic d2VjaGF0OndlY2hhdA=="},
|
||||
withoutToken: true
|
||||
}).then(res => {
|
||||
@@ -52,15 +52,13 @@ export const user = {
|
||||
return token
|
||||
} else {
|
||||
uni.showToast({title: res?.msg})
|
||||
return Promise.resolve(res?.msg)
|
||||
return Promise.reject(res?.msg)
|
||||
}
|
||||
})
|
||||
} else return Promise.reject("缺少登录code")
|
||||
},
|
||||
autoLogin({dispatch}, count = 0) {
|
||||
if (count <= 3) {
|
||||
return dispatch("getCode").then(code => dispatch("getToken", code).catch(() => dispatch("autoLogin", ++count)))
|
||||
} else return Promise.reject("登录失败,请联系管理员")
|
||||
autoLogin({dispatch}, params = {}) {
|
||||
return dispatch("getCode").then(code => dispatch("getToken", {...params, code}))
|
||||
},
|
||||
authCheck({state, dispatch, rootState}, {checkType, modulePath}) {
|
||||
//用于进入应用的权限判断
|
||||
|
||||
Reference in New Issue
Block a user