index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <!-- 订单 -->
  3. <view class="card_order">
  4. <view class="top_cardOrder">
  5. <u-tabs :list="list1" lineColor="#333333" lineWidth="60" :scrollable="false" :current="current"
  6. @change="tabClick"></u-tabs>
  7. </view>
  8. <view class="cardOrder_tab"></view>
  9. <view class="card_order_manag">
  10. <orderManagement :key="Math.random()" :datalist="datalist" @toDeliver="toDeliver"></orderManagement>
  11. </view>
  12. <view class="card_empty" v-if="datalist.length === 0">
  13. <u-empty mode="order"></u-empty>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. // 订单
  19. import orderManagement from '@/components/orderManagement.vue'
  20. export default {
  21. components: {
  22. orderManagement,
  23. },
  24. data() {
  25. return {
  26. current: 0,
  27. list1: [{
  28. name: '全部',
  29. }, {
  30. name: '待配送',
  31. }, {
  32. name: '配送中'
  33. }, {
  34. name: '已送达'
  35. }, {
  36. name: '已取消'
  37. }],
  38. datalist: [],
  39. Pagination: {
  40. PageIndex: 1,
  41. PageSize: 20,
  42. Total: 0,
  43. },
  44. loadingMore: true,
  45. }
  46. },
  47. onTabItemTap() {
  48. this.getOrderList()
  49. },
  50. mounted() {
  51. uni.$on('refresh', () => {
  52. this.datalist = []
  53. this.getOrderList()
  54. })
  55. var token = this.$cache.getToken()
  56. if (token) {
  57. this.getOrderList()
  58. }
  59. },
  60. methods: {
  61. // 触底事件
  62. bottomingEvent() {
  63. if (!this.loadingMore) {
  64. this.getOrderList()
  65. }
  66. },
  67. // 获取订单列表
  68. getOrderList() {
  69. this.$api.get('/api/order/delivery', {
  70. page: this.Pagination.PageIndex,
  71. pageSize: this.Pagination.PageSize,
  72. state: this.orderID,
  73. }).then(res => {
  74. if (res.code == 200) {
  75. const data = res.data.list
  76. if (this.loadingMore == true && data) {
  77. this.datalist = this.datalist.concat(data);
  78. }
  79. if (data.length < this.Pagination.PageSize) {
  80. this.loadingMore = true
  81. } else {
  82. this.loadingMore = false
  83. this.Pagination.PageIndex++
  84. }
  85. }
  86. })
  87. },
  88. // 去配送
  89. toDeliver(row) {
  90. this.$api.put('/api/order/state', {
  91. id: row.id,
  92. state: 5,
  93. }).then(res => {
  94. if (res.code == 200) {
  95. this.current = 2
  96. this.orderID = 5
  97. this.datalist = []
  98. this.getOrderList()
  99. } else {
  100. uni.$u.toast(res.data.msg)
  101. }
  102. })
  103. },
  104. tabClick(row) {
  105. // console.log(row, 26)
  106. if (row.index == 1) {
  107. // 待配送
  108. this.orderID = 2
  109. } else if (row.index == 2) {
  110. // 配送中
  111. this.orderID = 5
  112. } else if (row.index == 3) {
  113. // 已送达
  114. this.orderID = 3
  115. } else if (row.index == 4) {
  116. // 已取消
  117. this.orderID = 4
  118. } else {
  119. this.orderID = null
  120. }
  121. this.datalist = []
  122. this.current = row.index;
  123. this.getOrderList()
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .top_cardOrder {
  130. position: fixed;
  131. top: 0;
  132. left: 0;
  133. right: 0;
  134. background-color: #fff;
  135. z-index: 1;
  136. padding: 10rpx;
  137. padding-top: var(--status-bar-height);
  138. }
  139. .cardOrder_tab {
  140. width: 100%;
  141. height: 88rpx;
  142. padding-top: var(--status-bar-height);
  143. }
  144. .card_empty {
  145. padding-top: 30%;
  146. }
  147. .card_order_manag {
  148. margin-bottom: 50rpx;
  149. }
  150. </style>