2024-10-09 13:34:36 +08:00
|
|
|
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() {
|
2024-10-16 17:14:49 +08:00
|
|
|
if(uni.getStorageSync(UserInfo)){
|
|
|
|
return JSON.parse(uni.getStorageSync(UserInfo))
|
|
|
|
}else{
|
|
|
|
return undefined;
|
|
|
|
}
|
2024-10-09 13:34:36 +08:00
|
|
|
}
|
|
|
|
|
2024-10-16 17:14:49 +08:00
|
|
|
export function setUserInfo(dataObj) {
|
|
|
|
return uni.setStorageSync(UserInfo, JSON.stringify(dataObj))
|
2024-10-09 13:34:36 +08:00
|
|
|
}
|
2024-10-16 18:35:15 +08:00
|
|
|
|
|
|
|
export function removeUserInfo() {
|
|
|
|
return uni.removeStorageSync(UserInfo)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getJSONData(keyStr) {
|
|
|
|
if(uni.getStorageSync(keyStr)){
|
|
|
|
return JSON.parse(uni.getStorageSync(keyStr))
|
|
|
|
}else{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setJSONData(keyStr,dataObj) {
|
|
|
|
return uni.setStorageSync(keyStr, JSON.stringify(dataObj))
|
|
|
|
}
|
|
|
|
|
|
|
|
export function removeJSONData(keyStr) {
|
|
|
|
return uni.removeStorageSync(keyStr)
|
|
|
|
}
|
|
|
|
|