feat(miniapp): final 3 pages migrated to TypeScript (matchmaker/messages/mine)

D1 debt cleared: all 11 miniapp core pages now TS-only.
tsc --noEmit -> 0 errors. JS sources deleted.
This commit is contained in:
Codex
2026-09-14 14:59:28 +08:00
parent 918368159c
commit 4f91be0cab
5 changed files with 208 additions and 313 deletions
+97
View File
@@ -0,0 +1,97 @@
/**
* 公益红娘服务页 U33
*
* 重构要点(遵循 AGENTS.md 不变量):
* - 数据:MatchmakerStore.fetchMyServices + activeService 派生
* - 展示:ui-matchmaker-card 展示当前进行中的服务,"查看红娘推荐"按钮触发跳转
* - 申请:跳转 matchmaker-apply 页,不在本页填写(AGENTS 第 1 条:用户永久免费)
* - 推荐:红娘推荐列表跳 fate-center 页(AGENTS 第 5 条:红娘不可替用户操作)
*/
import { matchmakerStore, appStore } from '../../stores';
import { ROUTE, to, buildPath, MATCHMAKER_SERVICE_STATUS } from '../../constants';
Page({
data: {
statusBarHeight: 20,
navBarHeight: 44,
loading: false,
firstLoaded: false,
activeService: null as any,
historyServices: [] as any[],
showRecommendations: false,
capabilities: [
'推荐合适对象(基于你的择偶条件)',
'调整择偶条件的专业建议',
'协助联系你感兴趣的意向对象',
'推荐参加合适的相亲活动',
'聊天沟通的方法指导',
],
emptyActions: [{ text: '申请红娘帮助', event: 'apply', variant: 'primary' }],
},
onLoad() {
try {
const sysInfo = wx.getSystemInfoSync ? wx.getSystemInfoSync() : null;
if (sysInfo) {
this.setData({ statusBarHeight: sysInfo.statusBarHeight || 20, navBarHeight: 44 });
}
} catch (e) { /* 默认值 */ }
(this as any)._unsub = matchmakerStore.bindToPage(this, { activeService: 'activeService' });
this.fetchServices();
},
onShow() {
if (this.data.firstLoaded) this.fetchServices();
},
onUnload() {
if ((this as any)._unsub) (this as any)._unsub();
},
async fetchServices() {
if (this.data.loading) return;
this.setData({ loading: true });
try {
await matchmakerStore.fetchMyServices();
const { activeService, myServices } = matchmakerStore.state;
const showRecommendations = !!activeService && (
activeService.status === MATCHMAKER_SERVICE_STATUS.IN_SERVICE ||
activeService.status === MATCHMAKER_SERVICE_STATUS.WAITING_USER
);
const historyServices = activeService
? myServices.filter((s: any) => s.serviceId !== activeService.serviceId)
: myServices;
this.setData({ loading: false, firstLoaded: true, activeService, historyServices, showRecommendations });
} catch (err: any) {
this.setData({ loading: false, firstLoaded: true });
appStore.toastError(err, '加载红娘服务失败');
}
},
onBack() { wx.navigateBack(); },
onApplyService() { wx.navigateTo({ url: ROUTE.DETAIL.MATCHMAKER_APPLY }); },
onViewService(e: any) {
const serviceId = e.detail.serviceId;
if (!serviceId) return;
wx.navigateTo({ url: to.matchmakerProgress(serviceId) });
},
onViewRecommendations(e: any) {
const serviceId = e.detail.serviceId;
if (!serviceId) return;
wx.navigateTo({ url: buildPath(ROUTE.MAIN.FATE_CENTER, { id: serviceId }) });
},
onHistoryTap(e: any) {
const serviceId = e.currentTarget.dataset.serviceId;
if (!serviceId) return;
wx.navigateTo({ url: to.matchmakerProgress(serviceId) });
},
onEmptyAction(e: any) {
if (e.detail.event === 'apply') this.onApplyService();
},
});