|
|
@@ -502,43 +502,30 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // 首先获取红娘信息,以获取makerId
|
|
|
- const matchmakerInfo = await api.matchmaker.getByUserId(userInfo.userId)
|
|
|
- if (!matchmakerInfo || !matchmakerInfo.matchmakerId && !matchmakerInfo.matchmaker_id) {
|
|
|
- uni.showToast({
|
|
|
- title: '没有有效的makerId,无法签到',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- const makerId = matchmakerInfo.matchmakerId || matchmakerInfo.matchmaker_id
|
|
|
-
|
|
|
- // 执行签到
|
|
|
- const res = await api.matchmaker.doCheckin(makerId)
|
|
|
+ // 使用userId进行签到(后端会根据userId查询matchmaker并添加积分)
|
|
|
+ const res = await api.matchmaker.doCheckin(userInfo.userId)
|
|
|
console.log('签到API返回结果:', res)
|
|
|
+
|
|
|
+ // 判断签到结果
|
|
|
let success = false
|
|
|
let alreadySigned = false
|
|
|
- if (typeof res === 'boolean') {
|
|
|
- success = res
|
|
|
- } else if (typeof res === 'string') {
|
|
|
- success = res === 'true' || res === 'ok' || res === 'success'
|
|
|
+
|
|
|
+ // 后端返回格式: { code: 200, msg: "签到成功", data: true/false }
|
|
|
+ if (res === true) {
|
|
|
+ success = true
|
|
|
+ } else if (res === false) {
|
|
|
+ alreadySigned = true
|
|
|
} else if (res && typeof res === 'object') {
|
|
|
- if (typeof res.success === 'boolean') success = res.success
|
|
|
- if (typeof res.todaySigned === 'boolean') alreadySigned = res.todaySigned
|
|
|
- else if (typeof res.signed === 'boolean') alreadySigned = res.signed
|
|
|
- else if (typeof res.isSignedToday === 'boolean') alreadySigned = res.isSignedToday
|
|
|
- if (res.data && typeof res.data === 'object') {
|
|
|
- if (typeof res.data.success === 'boolean') success = res.data.success
|
|
|
- if (typeof res.data.todaySigned === 'boolean') alreadySigned = res.data.todaySigned
|
|
|
- else if (typeof res.data.signed === 'boolean') alreadySigned = res.data.signed
|
|
|
- else if (typeof res.data.isSignedToday === 'boolean') alreadySigned = res.data.isSignedToday
|
|
|
+ if (res.data === true) {
|
|
|
+ success = true
|
|
|
+ } else if (res.data === false || res.msg === '今日已签到') {
|
|
|
+ alreadySigned = true
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (success) {
|
|
|
uni.showToast({
|
|
|
- title: '签到成功',
|
|
|
+ title: '签到成功,+5积分',
|
|
|
icon: 'success'
|
|
|
})
|
|
|
this.isSignedToday = true
|
|
|
@@ -550,9 +537,11 @@ export default {
|
|
|
this.signedDays.sort((a, b) => a - b)
|
|
|
}
|
|
|
this.generateCalendar()
|
|
|
- this.loadProfileData()
|
|
|
+ // 刷新个人资料(包含积分)
|
|
|
+ await this.loadProfileData()
|
|
|
this.closeSignInPopup()
|
|
|
} else if (alreadySigned) {
|
|
|
+ this.isSignedToday = true
|
|
|
uni.showToast({
|
|
|
title: '今日已签到',
|
|
|
icon: 'none'
|
|
|
@@ -565,10 +554,19 @@ export default {
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('签到失败:', error)
|
|
|
- uni.showToast({
|
|
|
- title: error.msg || '签到失败,请稍后重试',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
+ // 检查是否是已签到的错误
|
|
|
+ if (error.msg && error.msg.includes('已签到')) {
|
|
|
+ this.isSignedToday = true
|
|
|
+ uni.showToast({
|
|
|
+ title: '今日已签到',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: error.msg || '签到失败,请稍后重试',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
// 签到(旧方法,保持兼容)
|