const request = require('../../utils/request') const DEMO_MATCH_DETAILS = { 'demo-success-001': { matched_at: '2026-04-16 19:25', other_user: { nickname: '林晓晴', city: '上海', education: '硕士', hobbies: ['摄影', '咖啡', '旅行'], job_industry: '互联网', job_company: '星云科技', income_range: '20k-30k', self_intro: '喜欢用镜头记录生活,周末常去城市周边拍照或找一家安静的咖啡馆。' } }, 'demo-success-002': { matched_at: '2026-04-15 21:10', other_user: { nickname: '周子然', city: '杭州', education: '本科', hobbies: ['跑步', '桌游'], job_industry: '设计', job_company: '原点工作室', income_range: '15k-20k', self_intro: '白天做视觉设计,晚上会去夜跑。喜欢轻松但有想法的交流。' } }, 'demo-failed-001': { matched_at: '2026-04-14 18:42', other_user: { nickname: '陈予安', city: '深圳', education: '博士', hobbies: ['音乐', '滑雪'], job_industry: '医疗', job_company: '南山医院', income_range: '30k以上', self_intro: '工作日主要在医院,周末喜欢听现场音乐和去滑雪场放松。' } }, 'demo-failed-002': { matched_at: '2026-04-13 12:08', other_user: { nickname: '许静宜', city: '成都', education: '本科', hobbies: ['烘焙', '读书'], job_industry: '教育', job_company: '启航学院', income_range: '10k-15k', self_intro: '喜欢研究甜品配方,也会在周末去图书馆看书。' } } } Page({ data: { loading: true, userInfo: null, matchId: null }, onLoad(options) { const matchId = options.match_id ? String(options.match_id) : null this.setData({ matchId }) if (!matchId) { wx.showToast({ title: '缺少匹配信息', icon: 'none' }) this.setData({ loading: false }) return } this.loadDetail() }, getDemoDetail(matchId) { return DEMO_MATCH_DETAILS[matchId] || null }, async loadDetail() { try { const isDemoMatch = String(this.data.matchId).startsWith('demo-') const detail = isDemoMatch ? this.getDemoDetail(this.data.matchId) : await request({ url: `/matches/${this.data.matchId}/detail` }) if (!detail) { throw new Error('暂无详情数据') } const otherUser = detail.other_user || {} this.setData({ userInfo: { ...otherUser, nicknameText: otherUser.nickname || '匿名用户', cityText: otherUser.city || '城市未知', educationText: otherUser.education || '学历未知', hobbiesText: Array.isArray(otherUser.hobbies) && otherUser.hobbies.length ? otherUser.hobbies.join('、') : '未填写爱好', jobIndustryText: otherUser.job_industry || '未填写', jobCompanyText: otherUser.job_company || '未填写', incomeRangeText: otherUser.income_range || '未填写', selfIntroText: otherUser.self_intro || '暂无自我介绍', matchedAt: detail.matched_at } }) } catch (err) { console.error('Load match detail failed:', err) wx.showToast({ title: '查看信息失败', icon: 'none' }) this.setData({ userInfo: null }) } finally { this.setData({ loading: false }) } } })