- 根因:c4639d0 给 plan-card 换上 <fc-icon> 但 plan-card.json 的 usingComponents 留空, 微信要求组件自行声明所引用的自定义组件,导致任何使用 plan-card 的页面编译报错、无法进入。 - 修复:plan-card/index.json 补上 fc-icon 声明(与 exercise-card/avatar/bottom-nav 一致)。 - 整体优化 my-plans: * 新增 status 四态(loading/list/empty/error),请求失败显示具体错误 + 『重新加载』按钮,杜绝静默进不去 * 加载态用 refresh-cw 旋转图标替代纯文字 * 遗留金色主按钮(新建计划/空态按钮/官方计划链接)统一到 Kinetic Dark 的 Volt 绿强调色,去除旧主题不一致
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
const app = getApp();
|
|
const planSvc = require('../../services/plan');
|
|
const auth = require('../../utils/auth');
|
|
|
|
Page({
|
|
data: {
|
|
statusBarHeight: 20,
|
|
plans: [],
|
|
status: 'loading', // 'loading' | 'list' | 'empty' | 'error'
|
|
errorMsg: ''
|
|
},
|
|
|
|
onLoad() {
|
|
this.setData({ statusBarHeight: app.globalData.statusBarHeight || 20 });
|
|
},
|
|
|
|
onShow() {
|
|
if (auth.isLogin()) this.load();
|
|
else {
|
|
wx.showToast({ title: '请先登录', icon: 'none' });
|
|
setTimeout(() => wx.navigateBack(), 600);
|
|
}
|
|
},
|
|
|
|
load() {
|
|
this.setData({ status: 'loading', errorMsg: '' });
|
|
planSvc.listMine().then((plans) => {
|
|
const list = plans || [];
|
|
this.setData({
|
|
plans: list,
|
|
status: list.length ? 'list' : 'empty'
|
|
});
|
|
}).catch((err) => {
|
|
this.setData({
|
|
plans: [],
|
|
status: 'error',
|
|
errorMsg: (err && err.message) ? err.message : '加载失败,请稍后重试'
|
|
});
|
|
});
|
|
},
|
|
|
|
onNew() {
|
|
wx.navigateTo({ url: '/pages/plan-edit/plan-edit?mode=new' });
|
|
},
|
|
|
|
onOpen(e) {
|
|
wx.navigateTo({ url: '/pages/plan-detail/plan-detail?id=' + encodeURIComponent(e.currentTarget.dataset.id) });
|
|
},
|
|
|
|
goOfficial() {
|
|
wx.navigateTo({ url: '/pages/collection/collection' });
|
|
}
|
|
});
|