buddhism/composables/goToLogin.js

29 lines
553 B
JavaScript

export const getToken = () => {
return uni.getStorageSync("token") || null;
};
export const checkLogin = () => {
const token = getToken();
if (!token) {
showLoginModal();
return false;
}
return true;
};
export const showLoginModal = () => {
uni.showModal({
title: "未登录",
content: "请先登录后再进行操作",
confirmText: "去登录",
cancelText: "取消",
success: (res) => {
if (res.confirm) {
uni.navigateTo({
url: "/pages/login/login",
});
}
},
});
};