index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <script setup lang="ts">
  2. import { getWxCommonPayment, handleCommonPayMent } from '../utils/confirm-order'
  3. import { OrderStatus, handleCommonCancelOrder, handleCommonDeleteOrder, handleCommonOrderReceive, handleCommonOrderStatusText, navTabTypeList, orderStatusList } from '../utils/order-data'
  4. import { createGlobalLoadingMiddleware } from '@/api/core/middleware'
  5. import { StaticUrl } from '@/config'
  6. import router from '@/router'
  7. definePage({
  8. name: 'xsb-order',
  9. islogin: true,
  10. style: {
  11. navigationBarTitleText: '订单列表',
  12. },
  13. })
  14. const navActiveTab = ref(0)
  15. const orderStatusActive = ref('all') // 我的订单 all-全部 paddingPay-待支付 ing-进行中 completed-已完成 cancel-已取消
  16. const { data: orderList, refresh, isLastPage, page, reload } = usePagination((pageNum, pageSize) => Apis.xsb.orderList({ data: {
  17. businessType: 'XSB',
  18. orderStatus: unref(orderStatusActive),
  19. pageNum,
  20. pageSize,
  21. dvyType: unref(navActiveTab) === 0 ? '' : unref(navActiveTab),
  22. } }), {
  23. immediate: false,
  24. pageNum: 1,
  25. pageSize: 10,
  26. initialData: [],
  27. data: res => res.data?.list,
  28. append: true,
  29. middleware: createGlobalLoadingMiddleware(),
  30. })
  31. function handleChangeTypeNav(value: number) {
  32. navActiveTab.value = value
  33. console.log(navActiveTab.value, '===============')
  34. orderList.value = []
  35. reload()
  36. }
  37. function handleChangeStatus(value: string) {
  38. orderStatusActive.value = value
  39. orderList.value = []
  40. reload()
  41. }
  42. function handleClick(item: Api.xsbOrderList) {
  43. router.push({ name: 'xsb-orderDetaile', params: { id: String(item.orderNumber) } })
  44. }
  45. onReachBottom(() => {
  46. if (!isLastPage.value) {
  47. page.value++
  48. }
  49. })
  50. onShow(() => {
  51. refresh()
  52. })
  53. async function handlePay(orderNumber: string) {
  54. const res = await handleCommonPayMent(orderNumber)
  55. if (res.payType !== 1) {
  56. await getWxCommonPayment(res)
  57. }
  58. else {
  59. reload()
  60. }
  61. }
  62. async function handleCancel(order: Api.xsbOrderList) {
  63. await handleCommonCancelOrder(order)
  64. reload()
  65. }
  66. async function handleDel(order: Api.xsbOrderList) {
  67. await handleCommonDeleteOrder(order)
  68. reload()
  69. }
  70. async function handleSubmitOrder(order: Api.xsbOrderList) {
  71. await handleCommonOrderReceive(order)
  72. reload()
  73. }
  74. async function handleAfterSale(item: Api.xsbOrderList) {
  75. if (!item.orderItemList) {
  76. useGlobalToast().show('商品异常!')
  77. return
  78. }
  79. await useSysStore().getRefunOrder(item.orderNumber as string)
  80. }
  81. </script>
  82. <template>
  83. <view class="page-xsb">
  84. <view class="nav sticky top-0 z10 bg-white px24rpx py18rpx">
  85. <view class="h80rpx flex items-center">
  86. <view
  87. v-for="item in navTabTypeList" :key="item.value" class="mr64rpx h-full flex flex-col items-center justify-center text-32rpx"
  88. :class="[navActiveTab == item.value ? 'font-semibold ' : 'text-#AAAAAA']"
  89. @click="handleChangeTypeNav(item.value)"
  90. >
  91. {{ item.name }}
  92. <view
  93. class="mt10rpx bg-[var(--them-color)] transition-all transition-duration-400 ease-in"
  94. :class="[navActiveTab == item.value ? 'w40rpx h8rpx rounded-4rpx' : '']"
  95. />
  96. </view>
  97. </view>
  98. <view class="mt20rpx flex items-center">
  99. <view
  100. v-for="item in orderStatusList" :key="item.value"
  101. class="mr16rpx rounded-24rpx bg-#F6F6F6 px16rpx py6rpx text-24rpx"
  102. :class="[orderStatusActive == item.value ? 'bg-[var(--them-color)] text-white' : '']"
  103. @click="handleChangeStatus(item.value)"
  104. >
  105. {{ item.name }}
  106. </view>
  107. </view>
  108. </view>
  109. <view class="px24rpx">
  110. <view v-for="item in orderList" :key="item.orderNumber" class="mt20rpx rounded-16rpx bg-white p24rpx">
  111. <view class="w-full flex items-center justify-between">
  112. <view class="flex items-center">
  113. <image :src="`${StaticUrl}/order-icon.png`" class="h36rpx w36rpx" />
  114. <view class="ml20rpx text-32rpx font-semibold">
  115. {{ item.shopName }}
  116. </view>
  117. </view>
  118. <view class="text-24rpx text-#FF4D3A">
  119. <template v-if="item.hbOrderStatus === OrderStatus.PaddingPay">
  120. <view class="flex items-center">
  121. 待支付( 还剩 <wd-count-down :time="handleCommonOrderStatusText(item)" @finish="refresh" /> )
  122. </view>
  123. </template>
  124. <text v-else>
  125. {{ handleCommonOrderStatusText(item) }}
  126. </text>
  127. </view>
  128. </view>
  129. <view class="my24rpx h2rpx w-full bg-#F0F0F0" />
  130. <view>
  131. <!-- <view class="mb20rpx box-border rounded-16rpx bg-#F9F9F9 p24rpx">
  132. <view class="flex items-center">
  133. <image :src="`${StaticUrl}/order-car.png`" class="h36rpx w36rpx" />
  134. <view class="ml20rpx text-28rpx text-#222 font-semibold">
  135. 预计10:40前可送达
  136. </view>
  137. </view>
  138. <view class="mt18rpx">
  139. 您的订单预计3月7日 10:40前送达
  140. </view>
  141. <view class="mt20rpx">
  142. 2025-03-26 11:56:07
  143. </view>
  144. </view> -->
  145. <view class="box-border h176rpx w-full flex items-center justify-between rounded-16rpx bg-#F9F9F9" @click="handleClick(item)">
  146. <view class="box-border h-full w480rpx py28rpx pl20rpx">
  147. <scroll-view scroll-x class="h-full w-full whitespace-nowrap">
  148. <view class="flex items-center">
  149. <view v-for="goods in item.orderItemList" :key="goods.skuId" class="mr50rpx">
  150. <image :src="goods.pic" class="h120rpx w120rpx" />
  151. </view>
  152. </view>
  153. </scroll-view>
  154. </view>
  155. <view class="box-shadow box-border h-full flex-1 flex-shrink-0 px14rpx py40rpx">
  156. <view class="text-center text-32rpx text-#FF4D3A font-semibold">
  157. ¥{{ item.actualTotal }}
  158. </view>
  159. <view class="text-center text-28rpx text-#AAAAAA">
  160. 共{{ item.goodsTotal }}件
  161. </view>
  162. </view>
  163. </view>
  164. </view>
  165. <view class="mt24rpx flex items-center justify-end">
  166. <template v-if="item.hbOrderStatus === OrderStatus.PaddingPay">
  167. <view class="mr20rpx">
  168. <wd-button size="small" plain type="info" @click.stop="handleCancel(item)">
  169. 取消订单
  170. </wd-button>
  171. </view>
  172. <view class="mr20rpx">
  173. <wd-button size="small" plain type="error" @click.stop="handlePay(item.orderNumber as string)">
  174. 付款
  175. </wd-button>
  176. </view>
  177. </template>
  178. <template v-if="[OrderStatus.OrderCancel, OrderStatus.OrderCompleted].includes(item.hbOrderStatus) ">
  179. <view class="mr20rpx">
  180. <wd-button size="small" plain type="info" @click.stop="handleDel(item)">
  181. 删除订单
  182. </wd-button>
  183. </view>
  184. <!-- <view class="ml20rpx">
  185. <wd-button size="small" plain type="error" @click.stop="handleDel(item)">
  186. 再次购买
  187. </wd-button>
  188. </view> -->
  189. </template>
  190. <template v-if="item.hbOrderStatus === OrderStatus.OrderArrived">
  191. <view class="mr20rpx">
  192. <wd-button size="small" plain type="info" @click.stop="handleSubmitOrder(item)">
  193. 确认收货
  194. </wd-button>
  195. </view>
  196. </template>
  197. <template v-if="item.refundStatus != 2 || [OrderStatus.OrderCompleted, OrderStatus.OrderWaitDelivery, OrderStatus.OrderAccepted].includes(item.hbOrderStatus) ">
  198. <view class="mr20rpx">
  199. <wd-button size="small" plain type="info" @click.stop="handleAfterSale(item)">
  200. 申请售后
  201. </wd-button>
  202. </view>
  203. </template>
  204. </view>
  205. </view>
  206. </view>
  207. <wd-status-tip v-if="!orderList.length" image="content" tip="暂无内容" />
  208. <view class="h-20rpx" />
  209. </view>
  210. </template>
  211. <style scoped lang="scss">
  212. .page-xsb {
  213. :deep() {
  214. .wd-button.is-plain.is-error {
  215. color: #FF4D3A !important;
  216. }
  217. .wd-count-down{
  218. color: #FF4D3A ;
  219. font-size: 700 !important;
  220. line-height: unset !important;
  221. }
  222. }
  223. .box-shadow {
  224. box-shadow: -6rpx 0rpx 6rpx 2rpx rgba(0, 0, 0, 0.04);
  225. }
  226. }
  227. </style>