liked-me.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="like-page">
  3. <!-- 数据加载状态 -->
  4. <view class="loading-container" v-if="loading">
  5. <uni-loading type="circle" color="#E91E63"></uni-loading>
  6. <text class="loading-text">加载中...</text>
  7. </view>
  8. <!-- 空数据状态 -->
  9. <view class="empty-container" v-else-if="users.length === 0">
  10. <text class="empty-icon">😊</text>
  11. <text class="empty-text">暂无用户喜欢您</text>
  12. <view class="empty-action">
  13. <button class="action-btn" @click="goRecommend">完善资料增加曝光</button>
  14. </view>
  15. </view>
  16. <!-- 用户列表 -->
  17. <scroll-view class="user-list" scroll-y="true">
  18. <view class="user-item" v-for="user in users" :key="user.userId" @click="goUserDetail(user.userId)">
  19. <image class="user-avatar" :src="user.avatar" mode="aspectFill"></image>
  20. <view class="user-info">
  21. <view class="user-basic">
  22. <text class="user-nickname">{{ user.nickname }}</text>
  23. <text class="user-age">{{ user.age }}岁</text>
  24. </view>
  25. <view class="user-details">
  26. <text class="detail-item" v-if="user.height">{{ user.height }}cm</text>
  27. <text class="detail-item" v-if="user.weight">{{ user.weight }}kg</text>
  28. <text class="detail-item" v-if="user.educationText">{{ user.educationText }}</text>
  29. <text class="detail-item" v-if="user.salaryText">{{ user.salaryText }}</text>
  30. </view>
  31. <view class="user-location" v-if="user.location">
  32. <text class="location-text">{{ user.location }}</text>
  33. </view>
  34. </view>
  35. <view class="like-status">
  36. <text class="like-icon">💖</text>
  37. </view>
  38. </view>
  39. </scroll-view>
  40. </view>
  41. </template>
  42. <script>
  43. import api from '@/utils/api.js'
  44. export default {
  45. data() {
  46. return {
  47. users: [],
  48. loading: true,
  49. pageNum: 1,
  50. pageSize: 20,
  51. hasMore: true
  52. }
  53. },
  54. onLoad() {
  55. this.loadUsers()
  56. },
  57. methods: {
  58. // 加载喜欢我的用户列表
  59. async loadUsers() {
  60. try {
  61. this.loading = true
  62. // 不调用真实API,显示空数据
  63. this.users = []
  64. } catch (error) {
  65. console.error('加载喜欢我的用户失败:', error)
  66. uni.showToast({
  67. title: '加载失败,请重试',
  68. icon: 'none'
  69. })
  70. } finally {
  71. this.loading = false
  72. }
  73. },
  74. // 跳转到用户详情页
  75. goUserDetail(userId) {
  76. uni.navigateTo({
  77. url: `/pages/recommend/index?userId=${userId}`,
  78. fail: (err) => {
  79. console.error('跳转用户详情失败:', err)
  80. uni.showToast({
  81. title: '页面不存在',
  82. icon: 'none'
  83. })
  84. }
  85. })
  86. },
  87. // 跳转到推荐页面
  88. goRecommend() {
  89. uni.navigateTo({
  90. url: '/pages/profile/index'
  91. })
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .like-page {
  98. min-height: 100vh;
  99. background-color: #F5F5F5;
  100. padding: 0 5rpx;
  101. box-sizing: border-box;
  102. overflow-x: hidden;
  103. }
  104. .loading-container {
  105. display: flex;
  106. flex-direction: column;
  107. align-items: center;
  108. justify-content: center;
  109. padding: 100rpx 0;
  110. .loading-text {
  111. margin-top: 20rpx;
  112. font-size: 28rpx;
  113. color: #999999;
  114. }
  115. }
  116. .empty-container {
  117. display: flex;
  118. flex-direction: column;
  119. align-items: center;
  120. justify-content: center;
  121. padding: 150rpx 0;
  122. .empty-icon {
  123. font-size: 120rpx;
  124. margin-bottom: 30rpx;
  125. }
  126. .empty-text {
  127. font-size: 32rpx;
  128. color: #999999;
  129. margin-bottom: 40rpx;
  130. }
  131. .action-btn {
  132. background: linear-gradient(135deg, #FF6B9D 0%, #E91E63 100%);
  133. color: #FFFFFF;
  134. border: none;
  135. padding: 18rpx 70rpx;
  136. border-radius: 45rpx;
  137. font-size: 28rpx;
  138. font-weight: 600;
  139. box-shadow: 0 6rpx 20rpx rgba(233, 30, 99, 0.3);
  140. transition: all 0.3s ease;
  141. letter-spacing: 1rpx;
  142. &:active {
  143. transform: translateY(2rpx);
  144. box-shadow: 0 3rpx 12rpx rgba(233, 30, 99, 0.4);
  145. background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
  146. }
  147. }
  148. }
  149. .user-list {
  150. padding: 20rpx;
  151. height: calc(100vh - 88rpx);
  152. }
  153. .user-item {
  154. display: flex;
  155. align-items: center;
  156. background-color: #FFFFFF;
  157. border-radius: 20rpx;
  158. padding: 20rpx;
  159. margin-bottom: 20rpx;
  160. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  161. transition: all 0.3s ease;
  162. &:active {
  163. transform: translateY(2rpx);
  164. box-shadow: 0 1rpx 5rpx rgba(0, 0, 0, 0.05);
  165. }
  166. .user-avatar {
  167. width: 120rpx;
  168. height: 120rpx;
  169. border-radius: 50%;
  170. margin-right: 20rpx;
  171. border: 4rpx solid #FFF9F9;
  172. box-shadow: 0 4rpx 15rpx rgba(233, 30, 99, 0.2);
  173. }
  174. .user-info {
  175. flex: 1;
  176. .user-basic {
  177. display: flex;
  178. align-items: center;
  179. margin-bottom: 10rpx;
  180. .user-nickname {
  181. font-size: 32rpx;
  182. font-weight: bold;
  183. color: #333333;
  184. margin-right: 15rpx;
  185. }
  186. .user-age {
  187. font-size: 28rpx;
  188. color: #666666;
  189. }
  190. }
  191. .user-details {
  192. display: flex;
  193. flex-wrap: wrap;
  194. gap: 15rpx;
  195. margin-bottom: 10rpx;
  196. .detail-item {
  197. font-size: 24rpx;
  198. color: #999999;
  199. background-color: #F5F5F5;
  200. padding: 6rpx 15rpx;
  201. border-radius: 15rpx;
  202. }
  203. }
  204. .user-location {
  205. .location-text {
  206. font-size: 24rpx;
  207. color: #999999;
  208. }
  209. }
  210. }
  211. .like-status {
  212. .like-icon {
  213. font-size: 40rpx;
  214. color: #E91E63;
  215. }
  216. }
  217. }
  218. </style>