apply-return.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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)" :hasReturn="currentTab==1"></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.$nextTick(() => {
  67. this.$refs.pageRef?.loadData(true)
  68. })
  69. },
  70. handleTabChange(index) {
  71. this.currentTab = index
  72. this.$nextTick(() => {
  73. this.$refs.pageRef?.loadData(true)
  74. })
  75. },
  76. handleUpdateList(list) {
  77. this.orderList = list
  78. console.log(this.orderList, 'list')
  79. },
  80. //操作按钮
  81. handleAction({ type, order }) {
  82. this.actionType = type
  83. this.orderInfo = order
  84. console.log(type, order, 'action')
  85. switch (type) {
  86. case 'cancel':
  87. this.dialogContent = '确定取消退回?'
  88. this.$refs.dialog?.openPopup()
  89. break;
  90. case 'confirm':
  91. this.dialogContent = '确定收货?'
  92. this.$refs.dialog?.openPopup()
  93. break;
  94. }
  95. },
  96. //取消退回
  97. handleCancel() {
  98. let { refundOrderId, orderId } = this.orderInfo
  99. uni.$u.http.post('/token/order/refundOrderCancel', {
  100. refundOrderId: orderId || refundOrderId,
  101. }).then(res => {
  102. if (res.code === 200) {
  103. uni.$u.toast('取消退回成功')
  104. this.$refs.pageRef.loadData(true)
  105. } else {
  106. uni.$u.toast(res.msg)
  107. }
  108. })
  109. },
  110. //确认收货
  111. handleConfirmReceipt() {
  112. let { refundOrderId, orderId } = this.orderInfo
  113. uni.$u.http.post('/token/order/refundOrderFinish', {
  114. refundOrderId: orderId || refundOrderId
  115. }).then(res => {
  116. if (res.code === 200) {
  117. uni.$u.toast('确认收货成功')
  118. this.$refs.pageRef.loadData(true)
  119. } else {
  120. uni.$u.toast(res.msg)
  121. }
  122. })
  123. },
  124. //弹窗确认按钮
  125. handleConfirm() {
  126. console.log('confirm')
  127. switch (this.actionType) {
  128. case 'cancel':
  129. this.handleCancel()
  130. break;
  131. case 'confirm':
  132. this.handleConfirmReceipt()
  133. break;
  134. }
  135. },
  136. handleItemClick(order) {
  137. // 从可退回tab点击时,带上fromCanReturn参数
  138. if (this.currentTab === 1) {
  139. uni.navigateTo({
  140. url: `/pages-mine/pages/return-detail?orderId=${order.orderId}`
  141. })
  142. } else {
  143. uni.navigateTo({
  144. url: `/pages-mine/pages/return-detail?orderId=${order.orderId}`
  145. })
  146. }
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .order-page {
  153. min-height: 100vh;
  154. background-color: #F5F5F5;
  155. .tabs-wrapper {
  156. position: sticky;
  157. top: 0;
  158. z-index: 99;
  159. background: #FFFFFF;
  160. }
  161. }
  162. </style>