47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
const request = require('../../utils/request')
|
|
|
|
Page({
|
|
data: {
|
|
loading: true,
|
|
userInfo: null,
|
|
matchId: null
|
|
},
|
|
|
|
onLoad(options) {
|
|
const matchId = options.match_id ? Number(options.match_id) : null
|
|
this.setData({ matchId })
|
|
if (!matchId) {
|
|
wx.showToast({ title: '缺少匹配信息', icon: 'none' })
|
|
this.setData({ loading: false })
|
|
return
|
|
}
|
|
this.loadDetail()
|
|
},
|
|
|
|
async loadDetail() {
|
|
try {
|
|
const detail = await request({ url: `/matches/${this.data.matchId}/detail` })
|
|
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 })
|
|
}
|
|
}
|
|
}) |