xiangqinxiaochengxu/miniprogram/pages/match-detail/match-detail.js
wsb1224 0b590ee580 6-28 完结修复
1. 互选页面分组显示
2. 加入ID查找用户的功能
3. 根据ID排序
2026-06-28 13:56:56 +08:00

78 lines
2.6 KiB
JavaScript

const request = require('../../utils/request')
const { resolveImageUrl, resolveImageList } = require('../../utils/media')
const EDUCATION_MAP = {
1: '高中',
2: '大专',
3: '本科',
4: '硕士',
5: '博士'
}
Page({
data: {
loading: true,
userInfo: null,
activityId: null,
targetUserId: null,
matchId: null
},
onLoad(options) {
const activityId = options.activity_id ? Number(options.activity_id) : null
const targetUserId = options.target_user_id ? Number(options.target_user_id) : null
const matchId = options.match_id ? Number(options.match_id) : null
this.setData({ activityId, targetUserId, matchId })
if ((!activityId || !targetUserId) && !matchId) {
wx.showToast({ title: '缺少匹配信息', icon: 'none' })
this.setData({ loading: false })
return
}
this.loadDetail()
},
async loadDetail() {
try {
let detail
if (this.data.matchId) {
detail = await request({
url: `/matches/${this.data.matchId}/detail`
})
} else {
detail = await request({
url: `/activities/${this.data.activityId}/matches/${this.data.targetUserId}/detail`
})
}
const otherUser = detail.other_user || {}
const profileImages = resolveImageList(otherUser.profile_images)
const ageText = otherUser.birth_year
? (new Date().getFullYear() - otherUser.birth_year) + '岁'
: '未填写'
this.setData({
userInfo: {
...otherUser,
avatar_url: resolveImageUrl(otherUser.avatar_url || ''),
avatar_blur_url: resolveImageUrl(otherUser.avatar_blur_url || ''),
profileImages,
previewImage: profileImages.length ? profileImages[0] : resolveImageUrl(otherUser.avatar_url || ''),
nicknameText: otherUser.real_name || otherUser.nickname || '匿名用户',
cityText: otherUser.city || '城市未知',
educationText: EDUCATION_MAP[otherUser.education] || '学历未知',
ageText,
hobbiesText: Array.isArray(otherUser.hobbies) && otherUser.hobbies.length ? otherUser.hobbies.join('、') : '未填写爱好',
jobIndustryText: otherUser.job_industry || '未填写',
jobCompanyText: otherUser.job_company || '未填写',
selfIntroText: otherUser.self_intro || '暂无自我介绍',
matchedAt: detail.matched_at
}
})
} catch (err) {
console.error('Load match detail failed:', err)
wx.showToast({ title: err.message || '查看信息失败', icon: 'none' })
this.setData({ userInfo: null })
} finally {
this.setData({ loading: false })
}
}
})