85 lines
2.3 KiB
TypeScript
85 lines
2.3 KiB
TypeScript
import { CATEGORIES } from '../../core/data/categories';
|
|
import { AGE_BANDS, AgeBandKey } from '../../core/data/difficulty';
|
|
|
|
const CATEGORY_TABS = [
|
|
{ id: 'all', name: '全部' },
|
|
...CATEGORIES.map((c) => ({ id: c.id, name: c.name })),
|
|
];
|
|
|
|
const AGE_BAND_ICONS = ['🌱', '🚀', '🎓', '🧠', '🏆'] as const;
|
|
|
|
const MOCK_HOT_RECOMMENDS = [
|
|
{
|
|
id: 'hot-1',
|
|
title: '100以内的加减法',
|
|
desc: '让算术变得像游戏一样简单',
|
|
tag: '数学',
|
|
score: '4.8',
|
|
emoji: '🍊',
|
|
},
|
|
{
|
|
id: 'hot-2',
|
|
title: '创意涂鸦大作战',
|
|
desc: '释放孩子的艺术想象力',
|
|
tag: '艺术',
|
|
score: '4.9',
|
|
emoji: '🎨',
|
|
},
|
|
] as const;
|
|
|
|
const { statusBarHeight } = wx.getWindowInfo();
|
|
|
|
Page({
|
|
data: {
|
|
statusBarHeight,
|
|
tabs: CATEGORY_TABS,
|
|
activeTab: 'all',
|
|
ageBands: AGE_BANDS.map((item, idx) => ({
|
|
...item,
|
|
icon: AGE_BAND_ICONS[idx] || '🌟',
|
|
})),
|
|
activeAgeBand: AGE_BANDS[0].key as AgeBandKey,
|
|
hotRecommends: [...MOCK_HOT_RECOMMENDS],
|
|
},
|
|
|
|
onTabChange(e: WechatMiniprogram.CustomEvent) {
|
|
this.setData({ activeTab: e.detail.id });
|
|
},
|
|
|
|
onTapAgeBand(e: WechatMiniprogram.TouchEvent) {
|
|
const key = e.currentTarget.dataset.key as AgeBandKey | undefined;
|
|
if (!key) return;
|
|
this.setData({ activeAgeBand: key });
|
|
},
|
|
|
|
onTapHotRecommend(e: WechatMiniprogram.TouchEvent) {
|
|
const title = e.currentTarget.dataset.title as string | undefined;
|
|
if (!title) return;
|
|
wx.showToast({ title: `已选择:${title}`, icon: 'none' });
|
|
},
|
|
|
|
onTapAgeMore() {
|
|
wx.showToast({ title: '分龄全部 即将上线', icon: 'none' });
|
|
},
|
|
|
|
onTapHotMore() {
|
|
wx.showToast({ title: '热门推荐 即将上线', icon: 'none' });
|
|
},
|
|
|
|
onShareAppMessage() {
|
|
return {
|
|
title: '涂鸦丫 - 快来生成宝宝的专属学习卡',
|
|
path: '/pages/home/home',
|
|
imageUrl:
|
|
'https://cdn.joeyone.cn/doodle/share-img/index-share-v2.png',
|
|
};
|
|
},
|
|
|
|
onShareTimeline() {
|
|
return {
|
|
title: '涂鸦丫 - 快来生成宝宝的专属学习卡',
|
|
query: '',
|
|
};
|
|
},
|
|
});
|