80 lines
1.7 KiB
JavaScript
80 lines
1.7 KiB
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 removeTenantId() {
|
|
return uni.removeStorageSync(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() {
|
|
if(uni.getStorageSync(UserInfo)){
|
|
return JSON.parse(uni.getStorageSync(UserInfo))
|
|
}else{
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
export function setUserInfo(dataObj) {
|
|
return uni.setStorageSync(UserInfo, JSON.stringify(dataObj))
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
export function getStrData(keyStr) {
|
|
return uni.getStorageSync(keyStr)
|
|
}
|
|
|
|
export function setStrData(keyStr,dataStr) {
|
|
return uni.setStorageSync(keyStr, dataStr)
|
|
}
|
|
|
|
export function removeStrData(keyStr) {
|
|
return uni.removeStorageSync(keyStr)
|
|
}
|
|
|