小程序整合完毕

This commit is contained in:
aixianling
2022-06-29 18:44:17 +08:00
parent 2bbc303c00
commit 3ae57be0cc
2 changed files with 7 additions and 10 deletions

View File

@@ -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}) {
//用于进入应用的权限判断