|
@@ -33,7 +33,9 @@
|
|
|
<image class="avatar-large" :src="topThree[1].avatar_url || defaultAvatar" mode="aspectFill"></image>
|
|
<image class="avatar-large" :src="topThree[1].avatar_url || defaultAvatar" mode="aspectFill"></image>
|
|
|
<text class="matchmaker-name">{{ topThree[1].real_name }}</text>
|
|
<text class="matchmaker-name">{{ topThree[1].real_name }}</text>
|
|
|
<text class="success-count">成功人数: {{ topThree[1].success_couples || 0 }}</text>
|
|
<text class="success-count">成功人数: {{ topThree[1].success_couples || 0 }}</text>
|
|
|
- <view class="like-btn" @click="handleLike(topThree[1])">点赞</view>
|
|
|
|
|
|
|
+ <view class="like-btn" :class="{ liked: topThree[1].hasLiked }" @click="handleLike(topThree[1])">
|
|
|
|
|
+ {{ topThree[1].hasLiked ? '已点赞' : '点赞' }}
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<view class="top-three-item first">
|
|
<view class="top-three-item first">
|
|
@@ -41,7 +43,9 @@
|
|
|
<image class="avatar-large" :src="topThree[0].avatar_url || defaultAvatar" mode="aspectFill"></image>
|
|
<image class="avatar-large" :src="topThree[0].avatar_url || defaultAvatar" mode="aspectFill"></image>
|
|
|
<text class="matchmaker-name">{{ topThree[0].real_name }}</text>
|
|
<text class="matchmaker-name">{{ topThree[0].real_name }}</text>
|
|
|
<text class="success-count">成功人数: {{ topThree[0].success_couples || 0 }}</text>
|
|
<text class="success-count">成功人数: {{ topThree[0].success_couples || 0 }}</text>
|
|
|
- <view class="like-btn active" @click="handleLike(topThree[0])">点赞</view>
|
|
|
|
|
|
|
+ <view class="like-btn" :class="{ liked: topThree[0].hasLiked }" @click="handleLike(topThree[0])">
|
|
|
|
|
+ {{ topThree[0].hasLiked ? '已点赞' : '点赞' }}
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<view class="top-three-item third">
|
|
<view class="top-three-item third">
|
|
@@ -49,7 +53,9 @@
|
|
|
<image class="avatar-large" :src="topThree[2].avatar_url || defaultAvatar" mode="aspectFill"></image>
|
|
<image class="avatar-large" :src="topThree[2].avatar_url || defaultAvatar" mode="aspectFill"></image>
|
|
|
<text class="matchmaker-name">{{ topThree[2].real_name }}</text>
|
|
<text class="matchmaker-name">{{ topThree[2].real_name }}</text>
|
|
|
<text class="success-count">成功人数: {{ topThree[2].success_couples || 0 }}</text>
|
|
<text class="success-count">成功人数: {{ topThree[2].success_couples || 0 }}</text>
|
|
|
- <view class="like-btn" @click="handleLike(topThree[2])">点赞</view>
|
|
|
|
|
|
|
+ <view class="like-btn" :class="{ liked: topThree[2].hasLiked }" @click="handleLike(topThree[2])">
|
|
|
|
|
+ {{ topThree[2].hasLiked ? '已点赞' : '点赞' }}
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
@@ -60,10 +66,12 @@
|
|
|
<image class="avatar-small" :src="item.avatar_url || defaultAvatar" mode="aspectFill"></image>
|
|
<image class="avatar-small" :src="item.avatar_url || defaultAvatar" mode="aspectFill"></image>
|
|
|
<view class="matchmaker-info">
|
|
<view class="matchmaker-info">
|
|
|
<text class="matchmaker-name-normal">{{ item.real_name }}</text>
|
|
<text class="matchmaker-name-normal">{{ item.real_name }}</text>
|
|
|
- <text class="success-count-normal">成功人数: {{ item.success_couples || 0 }} 人</text>
|
|
|
|
|
|
|
+ <text class="success-count-normal">成功: {{ item.success_couples || 0 }} | 点赞: {{ item.weeklyLikes || 0 }}</text>
|
|
|
<text class="user-rating">等级: {{ item.level_name || '青铜红娘' }}</text>
|
|
<text class="user-rating">等级: {{ item.level_name || '青铜红娘' }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="like-btn-small" @click="handleLike(item)">点赞</view>
|
|
|
|
|
|
|
+ <view class="like-btn-small" :class="{ liked: item.hasLiked }" @click="handleLike(item)">
|
|
|
|
|
+ {{ item.hasLiked ? '已赞' : '点赞' }}
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
<view v-if="loading" class="loading-tip">加载中...</view>
|
|
<view v-if="loading" class="loading-tip">加载中...</view>
|
|
|
<view v-if="!loading && restList.length === 0" class="empty-tip">暂无更多红娘</view>
|
|
<view v-if="!loading && restList.length === 0" class="empty-tip">暂无更多红娘</view>
|
|
@@ -105,7 +113,8 @@ export default {
|
|
|
return {
|
|
return {
|
|
|
loading: false,
|
|
loading: false,
|
|
|
rankingList: [],
|
|
rankingList: [],
|
|
|
- defaultAvatar: '/static/default-avatar.svg'
|
|
|
|
|
|
|
+ defaultAvatar: '/static/default-avatar.svg',
|
|
|
|
|
+ userId: null
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
@@ -119,6 +128,11 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onLoad() {
|
|
onLoad() {
|
|
|
|
|
+ // 获取当前用户ID
|
|
|
|
|
+ const userInfo = uni.getStorageSync('userInfo')
|
|
|
|
|
+ if (userInfo && userInfo.userId) {
|
|
|
|
|
+ this.userId = userInfo.userId
|
|
|
|
|
+ }
|
|
|
// 加载排行榜数据
|
|
// 加载排行榜数据
|
|
|
this.loadRankingData()
|
|
this.loadRankingData()
|
|
|
},
|
|
},
|
|
@@ -127,17 +141,21 @@ export default {
|
|
|
goBack() {
|
|
goBack() {
|
|
|
uni.navigateBack()
|
|
uni.navigateBack()
|
|
|
},
|
|
},
|
|
|
- // 加载排行榜数据
|
|
|
|
|
|
|
+ // 加载排行榜数据(使用本周排行榜API)
|
|
|
async loadRankingData() {
|
|
async loadRankingData() {
|
|
|
this.loading = true
|
|
this.loading = true
|
|
|
try {
|
|
try {
|
|
|
- const res = await api.matchmaker.getRankingData({ limit: 20 })
|
|
|
|
|
|
|
+ // 使用本周排行榜API,传入userId以获取点赞状态
|
|
|
|
|
+ const res = await api.matchmaker.getWeeklyRanking({
|
|
|
|
|
+ limit: 20,
|
|
|
|
|
+ userId: this.userId
|
|
|
|
|
+ })
|
|
|
if (res && Array.isArray(res)) {
|
|
if (res && Array.isArray(res)) {
|
|
|
- this.rankingList = res
|
|
|
|
|
|
|
+ this.rankingList = res.map(item => this.formatMatchmaker(item))
|
|
|
} else if (res && res.data && Array.isArray(res.data)) {
|
|
} else if (res && res.data && Array.isArray(res.data)) {
|
|
|
- this.rankingList = res.data
|
|
|
|
|
|
|
+ this.rankingList = res.data.map(item => this.formatMatchmaker(item))
|
|
|
}
|
|
}
|
|
|
- console.log('排行榜数据:', this.rankingList)
|
|
|
|
|
|
|
+ console.log('本周排行榜数据:', this.rankingList)
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error('加载排行榜数据失败:', e)
|
|
console.error('加载排行榜数据失败:', e)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
@@ -148,14 +166,66 @@ export default {
|
|
|
this.loading = false
|
|
this.loading = false
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ // 格式化红娘数据(统一字段名)
|
|
|
|
|
+ formatMatchmaker(item) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ matchmaker_id: item.matchmakerId || item.matchmaker_id,
|
|
|
|
|
+ real_name: item.realName || item.real_name,
|
|
|
|
|
+ avatar_url: item.avatarUrl || item.avatar_url,
|
|
|
|
|
+ success_couples: item.successCouples || item.success_couples,
|
|
|
|
|
+ level_name: item.levelName || item.level_name,
|
|
|
|
|
+ weeklyLikes: item.weeklyLikes || 0,
|
|
|
|
|
+ hasLiked: item.hasLiked || false
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
// 点赞
|
|
// 点赞
|
|
|
- handleLike(matchmaker) {
|
|
|
|
|
- // 实现点赞功能
|
|
|
|
|
- console.log('点赞红娘:', matchmaker.realName)
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '点赞成功',
|
|
|
|
|
- icon: 'success'
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ async handleLike(matchmaker) {
|
|
|
|
|
+ // 检查是否已点赞
|
|
|
|
|
+ if (matchmaker.hasLiked) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '本周已点赞过该红娘',
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否登录
|
|
|
|
|
+ if (!this.userId) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '请先登录',
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const matchmakerId = matchmaker.matchmaker_id || matchmaker.matchmakerId
|
|
|
|
|
+ const res = await api.matchmaker.likeMatchmaker(this.userId, matchmakerId)
|
|
|
|
|
+
|
|
|
|
|
+ if (res && (res.code === 200 || res.liked)) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '点赞成功',
|
|
|
|
|
+ icon: 'success'
|
|
|
|
|
+ })
|
|
|
|
|
+ // 更新本地状态
|
|
|
|
|
+ matchmaker.hasLiked = true
|
|
|
|
|
+ matchmaker.weeklyLikes = (matchmaker.weeklyLikes || 0) + 1
|
|
|
|
|
+ // 刷新列表
|
|
|
|
|
+ this.loadRankingData()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: res.message || '点赞失败',
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('点赞失败:', e)
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: e.message || '点赞失败',
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
// 导航到工作台
|
|
// 导航到工作台
|
|
|
navigateToWorkbench() {
|
|
navigateToWorkbench() {
|
|
@@ -356,10 +426,10 @@ export default {
|
|
|
font-weight: bold;
|
|
font-weight: bold;
|
|
|
border: 2rpx solid #FFFFFF;
|
|
border: 2rpx solid #FFFFFF;
|
|
|
|
|
|
|
|
- &.active {
|
|
|
|
|
- background: #E91E63;
|
|
|
|
|
- color: #FFFFFF;
|
|
|
|
|
- border-color: #E91E63;
|
|
|
|
|
|
|
+ &.liked {
|
|
|
|
|
+ background: rgba(255, 255, 255, 0.5);
|
|
|
|
|
+ color: rgba(255, 255, 255, 0.8);
|
|
|
|
|
+ border-color: rgba(255, 255, 255, 0.5);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -427,6 +497,11 @@ export default {
|
|
|
border-radius: 25rpx;
|
|
border-radius: 25rpx;
|
|
|
font-size: 26rpx;
|
|
font-size: 26rpx;
|
|
|
font-weight: bold;
|
|
font-weight: bold;
|
|
|
|
|
+
|
|
|
|
|
+ &.liked {
|
|
|
|
|
+ background: #CCCCCC;
|
|
|
|
|
+ color: #999999;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|