ranking.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <template>
  2. <view class="matchmaker-ranking">
  3. <!-- 顶部导航栏 -->
  4. <view class="header">
  5. <view class="back-btn" @click="goBack"></view>
  6. <text class="header-title">红娘排行榜</text>
  7. <view class="placeholder"></view>
  8. </view>
  9. <!-- 更新提示 -->
  10. <view class="update-info">
  11. <text class="update-text">每天17点自动更新数据</text>
  12. </view>
  13. <!-- 本周最佳榜标题 -->
  14. <view class="section-title-wrapper">
  15. <text class="section-title">
  16. <text class="title-icon">👩‍❤️‍💋‍👨</text>
  17. 本周最佳榜
  18. <text class="title-icon">👩‍❤️‍💋‍👨</text>
  19. </text>
  20. </view>
  21. <!-- 榜说明 -->
  22. <view class="ranking-description">
  23. <text class="description-text">榜单综合万粉以下红娘的日牵线数,用户好评数 等综合因素,上榜为前20的红娘</text>
  24. </view>
  25. <!-- 前三名展示 -->
  26. <view class="top-three-container" v-if="topThree.length >= 3">
  27. <view class="top-three-item second">
  28. <text class="rank-number">2</text>
  29. <image class="avatar-large" :src="topThree[1].avatar_url || defaultAvatar" mode="aspectFill"></image>
  30. <text class="matchmaker-name">{{ topThree[1].real_name }}</text>
  31. <text class="success-count">成功人数: {{ topThree[1].success_couples || 0 }}</text>
  32. <view class="like-btn" @click="handleLike(topThree[1])">点赞</view>
  33. </view>
  34. <view class="top-three-item first">
  35. <text class="rank-number">1</text>
  36. <image class="avatar-large" :src="topThree[0].avatar_url || defaultAvatar" mode="aspectFill"></image>
  37. <text class="matchmaker-name">{{ topThree[0].real_name }}</text>
  38. <text class="success-count">成功人数: {{ topThree[0].success_couples || 0 }}</text>
  39. <view class="like-btn active" @click="handleLike(topThree[0])">点赞</view>
  40. </view>
  41. <view class="top-three-item third">
  42. <text class="rank-number">3</text>
  43. <image class="avatar-large" :src="topThree[2].avatar_url || defaultAvatar" mode="aspectFill"></image>
  44. <text class="matchmaker-name">{{ topThree[2].real_name }}</text>
  45. <text class="success-count">成功人数: {{ topThree[2].success_couples || 0 }}</text>
  46. <view class="like-btn" @click="handleLike(topThree[2])">点赞</view>
  47. </view>
  48. </view>
  49. <!-- 排行榜列表 -->
  50. <scroll-view scroll-y class="ranking-list">
  51. <view class="ranking-item" v-for="(item, index) in restList" :key="item.matchmaker_id">
  52. <text class="rank-number-normal">{{ index + 4 }}</text>
  53. <image class="avatar-small" :src="item.avatar_url || defaultAvatar" mode="aspectFill"></image>
  54. <view class="matchmaker-info">
  55. <text class="matchmaker-name-normal">{{ item.real_name }}</text>
  56. <text class="success-count-normal">成功人数: {{ item.success_couples || 0 }} 人</text>
  57. <text class="user-rating">等级: {{ item.level_name || '青铜红娘' }}</text>
  58. </view>
  59. <view class="like-btn-small" @click="handleLike(item)">点赞</view>
  60. </view>
  61. <view v-if="loading" class="loading-tip">加载中...</view>
  62. <view v-if="!loading && restList.length === 0" class="empty-tip">暂无更多红娘</view>
  63. </scroll-view>
  64. <!-- 底部导航 -->
  65. <view class="tabbar">
  66. <view class="tabbar-item home" @click="navigateToWorkbench">
  67. <view class="tabbar-icon"></view>
  68. <text class="tabbar-text">工作台</text>
  69. </view>
  70. <view class="tabbar-item resources" @click="navigateToMyResources">
  71. <view class="tabbar-icon"></view>
  72. <text class="tabbar-text">我的资源</text>
  73. </view>
  74. <view class="tabbar-item trophy active" @click="navigateToRanking">
  75. <view class="tabbar-icon"></view>
  76. <text class="tabbar-text">排行榜</text>
  77. </view>
  78. <view class="tabbar-item message" @click="navigateToMessage">
  79. <view class="tabbar-icon">
  80. <view v-if="unreadCount > 0" class="badge">{{ unreadCount }}</view>
  81. </view>
  82. <text class="tabbar-text">消息</text>
  83. </view>
  84. <view class="tabbar-item mine" @click="navigateToMine">
  85. <view class="tabbar-icon"></view>
  86. <text class="tabbar-text">我的</text>
  87. </view>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. import api from '@/utils/api.js'
  93. export default {
  94. data() {
  95. return {
  96. loading: false,
  97. rankingList: [],
  98. defaultAvatar: '/static/default-avatar.svg'
  99. }
  100. },
  101. computed: {
  102. // 前三名
  103. topThree() {
  104. return this.rankingList.slice(0, 3)
  105. },
  106. // 第4名及以后
  107. restList() {
  108. return this.rankingList.slice(3)
  109. },
  110. // 全局未读消息数
  111. unreadCount() {
  112. return this.$store.getters.getTotalUnread || 0
  113. }
  114. },
  115. onLoad() {
  116. // 加载排行榜数据
  117. this.loadRankingData()
  118. },
  119. methods: {
  120. // 返回上一页
  121. goBack() {
  122. uni.navigateBack()
  123. },
  124. // 加载排行榜数据
  125. async loadRankingData() {
  126. this.loading = true
  127. try {
  128. const res = await api.matchmaker.getRankingData({ limit: 20 })
  129. if (res && Array.isArray(res)) {
  130. this.rankingList = res
  131. } else if (res && res.data && Array.isArray(res.data)) {
  132. this.rankingList = res.data
  133. }
  134. console.log('排行榜数据:', this.rankingList)
  135. } catch (e) {
  136. console.error('加载排行榜数据失败:', e)
  137. uni.showToast({
  138. title: '加载失败',
  139. icon: 'none'
  140. })
  141. } finally {
  142. this.loading = false
  143. }
  144. },
  145. // 点赞
  146. handleLike(matchmaker) {
  147. // 实现点赞功能
  148. console.log('点赞红娘:', matchmaker.realName)
  149. uni.showToast({
  150. title: '点赞成功',
  151. icon: 'success'
  152. })
  153. },
  154. // 导航到工作台
  155. navigateToWorkbench() {
  156. uni.redirectTo({
  157. url: '/pages/matchmaker-workbench/index'
  158. })
  159. },
  160. // 导航到我的资源
  161. navigateToMyResources() {
  162. uni.redirectTo({
  163. url: '/pages/matchmaker-workbench/my-resources'
  164. })
  165. },
  166. // 导航到排行榜
  167. navigateToRanking() {
  168. // 已在排行榜页面,无需跳转
  169. },
  170. // 导航到消息
  171. navigateToMessage() {
  172. uni.redirectTo({
  173. url: '/pages/matchmaker-workbench/message'
  174. })
  175. },
  176. // 导航到我的
  177. navigateToMine() {
  178. uni.redirectTo({
  179. url: '/pages/matchmaker-workbench/mine'
  180. })
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. .matchmaker-ranking {
  187. min-height: 100vh;
  188. background: linear-gradient(135deg, #FFF3F6 0%, #FFE4E8 100%);
  189. display: flex;
  190. flex-direction: column;
  191. }
  192. /* 顶部导航栏 */
  193. .header {
  194. display: flex;
  195. align-items: center;
  196. justify-content: space-between;
  197. padding: 25rpx 30rpx;
  198. padding-top: calc(25rpx + env(safe-area-inset-top));
  199. background: #FFF9F9;
  200. border-bottom: 1rpx solid #F0F0F0;
  201. .back-btn {
  202. width: 70rpx;
  203. height: 70rpx;
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. background: rgba(240, 240, 240, 0.5);
  208. border-radius: 50%;
  209. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23333"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>');
  210. background-size: 40rpx 40rpx;
  211. background-repeat: no-repeat;
  212. background-position: center;
  213. }
  214. .header-title {
  215. font-size: 38rpx;
  216. font-weight: bold;
  217. color: #333;
  218. }
  219. .placeholder {
  220. width: 70rpx;
  221. }
  222. }
  223. /* 更新提示 */
  224. .update-info {
  225. background: #FFF3E0;
  226. padding: 15rpx;
  227. text-align: center;
  228. .update-text {
  229. font-size: 24rpx;
  230. color: #FF9800;
  231. }
  232. }
  233. /* 本周最佳榜标题 */
  234. .section-title-wrapper {
  235. text-align: center;
  236. margin: 30rpx 0 15rpx;
  237. .section-title {
  238. display: inline-block;
  239. font-size: 36rpx;
  240. font-weight: bold;
  241. color: #E91E63;
  242. line-height: 1.4;
  243. .title-icon {
  244. font-size: 40rpx;
  245. margin: 0 10rpx;
  246. }
  247. }
  248. }
  249. /* 榜说明 */
  250. .ranking-description {
  251. padding: 0 30rpx 25rpx;
  252. .description-text {
  253. display: block;
  254. font-size: 26rpx;
  255. color: #666;
  256. line-height: 1.5;
  257. text-align: center;
  258. }
  259. }
  260. /* 前三名展示 */
  261. .top-three-container {
  262. display: flex;
  263. justify-content: space-around;
  264. align-items: flex-end;
  265. padding: 0 20rpx 40rpx;
  266. background: #FFF9F9;
  267. border-radius: 20rpx;
  268. margin: 0 20rpx 20rpx;
  269. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  270. .top-three-item {
  271. display: flex;
  272. flex-direction: column;
  273. align-items: center;
  274. padding: 20rpx;
  275. border-radius: 20rpx;
  276. position: relative;
  277. &.first {
  278. background: linear-gradient(135deg, #FFD700 0%, #FFA000 100%);
  279. width: 280rpx;
  280. height: 400rpx;
  281. order: 2;
  282. margin-bottom: 30rpx;
  283. }
  284. &.second {
  285. background: linear-gradient(135deg, #C0C0C0 0%, #A8A8A8 100%);
  286. width: 240rpx;
  287. height: 350rpx;
  288. order: 1;
  289. }
  290. &.third {
  291. background: linear-gradient(135deg, #CD7F32 0%, #B87333 100%);
  292. width: 240rpx;
  293. height: 350rpx;
  294. order: 3;
  295. }
  296. .rank-number {
  297. position: absolute;
  298. top: 20rpx;
  299. left: 20rpx;
  300. font-size: 48rpx;
  301. font-weight: bold;
  302. color: #FFFFFF;
  303. }
  304. .avatar-large {
  305. width: 120rpx;
  306. height: 120rpx;
  307. border-radius: 50%;
  308. background: rgba(255, 255, 255, 0.3);
  309. margin: 40rpx 0 20rpx;
  310. }
  311. .matchmaker-name {
  312. font-size: 32rpx;
  313. font-weight: bold;
  314. color: #FFFFFF;
  315. margin-bottom: 15rpx;
  316. }
  317. .success-count {
  318. font-size: 28rpx;
  319. color: #FFFFFF;
  320. margin-bottom: 30rpx;
  321. }
  322. .like-btn {
  323. padding: 12rpx 35rpx;
  324. background: rgba(255, 255, 255, 0.2);
  325. color: #FFFFFF;
  326. border-radius: 25rpx;
  327. font-size: 26rpx;
  328. font-weight: bold;
  329. border: 2rpx solid #FFFFFF;
  330. &.active {
  331. background: #E91E63;
  332. color: #FFFFFF;
  333. border-color: #E91E63;
  334. }
  335. }
  336. }
  337. }
  338. .ranking-list {
  339. flex: 1;
  340. padding: 0 20rpx 120rpx;
  341. .ranking-item {
  342. display: flex;
  343. align-items: center;
  344. background: #FFFFFF;
  345. border-radius: 20rpx;
  346. padding: 25rpx;
  347. margin-bottom: 20rpx;
  348. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  349. .rank-number-normal {
  350. width: 50rpx;
  351. height: 50rpx;
  352. display: flex;
  353. align-items: center;
  354. justify-content: center;
  355. font-size: 28rpx;
  356. font-weight: bold;
  357. color: #999;
  358. border-radius: 50%;
  359. background: #F0F0F0;
  360. margin-right: 20rpx;
  361. }
  362. .avatar-small {
  363. width: 80rpx;
  364. height: 80rpx;
  365. border-radius: 50%;
  366. background: #F0F0F0;
  367. margin-right: 20rpx;
  368. }
  369. .matchmaker-info {
  370. flex: 1;
  371. .matchmaker-name-normal {
  372. display: block;
  373. font-size: 32rpx;
  374. font-weight: bold;
  375. color: #333;
  376. margin-bottom: 8rpx;
  377. }
  378. .success-count-normal,
  379. .user-rating {
  380. display: block;
  381. font-size: 24rpx;
  382. color: #666;
  383. margin-bottom: 4rpx;
  384. }
  385. }
  386. .like-btn-small {
  387. padding: 10rpx 30rpx;
  388. background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
  389. color: #FFFFFF;
  390. border-radius: 25rpx;
  391. font-size: 26rpx;
  392. font-weight: bold;
  393. }
  394. }
  395. .loading-tip,
  396. .empty-tip {
  397. text-align: center;
  398. padding: 40rpx;
  399. font-size: 28rpx;
  400. color: #999;
  401. }
  402. }
  403. /* 底部导航 */
  404. .tabbar {
  405. position: fixed;
  406. bottom: 0;
  407. left: 0;
  408. right: 0;
  409. height: 100rpx;
  410. background: #FFFFFF;
  411. border-top: 1rpx solid #F0F0F0;
  412. display: flex;
  413. justify-content: space-around;
  414. align-items: center;
  415. padding-bottom: env(safe-area-inset-bottom);
  416. .tabbar-item {
  417. display: flex;
  418. flex-direction: column;
  419. align-items: center;
  420. gap: 8rpx;
  421. padding: 10rpx 0;
  422. .tabbar-icon {
  423. width: 44rpx;
  424. height: 44rpx;
  425. background-size: contain;
  426. background-repeat: no-repeat;
  427. background-position: center;
  428. position: relative;
  429. .badge {
  430. position: absolute;
  431. top: -8rpx;
  432. right: -8rpx;
  433. background: #FF4444;
  434. color: #FFFFFF;
  435. font-size: 20rpx;
  436. font-weight: bold;
  437. width: 32rpx;
  438. height: 32rpx;
  439. display: flex;
  440. align-items: center;
  441. justify-content: center;
  442. border-radius: 16rpx;
  443. }
  444. }
  445. .tabbar-text {
  446. font-size: 20rpx;
  447. color: #999;
  448. }
  449. &.active .tabbar-text {
  450. color: #9C27B0;
  451. font-weight: bold;
  452. }
  453. &.home .tabbar-icon {
  454. background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>');
  455. }
  456. &.home.active .tabbar-icon {
  457. background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>');
  458. }
  459. &.resources .tabbar-icon {
  460. background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/></svg>');
  461. }
  462. &.resources.active .tabbar-icon {
  463. background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/></svg>');
  464. }
  465. &.trophy .tabbar-icon {
  466. background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M19 5h-2V3H7v2H5c-1.1 0-2 .9-2 2v1c0 2.55 1.92 4.63 4.39 4.94.63 1.5 1.98 2.63 3.61 2.96V19H7v2h10v-2h-4v-3.1c1.63-.33 2.98-1.46 3.61-2.96C19.08 12.63 21 10.55 21 8V7c0-1.1-.9-2-2-2zM5 8V7h2v3.82C5.84 10.4 5 9.3 5 8zm14 0c0 1.3-.84 2.4-2 2.82V7h2v1z"/></svg>');
  467. }
  468. &.trophy.active .tabbar-icon {
  469. background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M19 5h-2V3H7v2H5c-1.1 0-2 .9-2 2v1c0 2.55 1.92 4.63 4.39 4.94.63 1.5 1.98 2.63 3.61 2.96V19H7v2h10v-2h-4v-3.1c1.63-.33 2.98-1.46 3.61-2.96C19.08 12.63 21 10.55 21 8V7c0-1.1-.9-2-2-2zM5 8V7h2v3.82C5.84 10.4 5 9.3 5 8zm14 0c0 1.3-.84 2.4-2 2.82V7h2v1z"/></svg>');
  470. }
  471. &.message .tabbar-icon {
  472. background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/></svg>');
  473. }
  474. &.message.active .tabbar-icon {
  475. background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/></svg>');
  476. }
  477. &.mine .tabbar-icon {
  478. background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
  479. }
  480. &.mine.active .tabbar-icon {
  481. background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
  482. }
  483. }
  484. }
  485. </style>