collect.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view>
  3. <!--mine/collect/collect.wxml-->
  4. <view class="list" v-if="pageList.length > 0">
  5. <view v-for="(item, index) in pageList" :key="index" class="li">
  6. <image :src="item.pic" @tap="redirectDetail" :data-id="item.id" mode="aspectFit" class="cimg"></image>
  7. <view class="zhinfo">
  8. <view class="zhtit" @tap="redirectDetail" :data-id="item.id">{{item.title}}</view>
  9. <!-- <view class="guige">规格:15g</view> -->
  10. <view class="jiage">
  11. <view class="zhjia" @tap="redirectDetail" :data-id="item.id">¥<text>{{item.salePrice}}</text></view>
  12. <view class="btn" @tap="clickCollect(item,index)">取消收藏</view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="nodata" v-else>
  18. <image :src="picUrlss+'empty_sc.png'"></image>
  19. <text>暂无收藏</text>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. const req = require("../../utils/request.js");
  25. const app = getApp();
  26. export default {
  27. data() {
  28. return {
  29. picUrlss: req.public.picUrls,
  30. form: {
  31. page: 1,
  32. limit: 10
  33. },
  34. pageList: [],
  35. isLoad: true,
  36. ishow: false
  37. };
  38. },
  39. components: {},
  40. props: {},
  41. onLoad: function (options) {
  42. this.loadFootprint();
  43. },
  44. onReachBottom() {
  45. this.form.page++;
  46. this.loadCoupon();
  47. },
  48. methods: {
  49. loadFootprint() {
  50. let isShowLoading = false;
  51. if (this.form.page == 1 && !isShowLoading) {
  52. req.loadIng('加载中');
  53. isShowLoading = true;
  54. }
  55. if (!this.isLoad) return false;
  56. this.isLoad = false;
  57. let that = this;
  58. req.getRequest('/api/collect/product', this.form, data => {
  59. if (data && data.length == 10) this.isLoad = true;
  60. if (that.form.page > 1) data = that.pageList.concat(data);
  61. that.setData({
  62. pageList: data
  63. });
  64. if (!this.pageList||this.pageList.length<1) {
  65. that.setData({
  66. ishow: true
  67. });
  68. } else {
  69. that.setData({
  70. ishow: false
  71. });
  72. }
  73. if (isShowLoading) {
  74. uni.hideLoading();
  75. isShowLoading = false;
  76. }
  77. });
  78. },
  79. clickCollect(item,index) {
  80. let _ts = this;
  81. const page = this.pageList[index];
  82. req.postRequest('/api/collect', {
  83. bindId: page.id,
  84. type: 1
  85. }, data => {
  86. _ts.pageList.splice(index, 1);
  87. });
  88. },
  89. redirectDetail(event) {
  90. uni.navigateTo({
  91. url: '/product/detail/detail?id=' + event.currentTarget.dataset.id
  92. });
  93. }
  94. }
  95. };
  96. </script>
  97. <style>
  98. @import "./collect.css";
  99. </style>