collectList.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <script>
  2. import api from '@/api'
  3. export default {
  4. data() {
  5. return {
  6. lists: []
  7. }
  8. },
  9. methods: {
  10. reload() {
  11. this.$refs.mescrollItem.reload()
  12. },
  13. async getList(page) {
  14. let res = await api.goodsAttList(page)
  15. this.lists = page.page === 1 ? res : [...this.lists, ...res]
  16. return res.length
  17. },
  18. async cancelAtt(id) {
  19. await api.cancelAtt(id)
  20. this.reload()
  21. }
  22. },
  23. provide() {
  24. return {
  25. getList: this.getList
  26. }
  27. }
  28. }
  29. </script>
  30. <template>
  31. <scroll ref="mescrollItem">
  32. <view class="list w">
  33. <view class="item bg-white radius flex" v-for="item in lists" :key="item.id">
  34. <image :src="item.goods_img" class="img"></image>
  35. <view class="info flex1">
  36. <u-text :text="item.goods_name" size="30rpx" bold></u-text>
  37. <u-text
  38. :text="`${item.attension_count}人收藏`"
  39. color="#959595"
  40. margin="20rpx 0"
  41. size="24rpx"
  42. ></u-text>
  43. <view class="flex">
  44. <u-text :text="item.price" mode="price" size="32rpx" bold></u-text>
  45. <u-text
  46. :text="`赠送${item.rebate_score}积分`"
  47. color="#F76363"
  48. bold
  49. align="right"
  50. size="30rpx"
  51. ></u-text>
  52. </view>
  53. <view class="btns flex flex-end">
  54. <u-button
  55. text="取消收藏"
  56. shape="circle"
  57. plain
  58. customStyle="width:150rpx;height:55rpx;margin:0 10rpx"
  59. @click="cancelAtt(item.goods_id)"
  60. ></u-button>
  61. <u-button
  62. text="去购买"
  63. shape="circle"
  64. color="var(--theme)"
  65. customStyle="width:150rpx;height:55rpx;margin:0"
  66. @click="$jump({ url: '/pagesGoods/goodsDetail/goodsDetail' }, { sn: item.goods_sn })"
  67. ></u-button>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </scroll>
  73. </template>
  74. <style lang="scss" scoped>
  75. .item {
  76. padding: 30rpx 25rpx 25rpx;
  77. margin-top: 20rpx;
  78. .img {
  79. width: 226rpx;
  80. height: 226rpx;
  81. border-radius: 10rpx;
  82. }
  83. .info {
  84. margin-left: 25rpx;
  85. }
  86. .btns {
  87. margin-top: 38rpx;
  88. }
  89. }
  90. </style>