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