Files
quantulr 0288146b0d init
2023-08-30 17:27:21 +08:00

24 lines
532 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export const setToken = (token?: string) => {
getApp().globalData.authToken = token;
wx.setStorage({
key: "auth-token",
data: token,
});
};
// 如果不存在token则跳转到身份选择页面
export const requiredAuth = () => {
const app = getApp();
if (!app.globalData.authToken) {
wx.redirectTo({
url: "/pages/login/login",
fail: (err) => {
console.log(err);
},
});
}
};
export const getToken = () => {
const token = wx.getStorageSync("auth-token");
return token;
};