visited-by-me.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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="browseHistory.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="history-list" scroll-y="true">
  18. <view class="history-item" v-for="item in browseHistory" :key="item.id" @click="goUserDetail(item.userId)">
  19. <image class="user-avatar" :src="item.avatar" mode="aspectFill"></image>
  20. <view class="user-info">
  21. <view class="user-basic">
  22. <text class="user-nickname">{{ item.nickname }}</text>
  23. <text class="user-age">{{ item.age }}岁</text>
  24. </view>
  25. <view class="user-details">
  26. <text class="detail-item" v-if="item.height">{{ item.height }}cm</text>
  27. <text class="detail-item" v-if="item.weight">{{ item.weight }}kg</text>
  28. <text class="detail-item" v-if="item.educationText">{{ item.educationText }}</text>
  29. <text class="detail-item" v-if="item.salaryText">{{ item.salaryText }}</text>
  30. </view>
  31. <view class="browse-time">
  32. <text class="time-text">{{ formatTime(item.viewTime) }}</text>
  33. </view>
  34. </view>
  35. <view class="browse-status">
  36. <text class="browse-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. browseHistory: [],
  48. loading: true,
  49. pageNum: 1,
  50. pageSize: 20,
  51. hasMore: true
  52. }
  53. },
  54. onLoad() {
  55. this.loadBrowseHistory()
  56. },
  57. methods: {
  58. // 加载浏览记录
  59. async loadBrowseHistory() {
  60. try {
  61. this.loading = true
  62. // 不调用真实API,显示空数据
  63. this.browseHistory = []
  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. formatTime(time) {
  76. if (!time) return ''
  77. const now = new Date()
  78. const viewTime = new Date(time)
  79. const diff = now - viewTime
  80. const minutes = Math.floor(diff / (1000 * 60))
  81. const hours = Math.floor(diff / (1000 * 60 * 60))
  82. const days = Math.floor(diff / (1000 * 60 * 60 * 24))
  83. if (minutes < 60) {
  84. return `${minutes}分钟前`
  85. } else if (hours < 24) {
  86. return `${hours}小时前`
  87. } else if (days < 30) {
  88. return `${days}天前`
  89. } else {
  90. return viewTime.toLocaleDateString()
  91. }
  92. },
  93. // 跳转到用户详情页
  94. goUserDetail(userId) {
  95. uni.navigateTo({
  96. url: `/pages/recommend/index?userId=${userId}`,
  97. fail: (err) => {
  98. console.error('跳转用户详情失败:', err)
  99. uni.showToast({
  100. title: '页面不存在',
  101. icon: 'none'
  102. })
  103. }
  104. })
  105. },
  106. // 跳转到推荐页面
  107. goRecommend() {
  108. uni.navigateTo({
  109. url: '/pages/recommend/index'
  110. })
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .like-page {
  117. min-height: 100vh;
  118. background-color: #F5F5F5;
  119. padding: 0 5rpx;
  120. box-sizing: border-box;
  121. overflow-x: hidden;
  122. }
  123. .loading-container {
  124. display: flex;
  125. flex-direction: column;
  126. align-items: center;
  127. justify-content: center;
  128. padding: 100rpx 0;
  129. .loading-text {
  130. margin-top: 20rpx;
  131. font-size: 28rpx;
  132. color: #999999;
  133. }
  134. }
  135. .empty-container {
  136. display: flex;
  137. flex-direction: column;
  138. align-items: center;
  139. justify-content: center;
  140. padding: 150rpx 0;
  141. .empty-icon {
  142. font-size: 120rpx;
  143. margin-bottom: 30rpx;
  144. }
  145. .empty-text {
  146. font-size: 32rpx;
  147. color: #999999;
  148. margin-bottom: 40rpx;
  149. }
  150. .action-btn {
  151. background: linear-gradient(135deg, #FF6B9D 0%, #E91E63 100%);
  152. color: #FFFFFF;
  153. border: none;
  154. padding: 18rpx 70rpx;
  155. border-radius: 45rpx;
  156. font-size: 28rpx;
  157. font-weight: 600;
  158. box-shadow: 0 6rpx 20rpx rgba(233, 30, 99, 0.3);
  159. transition: all 0.3s ease;
  160. letter-spacing: 1rpx;
  161. &:active {
  162. transform: translateY(2rpx);
  163. box-shadow: 0 3rpx 12rpx rgba(233, 30, 99, 0.4);
  164. background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
  165. }
  166. }
  167. }
  168. .history-list {
  169. padding: 20rpx;
  170. height: calc(100vh - 88rpx);
  171. }
  172. .history-item {
  173. display: flex;
  174. align-items: center;
  175. background-color: #FFFFFF;
  176. border-radius: 20rpx;
  177. padding: 20rpx;
  178. margin-bottom: 20rpx;
  179. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  180. transition: all 0.3s ease;
  181. &:active {
  182. transform: translateY(2rpx);
  183. box-shadow: 0 1rpx 5rpx rgba(0, 0, 0, 0.05);
  184. }
  185. .user-avatar {
  186. width: 120rpx;
  187. height: 120rpx;
  188. border-radius: 50%;
  189. margin-right: 20rpx;
  190. border: 4rpx solid #FFF9F9;
  191. box-shadow: 0 4rpx 15rpx rgba(233, 30, 99, 0.2);
  192. }
  193. .user-info {
  194. flex: 1;
  195. .user-basic {
  196. display: flex;
  197. align-items: center;
  198. margin-bottom: 10rpx;
  199. .user-nickname {
  200. font-size: 32rpx;
  201. font-weight: bold;
  202. color: #333333;
  203. margin-right: 15rpx;
  204. }
  205. .user-age {
  206. font-size: 28rpx;
  207. color: #666666;
  208. }
  209. }
  210. .user-details {
  211. display: flex;
  212. flex-wrap: wrap;
  213. gap: 15rpx;
  214. margin-bottom: 10rpx;
  215. .detail-item {
  216. font-size: 24rpx;
  217. color: #999999;
  218. background-color: #F5F5F5;
  219. padding: 6rpx 15rpx;
  220. border-radius: 15rpx;
  221. }
  222. }
  223. .browse-time {
  224. .time-text {
  225. font-size: 22rpx;
  226. color: #CCCCCC;
  227. }
  228. }
  229. }
  230. .browse-status {
  231. .browse-icon {
  232. font-size: 40rpx;
  233. color: #E91E63;
  234. }
  235. }
  236. }
  237. </style>