同步所有用到的登录类型态

This commit is contained in:
aixianling
2024-06-11 17:44:44 +08:00
parent 263f42d51c
commit 1a773d10fc
2 changed files with 8 additions and 3 deletions

View File

@@ -86,8 +86,9 @@ export const user = {
})
} else return Promise.reject("缺少登录code")
},
autoLogin({dispatch}, params = {nickName: '微信用户'}) {
const {loginWay = 'std', phoneCode} = params
autoLogin({dispatch, commit, rootState}, params = {nickName: '微信用户'}) {
const {loginWay = rootState.loginWay || "std", phoneCode} = params
commit("setLoginWay", loginWay)
if (loginWay == "admin") {
return phoneCode ? dispatch("getCode", params).then(code => dispatch('getAdminToken', {...params, code})).then(() => dispatch('getUserInfo', loginWay)) : Promise.reject("缺少手机号授权")
} else return dispatch("getCode").then(code => dispatch("getToken", {...params, code})).then(() => dispatch('getUserInfo', loginWay))

View File

@@ -7,12 +7,16 @@ Vue.use(Vuex)
const store = new Vuex.Store({
state: {
token: ""
token: "",
loginWay: "std",//std 标准,qujing:曲靖定制登录,admin:G端小程序登录
},
mutations: {
setToken(state, token) {
state.token = token
},
setLoginWay(state, way) {
state.loginWay = way
},
logout(state, showToast) {
state.token = ""
state.user = {}