Преглед изворни кода

refactor(transition): 优化支付状态页面的倒计时与订单查询逻辑

- 移除无用的加载状态管理
- 添加倒计时组件显示剩余时间
- 完成倒计时后自动查询订单信息
- 根据订单信息跳转支付成功页或订单列表页
- 改进路由跳转逻辑,支持参数传递
- 优化页面提示文本,提高用户体验
- 修正单位显示错误,将"vipPrice"后缀从"L"改为"/L"
- 删除未使用的WdLoading组件声明
zhangtao пре 1 дан
родитељ
комит
0b9bb428c1
3 измењених фајлова са 38 додато и 20 уклоњено
  1. 0 1
      src/components.d.ts
  2. 1 1
      src/pages/index/index.vue
  3. 37 18
      src/pages/transition/index.vue

+ 0 - 1
src/components.d.ts

@@ -20,7 +20,6 @@ declare module 'vue' {
     WdCountDown: typeof import('wot-design-uni/components/wd-count-down/wd-count-down.vue')['default']
     WdGap: typeof import('wot-design-uni/components/wd-gap/wd-gap.vue')['default']
     WdIcon: typeof import('wot-design-uni/components/wd-icon/wd-icon.vue')['default']
-    WdLoading: typeof import('wot-design-uni/components/wd-loading/wd-loading.vue')['default']
     WdMessageBox: typeof import('wot-design-uni/components/wd-message-box/wd-message-box.vue')['default']
     WdNotify: typeof import('wot-design-uni/components/wd-notify/wd-notify.vue')['default']
     WdPopup: typeof import('wot-design-uni/components/wd-popup/wd-popup.vue')['default']

+ 1 - 1
src/pages/index/index.vue

@@ -102,7 +102,7 @@ watch(() => currentTab.value, () => {
                 <text class="text-20rpx">
                 </text> <text class="text-36rpx">
-                  {{ item.vipPrice }}L
+                  {{ item.vipPrice }}/L
                 </text>
               </view>
             </view>

+ 37 - 18
src/pages/transition/index.vue

@@ -1,4 +1,5 @@
 <script setup lang="ts">
+import type { OmsOrder } from '@/api/globals'
 import router from '@/router'
 
 definePage({
@@ -10,39 +11,57 @@ definePage({
   },
 })
 
-const loading = ref(true)
-const payStatus = ref(0)
+const orderNo = ref('')
+const orderInfo = ref<OmsOrder>()
+const countdownTime = ref(3000) // 3秒倒计时
 
-onLoad((options: any) => {
-  if (options.payStatus) {
-    payStatus.value = Number(options.payStatus)
+// 倒计时结束后查询订单
+async function handleCountdownFinish() {
+  if (!orderNo.value) {
+    goToOrderList()
+    return
   }
-  const outerOrderId = options.outerOrderId || ''
 
-  // 延迟跳转,显示 loading 效果
-  setTimeout(() => {
-    loading.value = false
+  try {
+    const res = await Apis.general.get_smqjh_oms_api_v1_order_orderinfo({
+      params: { orderNo: orderNo.value },
+    })
+    orderInfo.value = res.data
 
-    if (payStatus.value === 1) {
-      // 支付成功,跳转支付成功页
+    // 有订单数据则跳转支付成功页
+    if (orderInfo.value?.orderNumber) {
       router.replace({
         name: 'paySuccess',
-        params: { outerOrderId },
+        params: { outerOrderId: orderNo.value },
       })
     }
     else {
-      router.pushTab({ name: 'order' })
-      useTabbar().setTabbarItemActive('order')
+      goToOrderList()
     }
-  }, 3000)
+  }
+  catch {
+    goToOrderList()
+  }
+}
+
+function goToOrderList() {
+  router.pushTab({ name: 'order' })
+  useTabbar().setTabbarItemActive('order')
+}
+
+onLoad((options: any) => {
+  orderNo.value = options.outerOrderId || ''
 })
 </script>
 
 <template>
   <view class="min-h-100vh flex flex-col items-center justify-center bg-#f5f5f5">
-    <wd-loading v-if="loading" size="64rpx" />
-    <view v-if="loading" class="mt24rpx text-28rpx text-#999">
-      正在处理中... {{ payStatus }}
+    <view class="text-32rpx text-#333">
+      正在处理中,请稍候...
+    </view>
+    <view class="mt24rpx flex items-center text-28rpx text-#999">
+      <wd-count-down :time="countdownTime" format="ss" @finish="handleCountdownFinish" />
+      <text>秒后跳转</text>
     </view>
   </view>
 </template>