瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

254 lines
5.4 KiB

  1. <template>
  2. <view class="browse-history">
  3. <navbar leftClick @leftClick="$utils.navigateBack" title="浏览历史" />
  4. <!-- 筛选标签 -->
  5. <view class="filter-tabs">
  6. <uv-tabs
  7. :list="filterTabs"
  8. :activeStyle="{color: '#000', fontWeight: 900, fontSize: '32rpx'}"
  9. lineColor="#5baaff"
  10. lineHeight="6rpx"
  11. lineWidth="50rpx"
  12. keyName="title"
  13. @click="onFilterChange"
  14. />
  15. </view>
  16. <!-- 浏览记录列表 -->
  17. <view class="history-list" v-if="historyList.length > 0">
  18. <view class="history-item"
  19. v-for="(item, index) in historyList"
  20. :key="index"
  21. @click="goToDetail(item)">
  22. <view class="item-content">
  23. <!-- 动态内容 -->
  24. <view class="dynamic-info">
  25. <view class="title" v-html="$utils.stringFormatHtml(item.title)"></view>
  26. <view class="meta-info">
  27. <text class="author">{{ item.userName }}</text>
  28. <text class="time">{{ $dayjs(item.createTime).format('MM-DD HH:mm') }}</text>
  29. </view>
  30. </view>
  31. <!-- 缩略图 -->
  32. <view class="thumbnail" v-if="item.image">
  33. <image :src="item.image.split(',')[0]" mode="aspectFill" />
  34. </view>
  35. </view>
  36. <!-- 浏览时间 -->
  37. <view class="browse-time">
  38. 浏览于 {{ $dayjs(item.browseTime).format('YYYY-MM-DD HH:mm') }}
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 空状态 -->
  43. <view class="empty-state" v-else-if="!loading">
  44. <uv-empty
  45. text="暂无浏览记录"
  46. icon="history"
  47. iconSize="120"
  48. />
  49. </view>
  50. <!-- 加载更多 -->
  51. <uv-load-more
  52. :status="loadStatus"
  53. @loadmore="loadMore"
  54. v-if="historyList.length > 0"
  55. />
  56. </view>
  57. </template>
  58. <script>
  59. import navbar from '@/components/base/navbar.vue'
  60. import mixinsList from '@/mixins/loadList.js'
  61. import { BROWSE_RECORD_CATEGORY } from '@/config/browseConfig.js'
  62. export default {
  63. mixins: [mixinsList],
  64. components: {
  65. navbar
  66. },
  67. data() {
  68. return {
  69. mixinsListApi: 'getBrowseRecordPage',
  70. filterTabs: [
  71. { id: '', title: '全部' },
  72. { id: 0, title: '动态' },
  73. { id: 1, title: '租房' },
  74. { id: 2, title: '工作' },
  75. { id: 5, title: '活动' },
  76. { id: 8, title: '文章' }
  77. ],
  78. currentFilter: '',
  79. historyList: [],
  80. loading: false,
  81. loadStatus: 'loadmore'
  82. }
  83. },
  84. onLoad() {
  85. this.loadHistoryData()
  86. },
  87. onPullDownRefresh() {
  88. this.refreshData()
  89. },
  90. onReachBottom() {
  91. this.loadMore()
  92. },
  93. methods: {
  94. // 筛选类型改变
  95. onFilterChange(item) {
  96. this.currentFilter = item.id
  97. this.queryParams.type = item.id === '' ? undefined : item.id
  98. this.refreshList()
  99. },
  100. // 加载浏览历史数据
  101. loadHistoryData() {
  102. this.loading = true
  103. this.$api('getBrowseRecordPage', {
  104. ...this.queryParams,
  105. category: BROWSE_RECORD_CATEGORY.BROWSE // 只获取浏览记录
  106. }, res => {
  107. this.loading = false
  108. uni.stopPullDownRefresh()
  109. if (res.code === 200) {
  110. const newData = res.result.records || res.result || []
  111. if (this.queryParams.pageNum === 1) {
  112. this.historyList = newData
  113. } else {
  114. this.historyList = [...this.historyList, ...newData]
  115. }
  116. // 更新加载状态
  117. if (newData.length < this.queryParams.pageSize) {
  118. this.loadStatus = 'nomore'
  119. } else {
  120. this.loadStatus = 'loadmore'
  121. }
  122. }
  123. })
  124. },
  125. // 刷新数据
  126. refreshData() {
  127. this.queryParams.pageNum = 1
  128. this.loadStatus = 'loadmore'
  129. this.loadHistoryData()
  130. },
  131. // 加载更多
  132. loadMore() {
  133. if (this.loadStatus === 'loadmore') {
  134. this.queryParams.pageNum++
  135. this.loadStatus = 'loading'
  136. this.loadHistoryData()
  137. }
  138. },
  139. // 跳转到详情页
  140. goToDetail(item) {
  141. const typeRouteMap = {
  142. 0: '/pages_order/post/postDetail',
  143. 1: '/pages_order/renting/rentingDetail',
  144. 2: '/pages_order/work/workDetail',
  145. 5: '/pages_order/activity/activityDetail',
  146. 8: '/pages_order/article/articleDetail'
  147. }
  148. const route = typeRouteMap[item.type] || '/pages_order/post/postDetail'
  149. uni.navigateTo({
  150. url: `${route}?id=${item.orderId}`
  151. })
  152. }
  153. }
  154. }
  155. </script>
  156. <style scoped lang="scss">
  157. .browse-history {
  158. background-color: #f5f5f5;
  159. min-height: 100vh;
  160. }
  161. .filter-tabs {
  162. background-color: #fff;
  163. padding: 20rpx 0;
  164. margin-bottom: 20rpx;
  165. }
  166. .history-list {
  167. padding: 0 20rpx;
  168. }
  169. .history-item {
  170. background-color: #fff;
  171. border-radius: 20rpx;
  172. padding: 30rpx;
  173. margin-bottom: 20rpx;
  174. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  175. .item-content {
  176. display: flex;
  177. align-items: flex-start;
  178. .dynamic-info {
  179. flex: 1;
  180. margin-right: 20rpx;
  181. .title {
  182. font-size: 32rpx;
  183. color: #333;
  184. line-height: 1.5;
  185. margin-bottom: 15rpx;
  186. display: -webkit-box;
  187. -webkit-box-orient: vertical;
  188. -webkit-line-clamp: 2;
  189. overflow: hidden;
  190. text-overflow: ellipsis;
  191. }
  192. .meta-info {
  193. display: flex;
  194. align-items: center;
  195. font-size: 26rpx;
  196. color: #999;
  197. .author {
  198. margin-right: 20rpx;
  199. }
  200. }
  201. }
  202. .thumbnail {
  203. width: 120rpx;
  204. height: 120rpx;
  205. border-radius: 12rpx;
  206. overflow: hidden;
  207. flex-shrink: 0;
  208. image {
  209. width: 100%;
  210. height: 100%;
  211. }
  212. }
  213. }
  214. .browse-time {
  215. margin-top: 20rpx;
  216. font-size: 24rpx;
  217. color: #999;
  218. text-align: right;
  219. }
  220. }
  221. .empty-state {
  222. padding: 100rpx 0;
  223. text-align: center;
  224. }
  225. </style>