waterUse.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="good-list">
  3. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  4. <!-- 空白页 -->
  5. <!-- #ifdef H5 -->
  6. <empty src="../../static/error/emptyMyCart.png"
  7. v-if="navList[tabCurrentIndex].loaded === true && navList[tabCurrentIndex].orderList.length === 0">
  8. </empty>
  9. <!-- #endif -->
  10. <!-- #ifndef H5 -->
  11. <empty src="../static/error/emptyMyCart.png"
  12. v-if="navList[tabCurrentIndex].loaded === true && navList[tabCurrentIndex].orderList.length === 0">
  13. </empty>
  14. <!-- #endif -->
  15. <view class="good flex" v-for="item in navList[tabCurrentIndex].orderList">
  16. <image :src="item.product.image" mode="" class="good-image"></image>
  17. <view class="right">
  18. <view class="good-name ">
  19. <view class="clamp2">
  20. {{item.product.store_name}}
  21. </view>
  22. </view>
  23. <view class="good-key">
  24. {{item.product.keyword}}
  25. </view>
  26. <view class="good-price">
  27. 剩余<text class="num">{{item.certificate_num}}</text>张
  28. </view>
  29. </view>
  30. </view>
  31. <uni-load-more :status="navList[tabCurrentIndex].loadingType"></uni-load-more>
  32. </scroll-view>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. use_certificate
  38. } from '@/api/water.js';
  39. export default {
  40. data() {
  41. return {
  42. tabCurrentIndex: 0,
  43. navList: [{
  44. state: 0,
  45. text: '全部',
  46. loadingType: 'more',
  47. orderList: [],
  48. page: 1, //当前页数
  49. limit: 10 //每次信息条数
  50. }]
  51. };
  52. },
  53. computed: {
  54. allNumber() {
  55. const item = this.navList[0].orderList;
  56. let num = 0;
  57. for (let i = 0; i < item.length; i++) {
  58. num += item[i].certificate_num
  59. }
  60. return num
  61. }
  62. },
  63. onReachBottom() {
  64. this.getGoodList();
  65. },
  66. onLoad: function(option) {
  67. this.getGoodList();
  68. },
  69. methods: {
  70. // 返回退回
  71. back() {
  72. uni.reLaunch({
  73. url: '/pages/home/user'
  74. })
  75. },
  76. // 加载数据
  77. getGoodList(source) {
  78. //这里是将订单挂载到tab列表下
  79. let index = this.tabCurrentIndex;
  80. let navItem = this.navList[index];
  81. let state = navItem.state;
  82. console.log(navItem, '数据');
  83. if (source === 'tabChange' && navItem.loaded === true) {
  84. //tab切换只有第一次需要加载数据
  85. return;
  86. }
  87. if (navItem.loadingType === 'loading') {
  88. //防止重复加载
  89. return;
  90. }
  91. if (navItem.loadingType === 'noMore') {
  92. //防止重复加载
  93. return;
  94. }
  95. // 修改当前对象状态为加载中
  96. navItem.loadingType = 'loading';
  97. use_certificate({
  98. page: navItem.page,
  99. limit: navItem.limit
  100. })
  101. .then(({
  102. data
  103. }) => {
  104. let arr = data.data
  105. navItem.orderList = navItem.orderList.concat(arr);
  106. navItem.page++;
  107. if (navItem.limit == arr.length) {
  108. //判断是否还有数据, 有改为 more, 没有改为noMore
  109. navItem.loadingType = 'more';
  110. return;
  111. } else {
  112. //判断是否还有数据, 有改为 more, 没有改为noMore
  113. navItem.loadingType = 'noMore';
  114. }
  115. uni.hideLoading();
  116. this.$set(navItem, 'loaded', true);
  117. })
  118. .catch(e => {
  119. console.log(e);
  120. });
  121. },
  122. }
  123. };
  124. </script>
  125. <style lang="scss">
  126. .good-list {
  127. width: 750rpx;
  128. height: 100%;
  129. .good {
  130. background: #FFFFFF;
  131. box-shadow: 0px 0px 20px 0px rgba(50, 50, 52, 0.06);
  132. width: 100%;
  133. border-radius: 14rpx;
  134. margin-bottom: 20rpx;
  135. position: relative;
  136. padding: 20rpx;
  137. .good-image {
  138. width: 180rpx;
  139. height: 180rpx;
  140. background-color: #eee;
  141. border-radius: 10rpx;
  142. flex-shrink: 0;
  143. }
  144. .right {
  145. height: 180rpx;
  146. position: relative;
  147. .good-name {
  148. font-size: 28rpx;
  149. font-weight: bold;
  150. color: #333333;
  151. padding-left: 20rpx;
  152. }
  153. .good-key {
  154. font-size: 22rpx;
  155. font-weight: 500;
  156. color: #999999;
  157. padding-left: 20rpx
  158. }
  159. .good-price {
  160. font-size: 28rpx;
  161. font-weight: bold;
  162. position: absolute;
  163. bottom: 0rpx;
  164. padding: 0 20rpx;
  165. left: 0;
  166. right: 0rpx;
  167. .num{
  168. color:$color-red;
  169. }
  170. }
  171. }
  172. }
  173. }
  174. .list-scroll-content {
  175. height: calc(100% - 200px - var(--status-bar-height));
  176. padding: 20rpx;
  177. }
  178. </style>