海报随机文案 + 找伙伴匹配数据库用户

## 海报功能
1. 10条随机朋友圈文案(基于书内容)
2. 二维码已带用户ID

## 找伙伴
1. 新增 /api/match/users API
2. 只匹配数据库中的真实用户
3. 排除自己,筛选有头像和联系方式的用户
This commit is contained in:
卡若
2026-01-29 12:25:01 +08:00
parent 0f50fb7c3b
commit cd2c8d7cc5
3 changed files with 134 additions and 17 deletions

View File

@@ -257,7 +257,7 @@ Page({
})
},
// 开始匹配
// 开始匹配 - 只匹配数据库中的真实用户
async startMatch() {
this.setData({
isMatching: true,
@@ -270,29 +270,23 @@ Page({
this.setData({ matchAttempts: this.data.matchAttempts + 1 })
}, 1000)
// 尝试从API获取真实用户
// 从数据库获取真实用户匹配
let matchedUser = null
try {
const res = await app.request('/api/ckb/match', {
const res = await app.request('/api/match/users', {
method: 'POST',
data: {
matchType: this.data.selectedType,
userId: app.globalData.userInfo?.id || '',
phone: this.data.phoneNumber,
wechat: this.data.wechatId
userId: app.globalData.userInfo?.id || ''
}
})
if (res.success && res.data) {
matchedUser = res.data
console.log('[Match] 从数据库匹配到用户:', matchedUser.nickname)
}
} catch (e) {
console.log('API匹配失败使用模拟数据')
}
// 如果API没返回使用模拟数据
if (!matchedUser) {
matchedUser = this.generateMockMatch()
console.log('[Match] 数据库匹配失败:', e)
}
// 延迟显示结果(模拟匹配过程)
@@ -300,6 +294,18 @@ Page({
setTimeout(() => {
clearInterval(timer)
// 如果没有匹配到用户,提示用户
if (!matchedUser) {
this.setData({ isMatching: false })
wx.showModal({
title: '暂无匹配',
content: '当前暂无合适的匹配用户,请稍后再试',
showCancel: false,
confirmText: '知道了'
})
return
}
// 增加今日匹配次数
const newCount = this.data.todayMatchCount + 1
const matchesRemaining = this.data.hasFullBook ? 999999 : Math.max(0, this.data.totalMatchesAllowed - newCount)
@@ -313,7 +319,7 @@ Page({
})
this.saveTodayMatchCount(newCount)
// 上报匹配行为
// 上报匹配行为到存客宝
this.reportMatch(matchedUser)
}, delay)