This commit is contained in:
2024-04-14 20:18:44 +08:00
parent 13fd77f13b
commit 877469ab43
12 changed files with 98 additions and 22 deletions

View File

@@ -1,5 +1,8 @@
const TokenKey = 'accessToken';
const CompanyIdKey = 'companyId';
const ReferrerUserIdKey = 'referrerUserId';
const RegisterStoreIdKey = 'storeId';
const TokenPrefix = 'Bearer ';
function isLogin() {
@@ -22,9 +25,37 @@ function setCompanyId(companyId: string) {
uni.setStorageSync(CompanyIdKey, companyId);
}
function getReferrerUserId() {
return uni.getStorageSync(ReferrerUserIdKey);
}
function setReferrerUserId(referrerUserId: string) {
uni.setStorageSync(ReferrerUserIdKey, referrerUserId);
}
function setRegisterStoreId(storeId: string) {
uni.setStorageSync(RegisterStoreIdKey, storeId);
}
function getRegisterStoreId() {
return uni.getStorageSync(RegisterStoreIdKey);
}
function clearToken() {
uni.removeStorageSync(TokenKey);
uni.removeStorageSync(CompanyIdKey);
}
export { TokenPrefix, isLogin, getToken, setToken, getCompanyId, setCompanyId, clearToken };
export {
TokenPrefix,
isLogin,
getToken,
setToken,
getCompanyId,
setCompanyId,
getReferrerUserId,
setReferrerUserId,
getRegisterStoreId,
setRegisterStoreId,
clearToken
};

View File

@@ -51,10 +51,17 @@ export function showToast(title: string, { icon, duration, complete }: ToastOpti
}
export function goPath(path: string) {
uni.navigateTo({
url: path
}).then(r => {
});
if(path.includes('home/index') || path.includes('mall/index') || path.includes('qrcode/index') || path.includes('mine/index')) {
uni.switchTab({
url: path
}).then(r => {
});
} else {
uni.navigateTo({
url: path
}).then(r => {
});
}
}
export function goLogin() {