国外MOSE官网
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.

185 lines
3.3 KiB

2 days ago
13 hours ago
2 days ago
13 hours ago
2 days ago
13 hours ago
2 days ago
13 hours ago
1 hour ago
2 days ago
13 hours ago
1 hour ago
2 days ago
  1. <template>
  2. <view class="page">
  3. <!-- 收藏列表 -->
  4. <view class="content">
  5. <view v-if="favoritesList.length > 0" 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.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.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.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 v-else class="empty">
  35. <uv-empty mode="data" text="暂无收藏商品"></uv-empty>
  36. </view>
  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.id}`
  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. onPullDownRefresh() {
  87. this.initData()
  88. this.getGoodsList()
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .page {
  94. background-color: #f5f5f5;
  95. min-height: 100vh;
  96. }
  97. .content {
  98. padding: 0;
  99. }
  100. .list {
  101. padding: 20rpx;
  102. }
  103. .record-item {
  104. display: flex;
  105. align-items: flex-start;
  106. margin-bottom: 30rpx;
  107. background: #fff;
  108. border-radius: 12rpx;
  109. padding: 20rpx;
  110. }
  111. .record-image {
  112. width: 215rpx;
  113. height: 215rpx;
  114. border-radius: 8rpx;
  115. margin-right: 20rpx;
  116. flex-shrink: 0;
  117. }
  118. .record-content {
  119. flex: 1;
  120. display: flex;
  121. flex-direction: column;
  122. }
  123. .record-info {
  124. display: flex;
  125. flex-direction: column;
  126. margin-bottom: 20rpx;
  127. }
  128. .title-row {
  129. margin-bottom: 10rpx;
  130. }
  131. .record-title {
  132. font-size: 22rpx;
  133. color: #000;
  134. line-height: 1.4;
  135. display: -webkit-box;
  136. -webkit-box-orient: vertical;
  137. -webkit-line-clamp: 2;
  138. overflow: hidden;
  139. }
  140. .record-points {
  141. display: flex;
  142. align-items: center;
  143. margin-bottom: 8rpx;
  144. }
  145. .points-text {
  146. font-size: 26rpx;
  147. color: #218cdd;
  148. font-weight: bold;
  149. margin-left: 6rpx;
  150. }
  151. .record-time {
  152. display: flex;
  153. align-items: center;
  154. }
  155. .time-text {
  156. font-size: 22rpx;
  157. color: #999;
  158. margin-left: 6rpx;
  159. }
  160. .record-action {
  161. display: flex;
  162. justify-content: flex-end;
  163. border-top: 1rpx solid #f0f0f0;
  164. }
  165. .empty {
  166. margin-top: 200rpx;
  167. }
  168. </style>