list.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <zj-page-layout
  4. :hasFooter="false"
  5. :isScroll="true"
  6. :refresherTriggered="refresherTriggered"
  7. @refresherrefresh="refresherrefresh"
  8. @scrolltolower="scrolltolower">
  9. <template slot="header">
  10. <view class="header-container">
  11. <u-tabs
  12. :scrollable="false"
  13. :list="tabList"
  14. :current="tabCurrent"
  15. @click="clickTab"
  16. lineColor="#01C30B"
  17. :activeStyle="{
  18. color: '#01C30B'
  19. }"
  20. :inactiveStyle="{
  21. color: '#666666'
  22. }"
  23. itemStyle="padding-left: 0; padding-right: 0; height: 88rpx;">
  24. </u-tabs>
  25. </view>
  26. </template>
  27. <view class="common-order-list">
  28. <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toDetail(item.orderId)">
  29. <view class="top">
  30. <image src="@/static/common/logo.png"></image>
  31. <view class="user">
  32. <view class="name">{{item.userName}}</view>
  33. <view class="time">{{item.goodsCreateTime | timeFilter}}发布</view>
  34. </view>
  35. <view class="status">{{item.status | statusFilter}}</view>
  36. </view>
  37. <view class="goods">
  38. <image :src="imageUrl + item.goodsPicUrl"></image>
  39. <view class="main">
  40. <view class="name">{{item.goodsTitle}}</view>
  41. <view class="des">{{item.content}}</view>
  42. <view class="price"><text>{{item.goodsAmount | priceFilter2}}</text>数量:{{item.num}}</view>
  43. </view>
  44. </view>
  45. <view class="total">订单总金额<text>{{item.price | priceFilter2}}</text></view>
  46. <view class="bottom">
  47. <view class="left-location"><text class="iconfont icon-dingwei"></text>{{item.city}} {{item.area}}</view>
  48. <view class="right-btn" @tap.stop>
  49. <block v-if="item.status == 'WAIT'">
  50. <u-button text="取消订单" shape="circle"></u-button>
  51. <u-button text="去支付" shape="circle" type="primary" plain @tap="toPay(item.goodsId, item.orderId)"></u-button>
  52. </block>
  53. <u-button text="查看物流" shape="circle" @tap="toLogistics(item.logisticsNum)"></u-button>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <Loading :loadStatus="loadStatus" :dataList="dataList" />
  59. </zj-page-layout>
  60. <!-- #endif -->
  61. <!-- #ifndef H5 -->
  62. <web-view :src="webViewHref(`/pages/mine/myBuy/list`, pam)"></web-view>
  63. <!-- #endif -->
  64. </template>
  65. <script>
  66. // #ifdef H5
  67. export default {
  68. filters: {
  69. statusFilter(val) {
  70. const MAP = {
  71. WAIT: '待支付',
  72. WAIT_SEND: '待发货',
  73. SEND: '已发货',
  74. COMPLETE: '已完成',
  75. }
  76. return MAP[val];
  77. }
  78. },
  79. data() {
  80. return {
  81. imageUrl: this.$imageUrl,
  82. tabList: [
  83. {name: '全部', value: 0},
  84. {name: '待付款', value: 1},
  85. {name: '待发货', value: 2},
  86. {name: '待收货', value: 3},
  87. {name: '已收货', value: 4},
  88. {name: '售后中', value: 5},
  89. ],
  90. tabCurrent: 0,
  91. dataList: [],
  92. pageNum: 1,
  93. loadStatus: 0,
  94. refresherTriggered: false,
  95. }
  96. },
  97. async onLoad({tab}) {
  98. this.tabCurrent = tab ? Number(tab) : 0;
  99. await this.getList();
  100. },
  101. methods: {
  102. //获取列表数据
  103. async getList() {
  104. const statusMap = {
  105. 0: '',
  106. 1: 'WAIT',
  107. 2: 'WAIT_SEND',
  108. 3: 'SEND',
  109. 4: 'COMPLETE',
  110. 5: 'AFTER_WAIT',
  111. }
  112. this.$api.post('/orderPay/list', {
  113. pageNum: this.pageNum,
  114. pageSize: 10,
  115. params: [{
  116. param: 'a.status',
  117. compare: '=',
  118. value: statusMap[this.tabCurrent]
  119. }, {
  120. param: 'a.buyer_user_id',
  121. compare: '=',
  122. value: this.$store.state.user.userId
  123. }]
  124. }).then(res => {
  125. this.loadStatus = 0;
  126. let list = res.data.records;
  127. if(list.length < 10){
  128. this.loadStatus = 2;
  129. }
  130. this.dataList = this.dataList.concat(list);
  131. }).catch(() => {
  132. this.loadStatus = 2;
  133. }).finally(res => {
  134. this.refresherTriggered = false;
  135. })
  136. },
  137. // 滚动到底部
  138. scrolltolower(e) {
  139. if (this.loadStatus === 0) {
  140. this.pageNum++;
  141. this.getList();
  142. }
  143. },
  144. // 触发下拉刷新
  145. refresherrefresh(e) {
  146. this.refresherTriggered = true;
  147. this.refreshLish();
  148. },
  149. refreshLish() {
  150. this.dataList = [];
  151. this.pageNum = 1;
  152. this.getList();
  153. },
  154. clickTab(item) {
  155. this.tabCurrent = item.value;
  156. this.refreshLish();
  157. },
  158. toDetail(id) {
  159. this.$navToPage({
  160. url: `/pages/mine/myBuy/detail?id=${id}`
  161. })
  162. },
  163. toLogistics(logisticsNum) {
  164. this.$navToPage({
  165. url: `/pages/mine/myBuy/logistics?logisticsNum=${logisticsNum}`
  166. })
  167. },
  168. toPay(goodsId, orderId) {
  169. this.$navToPage({
  170. url: `/pages/goods/order?goodsId=${goodsId}&orderId=${orderId}`
  171. })
  172. }
  173. }
  174. }
  175. // #endif
  176. // #ifndef H5
  177. export default {
  178. data() {
  179. return {
  180. pam: {},
  181. }
  182. },
  183. onLoad(pam) {
  184. this.pam = pam;
  185. },
  186. }
  187. // #endif
  188. </script>
  189. <style lang="scss" scoped>
  190. .header-container {
  191. background: #ffffff;
  192. }
  193. </style>