order-page.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class="order-page">
  3. <!-- 标签页 -->
  4. <view class="tabs-wrapper">
  5. <u-tabs :list="tabList" :current="currentTab" @change="handleTabChange" :is-scroll="false"
  6. active-color="#38C148" bar-width="60"></u-tabs>
  7. </view>
  8. <!-- 订单列表 -->
  9. <page-scroll :page-size="12" @updateList="handleUpdateList" ref="pageRef" slotEmpty
  10. url="/token/order/getMyOrderList" :params="params" :immediate="false">
  11. <view v-if="orderList.length > 0" class="pad-20">
  12. <order-item v-for="order in orderList" :key="order.orderNo" :order="order" @action="handleAction"
  13. @success="handleSuccess"></order-item>
  14. </view>
  15. </page-scroll>
  16. <u-action-sheet v-model="showReportSheet" :list="actionList" @close="showReportSheet = false"
  17. @click="handleReportSelect" cancelText="取消" :mask-close-able="false" :safe-area-inset-bottom="true" />
  18. <common-dialog ref="reviewDialog" title="温馨提示" @confirm="confirmReview">
  19. <text>对审核结果有疑问,申请复审?</text>
  20. </common-dialog>
  21. <common-dialog ref="processDialog" title="温馨提示" @confirm="handleSuccess">
  22. <text>{{ reviewMsg }}</text>
  23. </common-dialog>
  24. <common-dialog ref="errorDialog" title="温馨提示" :showCancel="false">
  25. <text>{{ errorMsg }}</text>
  26. </common-dialog>
  27. </view>
  28. </template>
  29. <script>
  30. import OrderItem from '../components/order-item.vue'
  31. import pageScroll from '@/components/pageScroll/index.vue'
  32. import CommonDialog from '@/components/common-dialog.vue'
  33. import mixin from '../mixin/btnAction.js'
  34. export default {
  35. mixins: [mixin],
  36. components: {
  37. OrderItem,
  38. pageScroll,
  39. CommonDialog,
  40. },
  41. data() {
  42. return {
  43. tabList: [{
  44. name: '全部',
  45. status: "-1"
  46. },
  47. {
  48. name: '待初审',
  49. status: "2"
  50. },
  51. {
  52. name: '待取件',
  53. status: "3"
  54. },
  55. {
  56. name: '待审核',
  57. status: "8"
  58. },
  59. {
  60. name: '待到款',
  61. status: "10"
  62. }
  63. ],
  64. currentTab: 0,
  65. orderList: [],
  66. isRefreshing: false,
  67. page: 1,
  68. pageSize: 10,
  69. hasMore: true,
  70. params: {},
  71. reviewMsg: "",
  72. errorMsg: ""
  73. }
  74. },
  75. onLoad(options) {
  76. console.log(options, 'options')
  77. // 如果有传入状态,切换到对应tab
  78. if (options.status) {
  79. this.currentTab = this.tabList.findIndex(item => item.status == options.status)
  80. this.params.status = options.status
  81. } else {
  82. this.currentTab = 0
  83. }
  84. this.loadOrders(true, this.params)
  85. uni.$on('btnActionSuccess', () => {
  86. this.loadOrders(true, this.params)
  87. })
  88. },
  89. onUnload() {
  90. uni.$off('btnActionSuccess')
  91. },
  92. methods: {
  93. loadOrders(bool = false, params = {}) {
  94. console.log(this.$refs.pageRef, 'params')
  95. this.$nextTick(() => {
  96. this.$refs.pageRef?.loadData(bool, params);
  97. })
  98. },
  99. confirmReview() {
  100. uni.$u.http.post('/token/order/applyReview?orderId=' + this.order.orderId).then(res => {
  101. if (res.code == 200) {
  102. this.reviewMsg = res.data || '申请复审成功'
  103. this.$refs.processDialog.openPopup()
  104. } else if (res.code == 1001 || res.code == 1002) {
  105. this.$refs.errorDialog.openPopup()
  106. this.errorMsg = res.msg || '您的订单已下架或出库,无法为您提供复审服务,给您带来的不便深感抱歉'
  107. } else {
  108. this.errorMsg = res.data || '申请复审失败'
  109. }
  110. })
  111. },
  112. handleSuccess() {
  113. this.loadOrders(true, this.params)
  114. },
  115. handleTabChange(index) {
  116. this.currentTab = index
  117. this.params.status = this.tabList[index].status
  118. this.loadOrders(true, this.params)
  119. },
  120. handleUpdateList(list) {
  121. this.orderList = list
  122. },
  123. // 订单操作方法
  124. handleCancel(order) {
  125. uni.showModal({
  126. title: '提示',
  127. content: '确定要取消该订单吗?',
  128. success: (res) => {
  129. if (res.confirm) {
  130. // 调用取消订单接口
  131. }
  132. }
  133. })
  134. },
  135. handleReport(order) {
  136. uni.navigateTo({
  137. url: `/pages/order/report?orderNo=${order.orderNo}`
  138. })
  139. },
  140. handleEditAddress(order) {
  141. uni.navigateTo({
  142. url: `/pages/order/address?orderNo=${order.orderNo}`
  143. })
  144. },
  145. handleRemind(order) {
  146. uni.showToast({
  147. title: '已提醒审核',
  148. icon: 'none'
  149. })
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. .order-page {
  156. min-height: 100vh;
  157. background-color: #F5F5F5;
  158. .tabs-wrapper {
  159. position: sticky;
  160. top: 0;
  161. z-index: 99;
  162. background: #FFFFFF;
  163. }
  164. }
  165. </style>