Selaa lähdekoodia

feat: 请求头中增加多语言入参、详情待支付去支付功能增加

liangan 1 kuukausi sitten
vanhempi
sitoutus
5559f2060f
2 muutettua tiedostoa jossa 22 lisäystä ja 43 poistoa
  1. 1 1
      src/interceptors/request.ts
  2. 21 42
      src/pages/myOrders/orderDetail.vue

+ 1 - 1
src/interceptors/request.ts

@@ -90,7 +90,7 @@ const httpInterceptor = {
       platform, // 可选,与 uniapp 定义的平台一致,告诉后台来源
       ...options.header,
     }
-    options.header['Accept-Language'] = i18n.global.locale
+    options.header.language = i18n.global.locale
     // 判断是否为登录接口
     const isLoginApi = options.url?.includes('/login') || options.url?.includes('/register')
 

+ 21 - 42
src/pages/myOrders/orderDetail.vue

@@ -10,10 +10,9 @@
 
 <script lang="ts" setup>
 import { getConfigByCode } from '@/api/common'
-import { bindingAddress, orderCancel, orderDetail, orderPink, orderStatusEnum } from '@/api/order'
+import { orderCancel, orderDetail, orderPink, orderStatusEnum, payOrder } from '@/api/order'
 import DialogBox from '@/components/DialogBox/DialogBox.vue'
 import { DialogUtils } from '@/components/DialogBox/utils'
-import { t } from '@/locale'
 import { formatNumber } from '@/utils'
 import { getPageParams, toPage } from '@/utils/page'
 import { toast } from '@/utils/toast'
@@ -107,36 +106,6 @@ function selectAddress() {
   })
 }
 
-// 绑定地址到订单
-async function bindAddressToOrder(addressId: number) {
-  try {
-    uni.showLoading({
-      title: t('addressBook.select.binding'),
-    })
-
-    const res = await bindingAddress({
-      orderId: id.value,
-      addressId,
-    })
-
-    if (res.code === '200') {
-      toast.success(t('addressBook.select.success'))
-      // 刷新订单详情
-      getDetail()
-    }
-    else {
-      toast.error(res.message || t('addressBook.select.failed'))
-    }
-  }
-  catch (error: any) {
-    console.error('Bind address error:', error)
-    toast.error(t('addressBook.select.networkError'))
-  }
-  finally {
-    uni.hideLoading()
-  }
-}
-
 // 显示取消订单确认对话框
 function showCancelOrderDialog() {
   Object.assign(dialogConfig.value, DialogUtils.info(
@@ -191,19 +160,27 @@ function handleDialogConfirm() {
   }
 
   // 关闭对话框
-  handleDialogCancel()
-}
-
-// 处理对话框取消事件
-function handleDialogCancel() {
-  // 关闭对话框
-  dialogConfig.value.show = false
+  handleDialogClose()
 }
 
 // 处理对话框关闭事件
 function handleDialogClose() {
   dialogConfig.value.show = false
 }
+
+async function handleClick() {
+  if (detail.value?.status === 1) {
+    // 去支付
+    const payRes = await payOrder({
+      orderId: detail.value?.orderId,
+      type: detail.value?.storePink?.kId ? 'open' : 'join',
+    })
+    console.log(payRes)
+  }
+  else {
+    // 去分享
+  }
+}
 </script>
 
 <template>
@@ -233,7 +210,7 @@ function handleDialogClose() {
         </view>
         <!-- 未开奖||未支付 -->
         <view v-else-if="detail?.storePink?.status === 1 || detail?.status === 1" class="mb-20rpx bg-#fff py-20rpx text-center text-28rpx text-white">
-          <text v-if="detail?.storePink?.status === 1" class="text-[var(--wot-color-theme)]">
+          <text v-if="detail?.storePink?.status === 1 && detail?.status !== 1" class="text-[var(--wot-color-theme)]">
             Please wait for the draw of this group
           </text>
           <text v-else class="text-[var(--wot-color-theme)]">
@@ -355,7 +332,9 @@ function handleDialogClose() {
         >
           Cancel
         </wd-button>
-        <wd-button>Share Now</wd-button>
+        <wd-button @click="handleClick">
+          {{ detail?.status !== 1 ? 'Share Now' : 'Pay Now' }}
+        </wd-button>
       </view>
     </template>
 
@@ -363,7 +342,7 @@ function handleDialogClose() {
     <DialogBox
       v-bind="dialogConfig"
       @confirm="handleDialogConfirm"
-      @cancel="handleDialogCancel"
+      @cancel="handleDialogClose"
       @close="handleDialogClose"
     />
   </z-paging>