liked-by-me.vue 5.8 KB

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