41 lines
903 B
JavaScript
41 lines
903 B
JavaScript
|
const TokenKey = 'App-Token'
|
||
|
const UserInfo = 'customerInfo'
|
||
|
const TenantIdKey = 'TENANT_ID'
|
||
|
export function getToken() {
|
||
|
return uni.getStorageSync(TokenKey)
|
||
|
}
|
||
|
|
||
|
export function setToken(token) {
|
||
|
return uni.setStorageSync(TokenKey, token)
|
||
|
}
|
||
|
|
||
|
export function removeToken() {
|
||
|
return uni.removeStorageSync(TokenKey)
|
||
|
}
|
||
|
|
||
|
export function setTenantId(TenantId) {
|
||
|
return uni.setStorageSync(TenantIdKey, TenantId);
|
||
|
}
|
||
|
export function getTenantId(){
|
||
|
return uni.getStorageSync(TenantIdKey)
|
||
|
}
|
||
|
|
||
|
export function hasRole(roleCode) {
|
||
|
const roleList = uni.getStorageSync('role')
|
||
|
if (roleList && roleList.length > 0) {
|
||
|
const roleInfo = roleList.find(f => f.code === roleCode)
|
||
|
if (roleInfo) {
|
||
|
return true
|
||
|
}
|
||
|
}
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
export function getUserInfo() {
|
||
|
return uni.getStorageSync(UserInfo)
|
||
|
}
|
||
|
|
||
|
export function setUserInfo(userInfo) {
|
||
|
return uni.setStorageSync(UserInfo, userInfo)
|
||
|
}
|