ソースを参照

feat: 订单详情支持兼容orderNo传参

叶静 3 週間 前
コミット
5b8a5923a2

+ 14 - 3
src/pages/myOrders/orderDetail.vue

@@ -27,6 +27,7 @@ defineOptions({
 const paging = ref(null)
 
 const id = ref<any>()
+const orderNo = ref<string>()
 const isPayOrder = ref<boolean>(false)
 const detail = ref<any>({})
 const orderStatusEnumData = ref<any>([])
@@ -107,9 +108,15 @@ async function getDetail() {
     title: t('orderDetail.loading'),
   })
   try {
-    const res = await orderDetail({ id: id.value })
+    // 根据参数类型构建请求参数
+    const params = orderNo.value ? { orderNo: orderNo.value } : { id: id.value }
+    const res = await orderDetail(params)
     if (res.code === '200') {
       detail.value = res.data
+      // 如果通过 orderNo 查询,更新 id 值用于其他接口调用
+      if (orderNo.value && detail.value?.orderId) {
+        id.value = detail.value.orderId
+      }
       if (detail.value?.status === 1) {
         startCountdown() // 开始倒计时
         // if (isPayOrder.value) {
@@ -269,8 +276,12 @@ onLoad(async (options) => {
   getConfig('open_red_envelope_rate')
   getConfig('join_red_envelope_rate')
   const params = getPageParams(options)
-  id.value = params.id
-  isPayOrder.value = params.isPayOrder
+
+  // 兼容 id 和 orderNo 两种传参方式,优先使用 JSON 参数,其次使用直接参数
+  orderNo.value = params.orderNo || options.orderNo
+  id.value = params.id || options.id
+
+  isPayOrder.value = params.isPayOrder || options.isPayOrder
   await getOrderStatus()
 })
 const balance = ref<number>(0)

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

@@ -187,7 +187,7 @@ function handleNoticeClick(item: any) {
     const config = contentTypeMap[item.noticeType]
     const link = config?.link
     if (link) {
-      toPage(link, typeMap.order.includes(item.noticeType) ? { id: item.noticeMessage } : {})
+      toPage(link, typeMap.order.includes(item.noticeType) ? { orderNo: item.noticeMessage } : {})
     }
   }
 }