const auth = require('../../../utils/auth'); Page({ data: { nickName: '', points: '-', loading: false }, onShow() { const accessToken = wx.getStorageSync('accessToken') || ''; if (!accessToken) { wx.redirectTo({ url: '/subpackages/mine/login/login' }); return; } this.loadProfile(); }, loadProfile() { if (this.data.loading) return; this.setData({ loading: true }); auth .fetchMyProfile() .then((profile) => { const p = profile || {}; this.setData({ nickName: p.nickName || '', points: p.points != null ? p.points : '-' }); }) .catch(() => {}) .finally(() => this.setData({ loading: false })); } });