Przeglądaj źródła

fix(threePay): 优化支付流程的异常处理和金额显示

- 清空 token 值,防止旧数据影响支付流程
- 在支付请求失败时捕获错误并打印日志
- 支付失败时跳转结果页,传递错误信息进行显示
- 结果页中增加错误信息展示,替代固定的支付超时提示
- 金额显示统一除以100并格式化为两位小数
- 清理 manifest.json 尾部多余空行
- 注释保留 H5 服务器配置,方便开发环境切换
zhangtao 1 tydzień temu
rodzic
commit
a11bef81d0

+ 2 - 2
src/config/index.ts

@@ -46,9 +46,9 @@ function handleEnvVersion() {
   // #ifdef H5
   const mode = import.meta.env.MODE
   const h5Server = {
-    // development: 'http://47.109.84.152:8081',
+    development: 'http://47.109.84.152:8081',
     // development: 'http://192.168.0.157:8080',
-    development: 'http://192.168.0.11:8081',
+    // development: 'http://192.168.0.11:8081',
     // development: 'http://192.168.1.21:8080',
     // development: 'https://smqjh.api.zswlgz.com',
     // production: 'https://smqjh.api.zswlgz.com',

+ 7 - 2
src/subPack-common/threePay/index.vue

@@ -10,6 +10,7 @@ const orderNumber = ref()
 onLoad((options: any) => {
   orderNumber.value = options.orderNumber
   tenantCode.value = options.tenantCode
+  token.value = ''
   handleLogin(options.phone)
   console.log(options, '============options=======')
 })
@@ -41,6 +42,7 @@ function handleLogin(phoneCode: string) {
 async function handlePay() {
   const res = await useUserStore().handleCommonPayMent(orderNumber.value)
   priceInfo.value = res
+  console.log(priceInfo.value, '=========================')
 }
 async function handleGoPay() {
   if (priceInfo.value?.payType !== 1) {
@@ -48,7 +50,10 @@ async function handleGoPay() {
       await useUserStore().getWxCommonPayment(priceInfo.value as wxpay)
       router.push({ name: 'common-threePayRes', params: { price: String(priceInfo.value?.price), type: '1' } })
     }
-    catch {
+    catch (error: any) {
+      console.log(error, '=========================')
+
+      router.push({ name: 'common-threePayRes', params: { price: String(priceInfo.value?.price), type: '0', error: error.errMsg } })
       // console.log(111)
     }
   }
@@ -119,7 +124,7 @@ onUnload(() => {
 
 <template>
   <view>
-    <wd-navbar title="支付" :bordered="false" :z-index="99" placeholder safe-area-inset-top fixed />
+    <wd-navbar title="支付" :bordered="false" :z-index="99" safe-area-inset-top placeholder fixed />
     <view v-if="priceInfo" class="px20rpx pt20rpx">
       <view class="text-center text-48rpx text-#FF4A39">
         ¥{{ (priceInfo?.price / 100).toFixed(2) }}

+ 8 - 3
src/subPack-common/threePayRes/index.vue

@@ -12,9 +12,14 @@ definePage({
 })
 const price = ref()
 const type = ref(0) // 1支付成功,0支付失败
+const error = ref('支付超时')
+
 onLoad((options: any) => {
   price.value = options.price
-  type.value = options.type
+  if (options.error) {
+    error.value = options.error
+  }
+  type.value = Number(options.type)
 })
 function handleClose() {
   // 关闭当前小程序
@@ -41,11 +46,11 @@ function handleClose() {
           {{ type === 1 ? '支付成功' : '支付失败' }}
         </view>
         <view v-if="type == 0" class="mt20rpx text-24rpx text-#AAAAAA">
-          失败原因:支付超时
+          失败原因:{{ error }}
         </view>
         <view v-else class="mt20rpx text-24rpx text-#AAAAAA">
           实付金额:<text class="text-32rpx text-#FF4A39">
-            ¥{{ price }}
+            ¥{{ (price / 100).toFixed(2) }}
           </text>
         </view>
         <view class="mt60rpx flex items-center">