waterUse.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 @click="navTo( '/pages/order/orderDetail?id=' + item.order_id )"
  16. v-for="(item, index) in navList[tabCurrentIndex].orderList" :key="index" class="order-item position-relative">
  17. <view class="i-top b-b flex">
  18. <view class="order-code flex">
  19. <view class="no">
  20. 订单编号:
  21. </view>
  22. <view>
  23. {{ item.order_id }}
  24. </view>
  25. </view>
  26. <text class="font-size-sm" :style="{ color: item.stateTipColor }">{{ item._status._title }}</text>
  27. <!-- <text v-if="item.status === 4" class="del-btn iconfont icondelete" @click="deleteOrder(index)"></text> -->
  28. </view>
  29. <scroll-view v-if="item.cartInfo.length > 0" class="goods-box" scroll-x>
  30. <view v-for="(goodsItem, goodsIndex) in item.cartInfo" :key="goodsIndex" class="goods-item">
  31. <image class="goods-img" :src="goodsItem.productInfo.image" mode="aspectFill">
  32. </image>
  33. <view class="good-name clamp">
  34. {{goodsItem.productInfo.attrInfo.suk}}*{{goodsItem.cart_num}}
  35. </view>
  36. </view>
  37. </scroll-view>
  38. <view class="info-info">
  39. <view class="js">
  40. 共{{item.cartInfo.length}}件
  41. </view>
  42. <view class="hj">
  43. 合计:¥{{item.pay_price}}
  44. </view>
  45. </view>
  46. </view>
  47. <uni-load-more :status="navList[tabCurrentIndex].loadingType"></uni-load-more>
  48. </scroll-view>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. use_certificate
  54. } from '@/api/water.js';
  55. export default {
  56. data() {
  57. return {
  58. tabCurrentIndex: 0,
  59. navList: [{
  60. state: 0,
  61. text: '全部',
  62. loadingType: 'more',
  63. orderList: [],
  64. page: 1, //当前页数
  65. limit: 10 //每次信息条数
  66. }]
  67. };
  68. },
  69. computed: {
  70. allNumber() {
  71. const item = this.navList[0].orderList;
  72. let num = 0;
  73. for (let i = 0; i < item.length; i++) {
  74. num += item[i].certificate_num
  75. }
  76. return num
  77. }
  78. },
  79. onReachBottom() {
  80. this.getGoodList();
  81. },
  82. onLoad: function(option) {
  83. this.getGoodList();
  84. },
  85. methods: {
  86. // 返回退回
  87. back() {
  88. uni.reLaunch({
  89. url: '/pages/home/user'
  90. })
  91. },
  92. // 加载数据
  93. getGoodList(source) {
  94. //这里是将订单挂载到tab列表下
  95. let index = this.tabCurrentIndex;
  96. let navItem = this.navList[index];
  97. let state = navItem.state;
  98. console.log(navItem, '数据');
  99. if (source === 'tabChange' && navItem.loaded === true) {
  100. //tab切换只有第一次需要加载数据
  101. return;
  102. }
  103. if (navItem.loadingType === 'loading') {
  104. //防止重复加载
  105. return;
  106. }
  107. if (navItem.loadingType === 'noMore') {
  108. //防止重复加载
  109. return;
  110. }
  111. // 修改当前对象状态为加载中
  112. navItem.loadingType = 'loading';
  113. use_certificate({
  114. page: navItem.page,
  115. limit: navItem.limit
  116. })
  117. .then(({
  118. data
  119. }) => {
  120. let arr = data.data
  121. navItem.orderList = navItem.orderList.concat(arr);
  122. navItem.page++;
  123. if (navItem.limit == arr.length) {
  124. //判断是否还有数据, 有改为 more, 没有改为noMore
  125. navItem.loadingType = 'more';
  126. return;
  127. } else {
  128. //判断是否还有数据, 有改为 more, 没有改为noMore
  129. navItem.loadingType = 'noMore';
  130. }
  131. uni.hideLoading();
  132. this.$set(navItem, 'loaded', true);
  133. })
  134. .catch(e => {
  135. console.log(e);
  136. });
  137. },
  138. }
  139. };
  140. </script>
  141. <style lang="scss">
  142. .good-list {
  143. width: 750rpx;
  144. height: 100%;
  145. .good {
  146. background: #FFFFFF;
  147. box-shadow: 0px 0px 20px 0px rgba(50, 50, 52, 0.06);
  148. width: 100%;
  149. border-radius: 14rpx;
  150. margin-bottom: 20rpx;
  151. position: relative;
  152. padding: 20rpx;
  153. .good-image {
  154. width: 180rpx;
  155. height: 180rpx;
  156. background-color: #eee;
  157. border-radius: 10rpx;
  158. flex-shrink: 0;
  159. }
  160. .right {
  161. height: 180rpx;
  162. position: relative;
  163. .good-name {
  164. font-size: 28rpx;
  165. font-weight: bold;
  166. color: #333333;
  167. padding-left: 20rpx;
  168. }
  169. .good-key {
  170. font-size: 22rpx;
  171. font-weight: 500;
  172. color: #999999;
  173. padding-left: 20rpx
  174. }
  175. .good-price {
  176. font-size: 28rpx;
  177. font-weight: bold;
  178. position: absolute;
  179. bottom: 0rpx;
  180. padding: 0 20rpx;
  181. left: 0;
  182. right: 0rpx;
  183. .num{
  184. color:$color-red;
  185. }
  186. }
  187. }
  188. }
  189. }
  190. .list-scroll-content {
  191. height: calc(100% - 200px - var(--status-bar-height));
  192. padding: 20rpx;
  193. }
  194. </style>