chore: establish V1.1 recovery baseline
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* 公益红娘服务页 U33
|
||||
*
|
||||
* 重构要点(遵循 AGENTS.md 不变量):
|
||||
* - 数据:MatchmakerStore.fetchMyServices + activeService 派生
|
||||
* - 展示:ui-matchmaker-card 展示当前进行中的服务,"查看红娘推荐"按钮触发跳转
|
||||
* - 申请:跳转 matchmaker-apply 页,不在本页填写(AGENTS 第 1 条:用户永久免费,无高级/付费红娘差异化)
|
||||
* - 推荐:红娘推荐列表跳 fate-center 页,最终 Like/Pass 仍走 matchStore(AGENTS 第 5 条:红娘不可替用户操作)
|
||||
* - 进度:跳 matchmaker-progress 页查看服务跟进记录
|
||||
*/
|
||||
const { matchmakerStore, appStore } = require('../../stores');
|
||||
const { to, ROUTE, buildPath, MATCHMAKER_SERVICE_STATUS } = require('../../constants');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 20,
|
||||
navBarHeight: 44,
|
||||
loading: false,
|
||||
firstLoaded: false,
|
||||
/** @type {import('../../types').MatchmakerService|null} 进行中的服务 */
|
||||
activeService: null,
|
||||
/** @type {import('../../types').MatchmakerService[]} 历史(不含活跃服务) */
|
||||
historyServices: [],
|
||||
/** 是否展示"查看红娘推荐"按钮 */
|
||||
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._unsub = matchmakerStore.bindToPage(this, {
|
||||
activeService: 'activeService',
|
||||
});
|
||||
this.fetchServices();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 从 apply/progress 页返回后刷新(状态可能已变更)
|
||||
if (this.data.firstLoaded) {
|
||||
this.fetchServices();
|
||||
}
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
if (this._unsub) this._unsub();
|
||||
},
|
||||
|
||||
async fetchServices() {
|
||||
if (this.data.loading) return;
|
||||
this.setData({ loading: true });
|
||||
try {
|
||||
await matchmakerStore.fetchMyServices();
|
||||
const { activeService, myServices } = matchmakerStore.state;
|
||||
// 仅当服务处于 in_service / waiting_user 时展示"查看推荐"入口
|
||||
const showRecommendations = !!activeService && (
|
||||
activeService.status === MATCHMAKER_SERVICE_STATUS.IN_SERVICE ||
|
||||
activeService.status === MATCHMAKER_SERVICE_STATUS.WAITING_USER
|
||||
);
|
||||
// 历史列表排除活跃服务,避免重复展示
|
||||
const historyServices = activeService
|
||||
? myServices.filter((s) => s.serviceId !== activeService.serviceId)
|
||||
: myServices;
|
||||
this.setData({
|
||||
loading: false,
|
||||
firstLoaded: true,
|
||||
activeService,
|
||||
historyServices,
|
||||
showRecommendations,
|
||||
});
|
||||
} catch (err) {
|
||||
this.setData({ loading: false, firstLoaded: true });
|
||||
appStore.toastError(err, '加载红娘服务失败');
|
||||
}
|
||||
},
|
||||
|
||||
onBack() {
|
||||
wx.navigateBack();
|
||||
},
|
||||
|
||||
/** 申请红娘帮助 */
|
||||
onApplyService() {
|
||||
wx.navigateTo({ url: ROUTE.DETAIL.MATCHMAKER_APPLY });
|
||||
},
|
||||
|
||||
/** 查看服务进度(卡片头部点击) */
|
||||
onViewService(e) {
|
||||
const serviceId = e.detail.serviceId;
|
||||
if (!serviceId) return;
|
||||
wx.navigateTo({ url: to.matchmakerProgress(serviceId) });
|
||||
},
|
||||
|
||||
/**
|
||||
* 查看红娘推荐(AGENTS 第 5 条:红娘不替用户 Like,推荐列表里仍由用户本人操作)
|
||||
* 跳 fate-center,由该页通过 matchStore.like/pass 完成最终选择
|
||||
*/
|
||||
onViewRecommendations(e) {
|
||||
const serviceId = e.detail.serviceId;
|
||||
if (!serviceId) return;
|
||||
wx.navigateTo({ url: buildPath(ROUTE.MAIN.FATE_CENTER, { id: serviceId }) });
|
||||
},
|
||||
|
||||
/** 历史服务列表项点击 */
|
||||
onHistoryTap(e) {
|
||||
const serviceId = e.currentTarget.dataset.serviceId;
|
||||
if (!serviceId) return;
|
||||
wx.navigateTo({ url: to.matchmakerProgress(serviceId) });
|
||||
},
|
||||
|
||||
/** 空状态操作 */
|
||||
onEmptyAction(e) {
|
||||
const { event } = e.detail;
|
||||
if (event === 'apply') this.onApplyService();
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user