mirror of
http://36.133.248.69:3088/admin/RentWeAppFront.git
synced 2026-03-08 01:42:28 +08:00
完成大体功能和样式
This commit is contained in:
38
common/utils/auth.js
Normal file
38
common/utils/auth.js
Normal file
@@ -0,0 +1,38 @@
|
||||
export function getToken() {
|
||||
const lifeData = uni.getStorageSync('lifeData') || {}
|
||||
const token = lifeData.vuex_token
|
||||
return token;
|
||||
}
|
||||
|
||||
export function checkToken(token) {
|
||||
if (!token || (typeof token === 'object' && Object.keys(token).length === 0)) {
|
||||
uni.reLaunch({
|
||||
url: '/pages-biz/login/login'
|
||||
})
|
||||
return Promise.reject('no token')
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.$u.get('/login/checkExpiration', {}, {
|
||||
WT: token
|
||||
}).then(res => {
|
||||
if (res.data) {
|
||||
uni.reLaunch({
|
||||
url: '/pages-biz/login/login'
|
||||
})
|
||||
reject('token expired')
|
||||
} else {
|
||||
resolve(true)
|
||||
}
|
||||
}).catch(err => {
|
||||
uni.reLaunch({
|
||||
url: '/pages-biz/login/login'
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getUserType(){
|
||||
let userInfo = uni.getStorageSync('userInfo')
|
||||
return userInfo.userType
|
||||
}
|
||||
Reference in New Issue
Block a user