60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
import { MATH_FUNCTION_TYPES } from '../../constants/mathFunctions';
|
|
import tracker from '../../utils/tracker';
|
|
import { defaultShareConfig } from '../../config/config';
|
|
|
|
Page({
|
|
data: {
|
|
functionList: MATH_FUNCTION_TYPES,
|
|
},
|
|
|
|
onLoad() {
|
|
// 页面加载
|
|
},
|
|
|
|
/**
|
|
* 打开数学功能页面
|
|
*/
|
|
openMathFunction(e: WechatMiniprogram.TouchEvent) {
|
|
const functionId = e.currentTarget.dataset.function;
|
|
const functionItem = this.data.functionList.find(
|
|
(item) => item.id === functionId,
|
|
);
|
|
|
|
if (!functionItem) {
|
|
return;
|
|
}
|
|
|
|
// 统一跳转到 mathDraw 页面
|
|
if (functionItem.page) {
|
|
wx.navigateTo({
|
|
url: `/mathPages/mathDraw/mathDraw?id=${functionId}`,
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: `功能开发中,敬请期待`,
|
|
icon: 'none',
|
|
duration: 2500,
|
|
});
|
|
}
|
|
},
|
|
|
|
onShareAppMessage() {
|
|
// 上报分享埋点
|
|
tracker.reportShare('数感启蒙');
|
|
|
|
return {
|
|
...defaultShareConfig,
|
|
path: `/pages/mathIndex/mathIndex`,
|
|
};
|
|
},
|
|
onShareTimeline() {
|
|
// 上报分享埋点
|
|
tracker.reportShare('数感启蒙');
|
|
|
|
return {
|
|
...defaultShareConfig,
|
|
query: `/pages/mathIndex/mathIndex`,
|
|
};
|
|
},
|
|
});
|