Files
fitness-coach/miniprogram/pages/collection-detail/collection-detail.js
wm b94eb706ff feat: Kinetic Dark 设计语言 + Lucide 图标迁移 + 首页轻量个性化
- 建立 Lucide 子集 iconfont(49 字形),全站 emoji 替换为 fc-icon 组件
- 重塑 Design Token(冷中性近黑底 + Volt 荧光绿 #B6F24E),消除硬编码颜色
- 首页登录后个性化:我的计划 / 我的收藏 / 今日推荐(纯前端复用现有 API)
- 后端 DEFAULT_EMOJI→Lucide 名,PALETTE 对齐 Kinetic Dark 语义色板
- 修复 person-standing 缺失字形;14 个官方组合 seed emoji 全部映射到现有字形
2026-07-22 21:38:56 +08:00

80 lines
2.3 KiB
JavaScript

const app = getApp();
const planSvc = require('../../services/plan');
const favSvc = require('../../services/favorite');
const auth = require('../../utils/auth');
const { iconName } = require('../../utils/icon-name');
Page({
data: {
statusBarHeight: 20,
slug: '',
collection: null,
exercises: [],
total: 0,
loading: true,
favorited: false
},
onLoad(query) {
const slug = query.slug || '';
this.setData({ statusBarHeight: app.globalData.statusBarHeight || 20, slug });
this.load();
if (auth.isLogin()) {
favSvc.planStatus(slug).then((r) => {
this.setData({ favorited: !!(r && r.favorited) });
}).catch(() => {});
}
},
load() {
this.setData({ loading: true });
planSvc.officialExercises(this.data.slug, 1, 60).then((res) => {
this.setData({
collection: { ...res.collection, icon: iconName(res.collection.emoji) },
exercises: (res && res.items) || [],
total: (res && res.total) || 0,
loading: false
});
}).catch(() => {
this.setData({ loading: false });
});
},
// 收藏 / 取消收藏官方计划
onToggleFav() {
auth.ensureLogin().then(() => {
const slug = this.data.slug;
const wasFav = this.data.favorited;
const op = wasFav ? favSvc.removePlan(slug) : favSvc.addPlan(slug);
op.then(() => {
this.setData({ favorited: !wasFav });
wx.showToast({ title: wasFav ? '已取消收藏' : '已收藏', icon: 'none' });
}).catch(() => {});
}).catch(() => {});
},
// 导入到我的计划
onImport() {
auth.ensureLogin().then(() => {
wx.showLoading({ title: '导入中…', mask: true });
planSvc.importOfficial(this.data.slug).then(() => {
wx.hideLoading();
wx.showToast({ title: '已导入到我的计划', icon: 'success' });
setTimeout(() => {
wx.navigateTo({ url: '/pages/my-plans/my-plans' });
}, 600);
}).catch(() => {
wx.hideLoading();
});
}).catch(() => {});
},
onExercise(e) {
if (!e || !e.detail || !e.detail.id) return;
wx.navigateTo({
url: '/pages/detail/detail?from=collection&slug=' +
encodeURIComponent(this.data.slug) + '&id=' + encodeURIComponent(e.detail.id)
});
}
});