木邻有你前端代码仓库
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.

186 lines
3.5 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="page">
  3. <!-- 收藏列表 -->
  4. <view class="content" v-if="favoritesList.length > 0">
  5. <view v class="list">
  6. <view v-for="item in favoritesList" :key="item.id" class="record-item" @click="viewGoodsDetail(item)">
  7. <image class="record-image" :src="item.communityGoods.image" mode="aspectFit"></image>
  8. <view class="record-content">
  9. <view class="record-info">
  10. <view class="title-row">
  11. <text class="record-title">{{ item.communityGoods.title }}</text>
  12. </view>
  13. <view class="record-points">
  14. <uv-icon name="integral" size="16" color="#218cdd"></uv-icon>
  15. <text class="points-text">{{ item.communityGoods.price }}积分</text>
  16. </view>
  17. <view class="record-time">
  18. <uv-icon name="heart-fill" size="14" color="#ff6b6b"></uv-icon>
  19. <text class="time-text">收藏时间{{ item.createTime }}</text>
  20. </view>
  21. </view>
  22. <view class="record-action">
  23. <uv-button
  24. type="primary"
  25. size="small"
  26. text="查看详情"
  27. shape="circle"
  28. @click.stop="viewGoodsDetail(item)"
  29. ></uv-button>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view v-else class="empty">
  36. <uv-empty icon="/static/暂无收藏.png" text="暂无收藏商品"></uv-empty>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. favoritesList: [],
  45. pageNo: 1,
  46. pageSize: 10
  47. }
  48. },
  49. methods: {
  50. // 查看商品详情
  51. viewGoodsDetail(item) {
  52. uni.navigateTo({
  53. url: `/subPages/shop/goodsDetail?id=${item.goodsId}`
  54. })
  55. },
  56. // 获取收藏的商品列表
  57. async getGoodsList() {
  58. const res = await this.$api.shop.queryGoodsCollectionList({
  59. pageNo: this.pageNo,
  60. pageSize: this.pageSize
  61. })
  62. if (res.result.records.length) {
  63. this.favoritesList.push(...res.result.records)
  64. this.pageNo++
  65. }else {
  66. uni.showToast({
  67. title: '暂无数据',
  68. icon: 'none'
  69. })
  70. }
  71. },
  72. initData() {
  73. this.favoritesList = []
  74. this.pageNo = 1
  75. this.pageSize = 10
  76. }
  77. },
  78. async onShow() {
  79. this.initData()
  80. // 刷新收藏列表
  81. await this.getGoodsList()
  82. },
  83. onReachBottom() {
  84. this.getGoodsList()
  85. },
  86. async onPullDownRefresh() {
  87. this.initData()
  88. await this.getGoodsList()
  89. uni.stopPullDownRefresh()
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. .page {
  95. background-color: #f5f5f5;
  96. min-height: 100vh;
  97. }
  98. .content {
  99. padding: 0;
  100. }
  101. .list {
  102. padding: 20rpx;
  103. }
  104. .record-item {
  105. display: flex;
  106. align-items: flex-start;
  107. margin-bottom: 30rpx;
  108. background: #fff;
  109. border-radius: 12rpx;
  110. padding: 20rpx;
  111. }
  112. .record-image {
  113. width: 215rpx;
  114. height: 215rpx;
  115. border-radius: 8rpx;
  116. margin-right: 20rpx;
  117. flex-shrink: 0;
  118. }
  119. .record-content {
  120. flex: 1;
  121. display: flex;
  122. flex-direction: column;
  123. }
  124. .record-info {
  125. display: flex;
  126. flex-direction: column;
  127. margin-bottom: 20rpx;
  128. }
  129. .title-row {
  130. margin-bottom: 10rpx;
  131. }
  132. .record-title {
  133. font-size: 22rpx;
  134. color: #000;
  135. line-height: 1.4;
  136. display: -webkit-box;
  137. -webkit-box-orient: vertical;
  138. -webkit-line-clamp: 2;
  139. overflow: hidden;
  140. }
  141. .record-points {
  142. display: flex;
  143. align-items: center;
  144. margin-bottom: 8rpx;
  145. }
  146. .points-text {
  147. font-size: 26rpx;
  148. color: #218cdd;
  149. font-weight: bold;
  150. margin-left: 6rpx;
  151. }
  152. .record-time {
  153. display: flex;
  154. align-items: center;
  155. }
  156. .time-text {
  157. font-size: 22rpx;
  158. color: #999;
  159. margin-left: 6rpx;
  160. }
  161. .record-action {
  162. display: flex;
  163. justify-content: flex-end;
  164. border-top: 1rpx solid #f0f0f0;
  165. }
  166. .empty {
  167. padding-top: 200rpx;
  168. }
  169. </style>