|
@@ -13,6 +13,7 @@ const user = {
|
|
|
avatar: storage.get(constant.avatar),
|
|
|
roles: storage.get(constant.roles),
|
|
|
permissions: storage.get(constant.permissions),
|
|
|
+ autologin:storage.get(constant.autologin),
|
|
|
wgtcode:storage.get(constant.wgtcode)
|
|
|
},
|
|
|
|
|
@@ -36,6 +37,10 @@ const user = {
|
|
|
state.permissions = permissions
|
|
|
storage.set(constant.permissions, permissions)
|
|
|
},
|
|
|
+ SET_AUTOLOGIN: (state, autologin) => {
|
|
|
+ state.autologin = autologin
|
|
|
+ storage.set(constant.autologin, autologin)
|
|
|
+ },
|
|
|
SET_WGTCODE: (state, wgtcode) => {
|
|
|
state.wgtcode = wgtcode
|
|
|
storage.set(constant.wgtcode, wgtcode)
|
|
@@ -53,12 +58,36 @@ const user = {
|
|
|
const password = userInfo.password
|
|
|
const code = userInfo.code
|
|
|
const uuid = userInfo.uuid
|
|
|
+ const strfrom = userInfo.strfrom||""
|
|
|
return new Promise((resolve, reject) => {
|
|
|
login(username, password, code, uuid).then(res => {
|
|
|
setToken(res.token)
|
|
|
commit('SET_TOKEN', res.token)
|
|
|
+ commit('SET_AUTOLOGIN',true)
|
|
|
resolve()
|
|
|
}).catch(error => {
|
|
|
+ if(error==500&&strfrom=='request'){
|
|
|
+ uni.hideLoading()
|
|
|
+ // 清空数据
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '登录状态已过期,您可以继续留在该页面,或者重新登录?',
|
|
|
+ cancelText: '取消',
|
|
|
+ confirmText: '确定',
|
|
|
+ success: function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ commit('SET_TOKEN', '')
|
|
|
+ commit('SET_ROLES', [])
|
|
|
+ commit('SET_PERMISSIONS', [])
|
|
|
+ removeToken()
|
|
|
+ storage.clean()
|
|
|
+ uni.reLaunch({ url: '/pages/login' })
|
|
|
+ }else{
|
|
|
+ commit('SET_AUTOLOGIN',false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
reject(error)
|
|
|
})
|
|
|
})
|