ranking.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  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 class="badge">3</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. onLoad() {
  112. // 加载排行榜数据
  113. this.loadRankingData()
  114. },
  115. methods: {
  116. // 返回上一页
  117. goBack() {
  118. uni.navigateBack()
  119. },
  120. // 加载排行榜数据
  121. async loadRankingData() {
  122. this.loading = true
  123. try {
  124. const res = await api.matchmaker.getRankingData({ limit: 20 })
  125. if (res && Array.isArray(res)) {
  126. this.rankingList = res
  127. } else if (res && res.data && Array.isArray(res.data)) {
  128. this.rankingList = res.data
  129. }
  130. console.log('排行榜数据:', this.rankingList)
  131. } catch (e) {
  132. console.error('加载排行榜数据失败:', e)
  133. uni.showToast({
  134. title: '加载失败',
  135. icon: 'none'
  136. })
  137. } finally {
  138. this.loading = false
  139. }
  140. },
  141. // 点赞
  142. handleLike(matchmaker) {
  143. // 实现点赞功能
  144. console.log('点赞红娘:', matchmaker.realName)
  145. uni.showToast({
  146. title: '点赞成功',
  147. icon: 'success'
  148. })
  149. },
  150. // 导航到工作台
  151. navigateToWorkbench() {
  152. uni.redirectTo({
  153. url: '/pages/matchmaker-workbench/index'
  154. })
  155. },
  156. // 导航到我的资源
  157. navigateToMyResources() {
  158. uni.redirectTo({
  159. url: '/pages/matchmaker-workbench/my-resources'
  160. })
  161. },
  162. // 导航到排行榜
  163. navigateToRanking() {
  164. // 已在排行榜页面,无需跳转
  165. },
  166. // 导航到消息
  167. navigateToMessage() {
  168. uni.redirectTo({
  169. url: '/pages/matchmaker-workbench/message'
  170. })
  171. },
  172. // 导航到我的
  173. navigateToMine() {
  174. uni.redirectTo({
  175. url: '/pages/matchmaker-workbench/mine'
  176. })
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. .matchmaker-ranking {
  183. min-height: 100vh;
  184. background: linear-gradient(135deg, #FFF3F6 0%, #FFE4E8 100%);
  185. display: flex;
  186. flex-direction: column;
  187. }
  188. /* 顶部导航栏 */
  189. .header {
  190. display: flex;
  191. align-items: center;
  192. justify-content: space-between;
  193. padding: 25rpx 30rpx;
  194. padding-top: calc(25rpx + env(safe-area-inset-top));
  195. background: #FFF9F9;
  196. border-bottom: 1rpx solid #F0F0F0;
  197. .back-btn {
  198. width: 70rpx;
  199. height: 70rpx;
  200. display: flex;
  201. align-items: center;
  202. justify-content: center;
  203. background: rgba(240, 240, 240, 0.5);
  204. border-radius: 50%;
  205. 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>');
  206. background-size: 40rpx 40rpx;
  207. background-repeat: no-repeat;
  208. background-position: center;
  209. }
  210. .header-title {
  211. font-size: 38rpx;
  212. font-weight: bold;
  213. color: #333;
  214. }
  215. .placeholder {
  216. width: 70rpx;
  217. }
  218. }
  219. /* 更新提示 */
  220. .update-info {
  221. background: #FFF3E0;
  222. padding: 15rpx;
  223. text-align: center;
  224. .update-text {
  225. font-size: 24rpx;
  226. color: #FF9800;
  227. }
  228. }
  229. /* 本周最佳榜标题 */
  230. .section-title-wrapper {
  231. text-align: center;
  232. margin: 30rpx 0 15rpx;
  233. .section-title {
  234. display: inline-block;
  235. font-size: 36rpx;
  236. font-weight: bold;
  237. color: #E91E63;
  238. line-height: 1.4;
  239. .title-icon {
  240. font-size: 40rpx;
  241. margin: 0 10rpx;
  242. }
  243. }
  244. }
  245. /* 榜说明 */
  246. .ranking-description {
  247. padding: 0 30rpx 25rpx;
  248. .description-text {
  249. display: block;
  250. font-size: 26rpx;
  251. color: #666;
  252. line-height: 1.5;
  253. text-align: center;
  254. }
  255. }
  256. /* 前三名展示 */
  257. .top-three-container {
  258. display: flex;
  259. justify-content: space-around;
  260. align-items: flex-end;
  261. padding: 0 20rpx 40rpx;
  262. background: #FFF9F9;
  263. border-radius: 20rpx;
  264. margin: 0 20rpx 20rpx;
  265. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  266. .top-three-item {
  267. display: flex;
  268. flex-direction: column;
  269. align-items: center;
  270. padding: 20rpx;
  271. border-radius: 20rpx;
  272. position: relative;
  273. &.first {
  274. background: linear-gradient(135deg, #FFD700 0%, #FFA000 100%);
  275. width: 280rpx;
  276. height: 400rpx;
  277. order: 2;
  278. margin-bottom: 30rpx;
  279. }
  280. &.second {
  281. background: linear-gradient(135deg, #C0C0C0 0%, #A8A8A8 100%);
  282. width: 240rpx;
  283. height: 350rpx;
  284. order: 1;
  285. }
  286. &.third {
  287. background: linear-gradient(135deg, #CD7F32 0%, #B87333 100%);
  288. width: 240rpx;
  289. height: 350rpx;
  290. order: 3;
  291. }
  292. .rank-number {
  293. position: absolute;
  294. top: 20rpx;
  295. left: 20rpx;
  296. font-size: 48rpx;
  297. font-weight: bold;
  298. color: #FFFFFF;
  299. }
  300. .avatar-large {
  301. width: 120rpx;
  302. height: 120rpx;
  303. border-radius: 50%;
  304. background: rgba(255, 255, 255, 0.3);
  305. margin: 40rpx 0 20rpx;
  306. }
  307. .matchmaker-name {
  308. font-size: 32rpx;
  309. font-weight: bold;
  310. color: #FFFFFF;
  311. margin-bottom: 15rpx;
  312. }
  313. .success-count {
  314. font-size: 28rpx;
  315. color: #FFFFFF;
  316. margin-bottom: 30rpx;
  317. }
  318. .like-btn {
  319. padding: 12rpx 35rpx;
  320. background: rgba(255, 255, 255, 0.2);
  321. color: #FFFFFF;
  322. border-radius: 25rpx;
  323. font-size: 26rpx;
  324. font-weight: bold;
  325. border: 2rpx solid #FFFFFF;
  326. &.active {
  327. background: #E91E63;
  328. color: #FFFFFF;
  329. border-color: #E91E63;
  330. }
  331. }
  332. }
  333. }
  334. .ranking-list {
  335. flex: 1;
  336. padding: 0 20rpx 120rpx;
  337. .ranking-item {
  338. display: flex;
  339. align-items: center;
  340. background: #FFFFFF;
  341. border-radius: 20rpx;
  342. padding: 25rpx;
  343. margin-bottom: 20rpx;
  344. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  345. .rank-number-normal {
  346. width: 50rpx;
  347. height: 50rpx;
  348. display: flex;
  349. align-items: center;
  350. justify-content: center;
  351. font-size: 28rpx;
  352. font-weight: bold;
  353. color: #999;
  354. border-radius: 50%;
  355. background: #F0F0F0;
  356. margin-right: 20rpx;
  357. }
  358. .avatar-small {
  359. width: 80rpx;
  360. height: 80rpx;
  361. border-radius: 50%;
  362. background: #F0F0F0;
  363. margin-right: 20rpx;
  364. }
  365. .matchmaker-info {
  366. flex: 1;
  367. .matchmaker-name-normal {
  368. display: block;
  369. font-size: 32rpx;
  370. font-weight: bold;
  371. color: #333;
  372. margin-bottom: 8rpx;
  373. }
  374. .success-count-normal,
  375. .user-rating {
  376. display: block;
  377. font-size: 24rpx;
  378. color: #666;
  379. margin-bottom: 4rpx;
  380. }
  381. }
  382. .like-btn-small {
  383. padding: 10rpx 30rpx;
  384. background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
  385. color: #FFFFFF;
  386. border-radius: 25rpx;
  387. font-size: 26rpx;
  388. font-weight: bold;
  389. }
  390. }
  391. .loading-tip,
  392. .empty-tip {
  393. text-align: center;
  394. padding: 40rpx;
  395. font-size: 28rpx;
  396. color: #999;
  397. }
  398. }
  399. /* 底部导航 */
  400. .tabbar {
  401. position: fixed;
  402. bottom: 0;
  403. left: 0;
  404. right: 0;
  405. height: 100rpx;
  406. background: #FFFFFF;
  407. border-top: 1rpx solid #F0F0F0;
  408. display: flex;
  409. justify-content: space-around;
  410. align-items: center;
  411. padding-bottom: env(safe-area-inset-bottom);
  412. .tabbar-item {
  413. display: flex;
  414. flex-direction: column;
  415. align-items: center;
  416. gap: 8rpx;
  417. padding: 10rpx 0;
  418. .tabbar-icon {
  419. width: 44rpx;
  420. height: 44rpx;
  421. background-size: contain;
  422. background-repeat: no-repeat;
  423. background-position: center;
  424. position: relative;
  425. .badge {
  426. position: absolute;
  427. top: -8rpx;
  428. right: -8rpx;
  429. background: #FF4444;
  430. color: #FFFFFF;
  431. font-size: 20rpx;
  432. font-weight: bold;
  433. width: 32rpx;
  434. height: 32rpx;
  435. display: flex;
  436. align-items: center;
  437. justify-content: center;
  438. border-radius: 16rpx;
  439. }
  440. }
  441. .tabbar-text {
  442. font-size: 20rpx;
  443. color: #999;
  444. }
  445. &.active .tabbar-text {
  446. color: #9C27B0;
  447. font-weight: bold;
  448. }
  449. &.home .tabbar-icon {
  450. 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>');
  451. }
  452. &.home.active .tabbar-icon {
  453. 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>');
  454. }
  455. &.resources .tabbar-icon {
  456. 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>');
  457. }
  458. &.resources.active .tabbar-icon {
  459. 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>');
  460. }
  461. &.trophy .tabbar-icon {
  462. 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>');
  463. }
  464. &.trophy.active .tabbar-icon {
  465. 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>');
  466. }
  467. &.message .tabbar-icon {
  468. 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>');
  469. }
  470. &.message.active .tabbar-icon {
  471. 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>');
  472. }
  473. &.mine .tabbar-icon {
  474. 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>');
  475. }
  476. &.mine.active .tabbar-icon {
  477. 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>');
  478. }
  479. }
  480. }
  481. </style>