Files
bodyWeight/miniprogram/app.ts
T

33 lines
919 B
TypeScript

App<IAppOption>({
globalData: {},
onLaunch() {
// 已登录则跳过登录页
const token = wx.getStorageSync('token') || null;
const userInfo = wx.getStorageSync('userInfo') || null;
// const userInfo = true;
if (token && userInfo) {
wx.reLaunch({
url: '/pages/home/home'
})
}
},
getWxLoginCode(): Promise<string> {
return new Promise((resolve, reject) => {
wx.login({
success: (res) => {
if (res.code) {
resolve(res.code)
} else {
reject(new Error('获取登录凭证失败'))
}
},
fail: (err) => {
reject(new Error(err.errMsg || '获取登录凭证失败'))
},
})
})
},
})