apply-return.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 v-if="currentTab == 0" :page-size="12" @updateList="handleUpdateList" ref="pageRef" slotEmpty
  10. url="/token/order/refundOrderList" :immediate="false">
  11. <view v-if="orderList.length > 0" class="pad-20">
  12. <order-return-item v-for="order in orderList" :key="order.orderId" :order="order"
  13. @action="handleAction"></order-return-item>
  14. </view>
  15. </page-scroll>
  16. <page-scroll v-if="currentTab == 1" :page-size="12" @updateList="handleUpdateList" ref="pageRef" slotEmpty
  17. url="/token/order/canRefundOrderList" :immediate="false">
  18. <view v-if="orderList.length > 0" class="pad-20">
  19. <order-return-item v-for="order in orderList" :key="order.orderId" :order="order"
  20. :showAction="false" @click="handleItemClick(order)"></order-return-item>
  21. </view>
  22. </page-scroll>
  23. <common-dialog ref="dialog" :title="dialogTitle" @confirm="handleConfirm">{{ dialogContent }}</common-dialog>
  24. </view>
  25. </template>
  26. <script>
  27. import pageScroll from '@/components/pageScroll/index.vue'
  28. import OrderReturnItem from '../components/order-return-item.vue'
  29. import CommonDialog from '@/components/common-dialog.vue'
  30. export default {
  31. components: {
  32. pageScroll,
  33. OrderReturnItem,
  34. CommonDialog
  35. },
  36. data() {
  37. return {
  38. tabList: [{
  39. name: '已申请'
  40. },
  41. {
  42. name: '可退回'
  43. },
  44. ],
  45. currentTab: 0,
  46. orderList: [],
  47. requestUrl: '/token/order/refundOrderList',
  48. refundUrl: '/token/order/refundOrderList',
  49. canRefundUrl: '/token/order/canRefundOrderList',
  50. dialogTitle: '提示',
  51. dialogContent: '',
  52. actionType: '',
  53. orderInfo: {} // 订单信息
  54. }
  55. },
  56. onLoad(options) {
  57. // 如果有传入状态,切换到对应tab
  58. this.refreshList()
  59. },
  60. onShow(){
  61. this.refreshList()
  62. },
  63. methods: {
  64. refreshList() {
  65. this.requestUrl = this.currentTab == 0 ? this.refundUrl : this.canRefundUrl
  66. this.$refs.pageRef?.loadData(true)
  67. },
  68. handleTabChange(index) {
  69. this.currentTab = index
  70. this.$nextTick(() => {
  71. this.$refs.pageRef?.loadData(true)
  72. })
  73. },
  74. handleUpdateList(list) {
  75. this.orderList = list
  76. console.log(this.orderList, 'list')
  77. },
  78. //操作按钮
  79. handleAction({ type, order }) {
  80. this.actionType = type
  81. this.orderInfo = order
  82. console.log(type, order, 'action')
  83. switch (type) {
  84. case 'cancel':
  85. this.dialogContent = '确定取消退回?'
  86. this.$refs.dialog?.openPopup()
  87. break;
  88. case 'confirm':
  89. this.dialogContent = '确定收货?'
  90. this.$refs.dialog?.openPopup()
  91. break;
  92. }
  93. },
  94. //取消退回
  95. handleCancel() {
  96. let { refundOrderId, orderId } = this.orderInfo
  97. uni.$u.http.post('/token/order/refundOrderCancel', {
  98. refundOrderId: orderId || refundOrderId,
  99. }).then(res => {
  100. if (res.code === 200) {
  101. uni.$u.toast('取消退回成功')
  102. this.$refs.pageRef.loadData(true)
  103. } else {
  104. uni.$u.toast(res.msg)
  105. }
  106. })
  107. },
  108. //确认收货
  109. handleConfirmReceipt() {
  110. let { refundOrderId, orderId } = this.orderInfo
  111. uni.$u.http.post('/token/order/refundOrderFinish', {
  112. refundOrderId: orderId || refundOrderId
  113. }).then(res => {
  114. if (res.code === 200) {
  115. uni.$u.toast('确认收货成功')
  116. this.$refs.pageRef.loadData(true)
  117. } else {
  118. uni.$u.toast(res.msg)
  119. }
  120. })
  121. },
  122. //弹窗确认按钮
  123. handleConfirm() {
  124. console.log('confirm')
  125. switch (this.actionType) {
  126. case 'cancel':
  127. this.handleCancel()
  128. break;
  129. case 'confirm':
  130. this.handleConfirmReceipt()
  131. break;
  132. }
  133. },
  134. handleItemClick(order) {
  135. // 从可退回tab点击时,带上fromCanReturn参数
  136. if (this.currentTab === 1) {
  137. uni.navigateTo({
  138. url: `/pages-mine/pages/return-detail?orderId=${order.orderId}`
  139. })
  140. } else {
  141. uni.navigateTo({
  142. url: `/pages-mine/pages/return-detail?orderId=${order.orderId}`
  143. })
  144. }
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .order-page {
  151. min-height: 100vh;
  152. background-color: #F5F5F5;
  153. .tabs-wrapper {
  154. position: sticky;
  155. top: 0;
  156. z-index: 99;
  157. background: #FFFFFF;
  158. }
  159. }
  160. </style>