index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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" v-if="current == 0">
  10. <orderManagement :datalist="datalist" @confirmedDelivery="confirmedDelivery"></orderManagement>
  11. </view>
  12. <!-- 待配送 -->
  13. <view class="card_order_manag" v-if="current == 1">
  14. <orderManagement :datalist="datalist" @confirmedDelivery="confirmedDelivery"></orderManagement>
  15. </view>
  16. <!-- 配送中 -->
  17. <view class="card_order_manag" v-if="current == 2">
  18. <orderManagement :datalist="datalist"></orderManagement>
  19. </view>
  20. <!-- 已送达 -->
  21. <view class="card_order_manag" v-if="current == 3">
  22. <orderManagement :datalist="datalist"></orderManagement>
  23. </view>
  24. <!-- 已取消 -->
  25. <view class="card_order_manag" v-if="current == 4">
  26. <orderManagement :datalist="datalist"></orderManagement>
  27. </view>
  28. <view class="card_empty" v-if="datalist.length === 0">
  29. <u-empty mode="order"></u-empty>
  30. </view>
  31. <u-modal width="450rpx" :show="show" showCancelButton :content='title' @cancel="show = false"
  32. @confirm="expurgate"></u-modal>
  33. </view>
  34. </template>
  35. <script>
  36. // 订单
  37. import orderManagement from '@/components/orderManagement.vue'
  38. export default {
  39. components: {
  40. orderManagement,
  41. },
  42. data() {
  43. return {
  44. current: 0,
  45. list1: [{
  46. name: '全部',
  47. }, {
  48. name: '待配送',
  49. }, {
  50. name: '配送中'
  51. }, {
  52. name: '已送达'
  53. }, {
  54. name: '已取消'
  55. }],
  56. datalist: [],
  57. show: false,
  58. title: '订单删除后无法恢复是否删除订单?',
  59. orderId: null,
  60. }
  61. },
  62. // onTabItemTap() {
  63. // this.getOrderList()
  64. // },
  65. mounted() {
  66. uni.$on('refresh', () => {
  67. this.getOrderList()
  68. })
  69. var token = this.$cache.getToken()
  70. if (token) {
  71. this.getOrderList()
  72. }
  73. },
  74. methods: {
  75. // 获取订单列表
  76. getOrderList(stateType) {
  77. this.$api.get('/api/applet/order', {
  78. state: stateType,
  79. }).then(res => {
  80. if (res.code == 200) {
  81. this.datalist = res.data.list
  82. } else {
  83. this.datalist = []
  84. }
  85. })
  86. },
  87. confirmedDelivery(orderId) {
  88. this.show = true
  89. this.orderId = orderId
  90. },
  91. // 取消订单
  92. expurgate() {
  93. this.$api.post('/api/applet/order/cancel', {
  94. id: this.orderId,
  95. }).then(res => {
  96. if (res.code == 200) {
  97. this.show = false
  98. this.getOrderList(this.current)
  99. }
  100. })
  101. },
  102. tabClick(row) {
  103. // console.log(row, 26)
  104. if (row.index == 1) {
  105. this.getOrderList(1)
  106. } else if (row.index == 2) {
  107. this.getOrderList(5)
  108. } else if (row.index == 3) {
  109. this.getOrderList(3)
  110. } else if (row.index == 4) {
  111. this.getOrderList(4)
  112. } else {
  113. this.getOrderList()
  114. }
  115. this.current = row.index;
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .top_cardOrder {
  122. position: fixed;
  123. top: 0;
  124. left: 0;
  125. right: 0;
  126. background-color: #fff;
  127. z-index: 1;
  128. padding: 10rpx;
  129. padding-top: var(--status-bar-height);
  130. }
  131. .cardOrder_tab {
  132. width: 100%;
  133. height: 88rpx;
  134. padding-top: var(--status-bar-height);
  135. }
  136. .card_empty {
  137. padding-top: 30%;
  138. }
  139. .card_order_manag {
  140. margin-bottom: 50rpx;
  141. }
  142. </style>