index.vue 6.8 KB

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