feat(plan): 新增「加入计划」选择器页 + 增强官方计划浏览,修复返回不刷新
1) 新增 pages/plan-select(加入我的计划选择器,替换详情页 actionSheet) - 默认展示我全部计划(浏览,不再强制搜索),支持 最近创建/动作最多 排序 + 名称搜索 - 点选即把动作加入该计划并返回;无计划时引导新建 - 入口接在 detail 页「加入计划」(无 planId 时 navigate 至此) 2) 增强 pages/collection(官方训练计划) - 默认展示全部分级,新增 等级筛选 chips + 名称搜索(均用现有字段,不改后端) - 筛选/搜索纯前端,viewGroups 驱动渲染 3) 修复 plan-detail 从「添加动作」返回后列表不刷新(上轮已单独提交 7ff55a6) 4) app.json 注册 plan-select 页面
This commit is contained in:
@@ -68,7 +68,9 @@ Page({
|
||||
}).catch(() => {});
|
||||
},
|
||||
|
||||
// 底部主按钮:加入计划(真实选择器)
|
||||
// 底部主按钮:加入计划
|
||||
// - 若从某计划内进入(带 planId),直接加入该计划
|
||||
// - 否则进入「加入计划」选择器页,可浏览全部计划并筛选
|
||||
onAdd() {
|
||||
if (this.data.planId) {
|
||||
planSvc.addExercise(this.data.planId, this.data.id).then(() => {
|
||||
@@ -77,28 +79,13 @@ Page({
|
||||
}).catch(() => {});
|
||||
return;
|
||||
}
|
||||
auth.ensureLogin().then(() => planSvc.listMine()).then((res) => {
|
||||
const plans = (res && res.items) || res || [];
|
||||
if (!plans.length) {
|
||||
wx.showModal({
|
||||
title: '还没有训练计划',
|
||||
content: '先创建一个计划,再把动作加进去吧~',
|
||||
confirmText: '去创建',
|
||||
cancelText: '稍后',
|
||||
success: (r) => { if (r.confirm) wx.navigateTo({ url: '/pages/plan-edit/plan-edit' }); }
|
||||
});
|
||||
return;
|
||||
}
|
||||
const names = plans.slice(0, 6).map((p) => p.name);
|
||||
wx.showActionSheet({
|
||||
itemList: names,
|
||||
success: (sheet) => {
|
||||
const plan = plans[sheet.tapIndex];
|
||||
if (!plan) return;
|
||||
planSvc.addExercise(plan.id, this.data.id).then(() => {
|
||||
wx.showToast({ title: '已加入「' + plan.name + '」', icon: 'success' });
|
||||
}).catch(() => {});
|
||||
}
|
||||
auth.ensureLogin().then(() => {
|
||||
const name = this.data.exercise
|
||||
? (this.data.exercise.displayName || this.data.exercise.name)
|
||||
: '';
|
||||
wx.navigateTo({
|
||||
url: '/pages/plan-select/plan-select?exerciseId=' + encodeURIComponent(this.data.id) +
|
||||
'&name=' + encodeURIComponent(name || '')
|
||||
});
|
||||
}).catch(() => {});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user