小程序端工程代码
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.

101 lines
3.3 KiB

  1. <template>
  2. <view ref="container">
  3. <view class="collectionGoods" v-if="collectProductList.length > 0">
  4. <view class="item acea-row row-between-wrapper" v-for="(item, collectProductListIndex) in collectProductList" :key="collectProductListIndex" @click="goGoodsCon(item)">
  5. <view class="pictrue">
  6. <image :src="item.image" />
  7. </view>
  8. <view class="text acea-row row-column-between">
  9. <view class="infor line1">{{ item.storeName }}</view>
  10. <view class="acea-row row-between-wrapper">
  11. <view class="money font-color-red" v-if="isIntegral == 1">{{ item.costPrice }}积分</view>
  12. <view class="money font-color-red" v-else>{{ item.price }}</view>
  13. <view class="delete" @tap.stop="delCollection(collectProductListIndex)">删除</view>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <Loading :loaded="loadend" :loading="loading"></Loading>
  19. <view class="noCommodity" style="background-color:#fff;" v-if="collectProductList.length < 1 && page > 1">
  20. <view class="noPictrue">
  21. <image :src="`${$VUE_APP_RESOURCES_URL}/images/noCollection.png`" class="image" />
  22. </view>
  23. <Recommend></Recommend>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import Recommend from '@/components/Recommend'
  29. import { getCollectUser, getCollectDel } from '@/api/user'
  30. import Loading from '@/components/Loading'
  31. export default {
  32. name: 'GoodsFoot',
  33. components: {
  34. Recommend,
  35. Loading,
  36. },
  37. props: {},
  38. data: function() {
  39. return {
  40. page: 1,
  41. limit: 20,
  42. type: 'foot',
  43. collectProductList: [],
  44. loadTitle: '',
  45. loading: false,
  46. loadend: false,
  47. }
  48. },
  49. mounted: function() {
  50. this.get_user_collect_product()
  51. },
  52. onReachBottom() {
  53. !this.loading && this.get_user_collect_product()
  54. },
  55. methods: {
  56. goGoodsCon(item) {
  57. if (item.isIntegral == 1) {
  58. this.$yrouter.push({
  59. path: '/pages/shop/GoodsCon/index',
  60. query: { id: item.pid },
  61. })
  62. } else {
  63. this.$yrouter.push({
  64. path: '/pages/shop/GoodsCon/index',
  65. query: { id: item.pid },
  66. })
  67. }
  68. },
  69. get_user_collect_product: function() {
  70. let that = this
  71. if (that.loading) return //阻止下次请求(false可以进行请求);
  72. if (that.loadend) return //阻止结束当前请求(false可以进行请求);
  73. that.loading = true
  74. getCollectUser(that.page, that.limit, that.type).then(res => {
  75. that.loading = false
  76. //apply();js将一个数组插入另一个数组;
  77. that.collectProductList.push.apply(that.collectProductList, res.data)
  78. that.loadend = res.data.length < that.limit //判断所有数据是否加载完成;
  79. that.page = that.page + 1
  80. })
  81. },
  82. //删除收藏;
  83. delCollection: function(index) {
  84. let that = this,
  85. id = that.collectProductList[index].pid,
  86. category = that.collectProductList[index].category
  87. getCollectDel(id, category).then(function() {
  88. uni.showToast({
  89. title: '删除成功',
  90. icon: 'success',
  91. duration: 2000,
  92. complete: () => {
  93. that.collectProductList.splice(index, 1)
  94. that.$set(that, 'collectProductList', that.collectProductList)
  95. },
  96. })
  97. })
  98. },
  99. },
  100. }
  101. </script>