visited-by-me.vue 6.4 KB

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