list.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="container">
  3. <u-sticky style="top: 0" offset-top="0">
  4. <u-tabs :list="tabArray" :current="tabIndex" itemStyle="padding-left: 18px; padding-right: 18px; height: 36px;" @change="handleStatusChange"></u-tabs>
  5. </u-sticky>
  6. <view class="order-list">
  7. <view v-for="order in orderList" :key="order.no" class="order-item">
  8. <view class="order-header">
  9. <view class="order-no">订单编号:{{ order.no }}</view>
  10. <view class="order-status">{{ order.status | getStatusName }}</view>
  11. </view>
  12. <view v-if="order.items.length === 1" class="order-single-item" @click="handleOrderClick(order.id)">
  13. <view class="item-wrap" v-for="item in order.items" :key="item.id">
  14. <view class="item-info">
  15. <image class="item-cover" :src="item.picUrl"></image>
  16. <u--text :lines="2" size="15px" color="#333333" :text="item.spuName"></u--text>
  17. </view>
  18. <view class="item-count">共{{ item.count }}件</view>
  19. </view>
  20. </view>
  21. <view v-else class="order-multi-item" @click="handleOrderClick(order.id)">
  22. <u-scroll-list :indicator="false">
  23. <view class="item-wrap" v-for="item in order.items" :key="item.id">
  24. <image class="item-image" :src="item.picUrl"></image>
  25. </view>
  26. </u-scroll-list>
  27. <view class="product-count">共{{ order.productCount }}件</view>
  28. </view>
  29. <view class="order-btn-group">
  30. <view class="order-btn">再次购买</view>
  31. <view class="order-btn">其他操作</view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { getOrderPage } from '../../api/order'
  39. import orderStatus from '@/common/orderStatus'
  40. export default {
  41. name: 'orderList',
  42. filters: {
  43. getStatusName(status) {
  44. return orderStatus[status + ''].name
  45. }
  46. },
  47. data() {
  48. return {
  49. pageNo: 1,
  50. tabIndex: 0,
  51. orderList: []
  52. }
  53. },
  54. computed: {
  55. tabArray() {
  56. let tabArray = [{ name: '全部', status: 'all' }]
  57. for (let status in orderStatus) {
  58. if (status !== '40') {
  59. tabArray.push({ name: orderStatus[status].name, status: status })
  60. }
  61. }
  62. return tabArray
  63. }
  64. },
  65. onLoad(e) {
  66. const status = e.status
  67. if (status !== undefined) {
  68. this.tabArray.forEach((item, index) => {
  69. if (item.status === status) {
  70. this.tabIndex = index
  71. }
  72. })
  73. }
  74. this.loadOrderPageData()
  75. },
  76. methods: {
  77. handleStatusChange({ index }) {
  78. this.tabIndex = index
  79. this.loadOrderPageData()
  80. },
  81. loadOrderPageData() {
  82. let params = { pageNo: this.pageNo }
  83. const status = this.tabArray[this.tabIndex].status
  84. if (status !== 'all') {
  85. params.orderStatus = status
  86. }
  87. getOrderPage(params)
  88. .then(res => {
  89. this.orderList = res.data.list || []
  90. })
  91. .catch(err => {
  92. console.log(err)
  93. })
  94. },
  95. handleOrderClick(orderId) {
  96. uni.$u.route('/pages/order/detail', {
  97. orderId: orderId
  98. })
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .order-list {
  105. background-color: #f3f3f3;
  106. .order-item {
  107. padding: 20rpx;
  108. background-color: #ffffff;
  109. border-bottom: $custom-border-style;
  110. .order-header {
  111. @include flex-space-between;
  112. height: 80rpx;
  113. .order-no {
  114. font-size: 28rpx;
  115. color: #333;
  116. }
  117. .order-status {
  118. font-size: 24rpx;
  119. color: #999;
  120. }
  121. }
  122. .order-single-item {
  123. .item-wrap {
  124. @include flex-space-between();
  125. .item-info {
  126. @include flex-left();
  127. .item-cover {
  128. width: 100rpx;
  129. height: 100rpx;
  130. border-radius: 10rpx;
  131. margin-right: 15rpx;
  132. }
  133. }
  134. .item-count {
  135. color: #999;
  136. font-size: 24rpx;
  137. width: 120rpx;
  138. text-align: right;
  139. }
  140. }
  141. }
  142. .order-multi-item {
  143. @include flex-space-between();
  144. .item-wrap {
  145. margin-right: 20rpx;
  146. .item-image {
  147. width: 100rpx;
  148. height: 100rpx;
  149. border-radius: 10rpx;
  150. }
  151. }
  152. .product-count {
  153. color: #999;
  154. font-size: 24rpx;
  155. width: 120rpx;
  156. text-align: right;
  157. }
  158. }
  159. .order-btn-group {
  160. margin-top: 10rpx;
  161. @include flex-right();
  162. .order-btn {
  163. width: 120rpx;
  164. height: 36rpx;
  165. line-height: 36rpx;
  166. border-radius: 36rpx;
  167. border: 1px solid #777;
  168. color: #777;
  169. font-size: 22rpx;
  170. text-align: center;
  171. margin-left: 15rpx;
  172. }
  173. }
  174. }
  175. }
  176. </style>