Forráskód Böngészése

```
feat(charge): 更新充电桩连接器ID类型为字符串并优化充电流程

- 将connectorId从number类型改为string类型
- 修复充电启动时连接器ID字段映射错误的问题
- 优化充电中页面的状态处理逻辑
- 添加充电加载组件提升用户体验
- 修复订单跳转路径参数传递问题
- 使用router.replace替代router.push避免历史记录堆积

fix(xsb): 完善支付失败处理逻辑并添加调试日志

- 在支付失败回调中调用payError函数进行统一处理
- 添加支付失败日志便于问题排查

refactor: 提取订单列表组件并支持多业务类型

- 新增通用订单列表组件支持XSB和充电两种业务类型
- 统一订单状态显示和操作按钮逻辑
- 优化订单详情跳转处理
```

zouzexu 3 napja
szülő
commit
1299ed2f8b

+ 1 - 1
src/api/api.type.d.ts

@@ -1800,7 +1800,7 @@ namespace Api {
     /**
      * 充电设备接口编码
      */
-    connectorId?: number
+    connectorId?: string
     /**
      * 用户昵称
      */

+ 3 - 3
src/subPack-charge/chargeStart/chargeStart.vue

@@ -36,7 +36,7 @@ async function getConnectorDetail() {
 const fromData = ref<Api.invokeChargeList>({
   equipmentId: 0,
   stationId: 0,
-  connectorId: 0,
+  connectorId: '',
   consigneeName: userInfo.value?.nickName,
   consigneeMobile: userInfo.value?.mobile,
 })
@@ -45,10 +45,10 @@ async function launchCharge() {
   // return
   fromData.value.equipmentId = connectorDetailInfo.value?.equipmentId
   fromData.value.stationId = connectorDetailInfo.value?.stationId
-  fromData.value.connectorId = connectorDetailInfo.value?.connectorId
+  fromData.value.connectorId = connectorDetailInfo.value?.connectorCode
   const res = await Apis.charge.invokeCharge({ data: fromData.value })
   if (res.code === '00000') {
-    router.push({ name: 'chargeing', params: { orderNo: res.data.orderNo } })
+    router.push({ name: 'chargeing', params: { orderNo: res.data } })
   }
 }
 </script>

+ 10 - 4
src/subPack-charge/chargeing/chargeing.vue

@@ -1,5 +1,6 @@
 <script setup lang="ts">
 import wlpProgress from '../components/wlp-progress-new/wlp-progress-new.vue'
+import chargeLoading from '../components/charge-loading.vue'
 import router from '@/router'
 import { StaticUrl } from '@/config'
 
@@ -41,6 +42,11 @@ onPageScroll((e) => {
 async function getChargeingCost() {
   const res = await Apis.charge.chargeingCost({ data: { orderNo: orderNo.value } })
   chargeingDetail.value = res.data
+  if (chargeingDetail.value?.status === '2') {
+    pause()
+    clearInterval(longPressTimer.value)
+    router.replace({ name: 'smqjh-order' })
+  }
 }
 
 function onTouchStart() {
@@ -77,7 +83,7 @@ async function initiatedStopCharge() {
     useGlobalToast().success('停止充电成功')
     stopCharge.value = false // 关闭弹窗
     current.value = 0
-    router.push({ name: 'smqjh-order' })
+    router.replace({ name: 'smqjh-order' })
   }
   useGlobalLoading().close()
 }
@@ -99,13 +105,13 @@ onUnmounted(() => {
       :z-index="999" safe-area-inset-top left-arrow fixed @click-left="router.back()"
     />
     <view :style="{ paddingTop: `${(Number(statusBarHeight) || 44) + MenuButtonHeight + 12}px` }" />
-    <!-- <view v-if="!chargeingDetail">
+    <view v-if="!chargeingDetail">
       <charge-loading />
-    </view> -->
+    </view>
     <view v-if="chargeingDetail?.status == '1'">
       <view class="flex items-center justify-center">
         <wlpProgress
-          :percent="75"
+          :percent="chargeingDetail?.soc"
           bg-color="#ebffb2"
           progress-color="#CCF35F"
           gradual-color="#9ED605"

+ 158 - 0
src/subPack-smqjh/components/orderList.vue

@@ -0,0 +1,158 @@
+<script setup lang="ts">
+import { StaticUrl } from '@/config'
+import router from '@/router'
+
+const props = defineProps<{
+  orderList: Api.xsbOrderList[]
+  type: 'XSB' | 'CHARGE'
+  subPackOrder?: typeof import('@/subPack-xsb/utils/order-data')
+  subPackConfirm?: typeof import('@/subPack-xsb/utils/confirm-order')
+}>()
+
+const _emit = defineEmits<{
+  'cancel': [order: Api.xsbOrderList]
+  'pay': [orderNumber: string]
+  'submit': [order: Api.xsbOrderList]
+  'del': [order: Api.xsbOrderList]
+  'after-sale': [item: Api.xsbOrderList]
+  'refresh': []
+}>()
+
+function handleClick(no: string) {
+  if (props.type === 'XSB') {
+    router.push({ name: 'xsb-orderDetaile', params: { id: no } })
+  }
+  else {
+    router.push({ name: 'charge-order-detail' })
+  }
+}
+</script>
+
+<template>
+  <view v-for="item in orderList" :key="item.orderNumber" class="mt20rpx rounded-16rpx bg-white p24rpx">
+    <!-- 通用头部 -->
+    <view class="flex items-center justify-between">
+      <view class="flex items-center">
+        <image :src="`${StaticUrl}/order-icon.png`" class="h36rpx w36rpx" />
+        <view class="ml20rpx text-32rpx font-semibold">
+          {{ item.shopName }}
+        </view>
+      </view>
+      <view class="text-24rpx" :class="props.type === 'XSB' ? 'text-#FF4D3A' : 'text-#4EDC86'">
+        <template v-if="props.type === 'XSB' && item.hbOrderStatus !== props.subPackOrder?.OrderStatus.PaddingPay">
+          {{ props.subPackOrder?.handleCommonOrderStatusText(item) }}
+        </template>
+        <template v-else-if="props.type === 'XSB'">
+          <view class="flex items-center">
+            待支付( 还剩 <wd-count-down :time="props.subPackOrder?.handleCommonOrderStatusText(item)" @finish="$emit('refresh')" /> )
+          </view>
+        </template>
+        <template v-else>
+          {{ props.subPackOrder?.handleCommonOrderStatusText(item) }}
+        </template>
+      </view>
+    </view>
+    <view class="my24rpx h2rpx w-full bg-#F0F0F0" />
+
+    <!-- XSB 特定内容 -->
+    <template v-if="props.type === 'XSB'">
+      <view
+        class="box-border h176rpx w-full flex items-center justify-between rounded-16rpx bg-#F9F9F9"
+        @click="handleClick(item.orderNumber as string)"
+      >
+        <view class="box-border h-full w480rpx py28rpx pl20rpx">
+          <scroll-view scroll-x class="h-full w-full whitespace-nowrap">
+            <view class="flex items-center">
+              <view v-for="goods in item.orderItemList" :key="goods.skuId" class="mr50rpx">
+                <image :src="goods.pic" class="h120rpx w120rpx" />
+              </view>
+            </view>
+          </scroll-view>
+        </view>
+        <view class="box-shadow box-border h-full flex-1 flex-shrink-0 px14rpx py40rpx">
+          <view class="text-center text-32rpx text-#FF4D3A font-semibold">
+            ¥{{ item.actualTotal }}
+          </view>
+          <view class="text-center text-28rpx text-#AAAAAA">
+            共{{ item.goodsTotal }}件
+          </view>
+        </view>
+      </view>
+    </template>
+
+    <!-- CHARGE 特定内容 -->
+    <template v-else>
+      <view class="flex items-center justify-between" @click="handleClick(item.orderNumber as string)">
+        <view>
+          <view class="text-28rpx font-bold">
+            {{ item.shopName }}
+          </view>
+          <view class="mt-20rpx text-24rpx text-#AAA">
+            订单时间:{{ item.createTime || '未知' }}
+          </view>
+          <view class="mt-20rpx text-24rpx text-#AAA">
+            终端名称:{{ item.orderItemList?.[0]?.goodsName || '未知' }}
+          </view>
+        </view>
+        <view class="text-28rpx text-#4EDC86">
+          {{ props.subPackOrder?.handleCommonOrderStatusText(item) }}
+        </view>
+      </view>
+      <wd-divider />
+      <view class="flex items-center justify-between">
+        <view class="text-28rpx">
+          充电费用:
+        </view>
+        <view class="text-32rpx text-#FF6464 font-800">
+          <text class="text-18rpx">
+            ¥
+          </text>
+          {{ item.actualTotal }}
+        </view>
+      </view>
+    </template>
+
+    <!-- XSB 按钮 -->
+    <view v-if="props.type === 'XSB'" class="my24rpx flex items-center justify-end">
+      <template v-if="item.hbOrderStatus === props.subPackOrder?.OrderStatus.PaddingPay">
+        <view class="mr20rpx">
+          <wd-button size="small" plain type="info" @click.stop="$emit('cancel', item)">
+            取消订单
+          </wd-button>
+        </view>
+        <view class="mr20rpx">
+          <wd-button size="small" plain type="error" @click.stop="$emit('pay', item.orderNumber as string)">
+            付款
+          </wd-button>
+        </view>
+      </template>
+      <template v-if="[props.subPackOrder?.OrderStatus.OrderCancel, props.subPackOrder?.OrderStatus.OrderCompleted].includes(item.hbOrderStatus)">
+        <view class="mr20rpx">
+          <wd-button size="small" plain type="info" @click.stop="$emit('del', item)">
+            删除订单
+          </wd-button>
+        </view>
+      </template>
+      <template v-if="item.hbOrderStatus === props.subPackOrder?.OrderStatus.OrderArrived">
+        <view class="mr20rpx">
+          <wd-button size="small" plain type="info" @click.stop="$emit('submit', item)">
+            确认收货
+          </wd-button>
+        </view>
+      </template>
+      <template v-if="item.refundStatus != 2 || [props.subPackOrder?.OrderStatus.OrderCompleted, props.subPackOrder?.OrderStatus.OrderWaitDelivery, props.subPackOrder?.OrderStatus.OrderAccepted].includes(item.hbOrderStatus)">
+        <view class="mr20rpx">
+          <wd-button size="small" plain type="info" @click.stop="$emit('after-sale', item)">
+            申请售后
+          </wd-button>
+        </view>
+      </template>
+    </view>
+  </view>
+</template>
+
+<style lang="scss" scoped>
+.box-shadow {
+  box-shadow: -6rpx 0rpx 6rpx 2rpx rgba(0, 0, 0, 0.04);
+}
+</style>

+ 3 - 1
src/subPack-xsb/utils/confirm-order.ts

@@ -85,7 +85,7 @@ export function getWxCommonPayment(orderPay: wxpay) {
       },
       fail(e) {
         console.log(e, '失败')
-
+        payError()
         reject(e)
       },
       complete() {
@@ -115,6 +115,8 @@ export function paySuccess() {
  * 支付成功统一跳转
  */
 export function payError() {
+  console.log('进入支付失败')
+
   return new Promise((resolve) => {
     const { paySuccessPath, payBackIndexPath } = storeToRefs(useSysStore())
     paySuccessPath.value = 'xsb-order'