- 新增 miniapp/constants/profileLabels.js 作为「枚举码→中文简体」唯一字典 (婚姻/子女/学历/职业/吸烟饮酒/择偶子女/红娘状态),覆盖表单值与种子 实际值两套并集,保证详情页无论后端返回哪种码都显示中文 - 修复「择偶条件-子女」下拉英文选项(any/accept/reject→不限/可接受/不接受), 改用 value/label 数组 + range-key="label" - 修复 recommend-card / user-card / profile-detail / profile-confirm 直接渲染 后端枚举码(educationCode/maritalStatus/occupationCode…)的问题,改由 observers 派生中文 label 上屏 - 清理残留英文文案:Required 条件→必须符合的条件、喜欢TA/向Ta→喜欢对方/向对方、 U51 服务预约→服务预约、U64 公益服务记录→公益服务记录 - 修复 7 个英文窗口标题与 3 个英文占位页正文 - matchmaker 历史服务状态消除原始码兜底,统一走字典 - 加固 scripts/audit-miniapp-language.mjs(A 整行先剥离 mustache、B 排除 bind:action 处理器、F 窗口标题、JPG/PNG 入白名单) - 新增 ui-tests/miniapp-language-contracts.mjs 语种守卫(复用审计脚本,断言 0 命中), UI 契约门禁 MIN_GUARDS 21→22;已做负向注入验证判别力
105 lines
3.7 KiB
TypeScript
105 lines
3.7 KiB
TypeScript
/**
|
|
* 公益红娘服务页 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, MATCHMAKER_SERVICE_STATUS_LABEL } 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 withStatusText = (s: any) => ({
|
|
...s,
|
|
statusText: MATCHMAKER_SERVICE_STATUS_LABEL[s.status] || s.statusText || s.status || '',
|
|
})
|
|
const historyServices = (activeService
|
|
? myServices.filter((s: any) => s.serviceId !== activeService.serviceId)
|
|
: myServices).map(withStatusText)
|
|
const activeServiceWithText = activeService
|
|
? { ...activeService, statusText: MATCHMAKER_SERVICE_STATUS_LABEL[activeService.status] || activeService.statusText || activeService.status || '' }
|
|
: null
|
|
this.setData({ loading: false, firstLoaded: true, activeService: activeServiceWithText, 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();
|
|
},
|
|
});
|