2026-03-30 18:08:27 +08:00

36 lines
742 B
JavaScript

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 }));
}
});