37 lines
783 B
JavaScript
37 lines
783 B
JavaScript
const auth = require('../../../utils/auth');
|
|
|
|
Page({
|
|
data: {
|
|
nickName: '',
|
|
certificateCount: '-',
|
|
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 || '',
|
|
certificateCount: p.certificateCount != null ? p.certificateCount : '-'
|
|
});
|
|
})
|
|
.catch(() => {})
|
|
.finally(() => this.setData({ loading: false }));
|
|
}
|
|
});
|
|
|