Просмотр исходного кода

```
feat(api): 更新充电订单详情API类型定义

添加了充电功率、停止类型、终端编号和充电电费字段,
将原有的totalCharge字段重命名为totalPower以更准确表示充电功率数据

feat(charge): 完善充电订单详情页面功能

- 将总充电量字段从totalCharge更新为totalPower显示
- 添加停止类型的展示逻辑,根据stopMethod值显示对应停止方式描述
- 实现订单时长秒数转换为HH:mm:ss格式显示
- 添加终端编号和充电电费的数据显示
- 优化空值显示为'--'占位符

refactor(charge): 新增充电订单相关工具函数

- 添加stopType函数处理停止类型枚举值转换为中文描述
- 添加secondToTime函数实现秒数转时间格式功能
```

zouzexu 1 неделя назад
Родитель
Сommit
bf5c0e624c

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

@@ -2063,6 +2063,19 @@ namespace Api {
     /**
      * 实际充电度数(单位:0.001 kw/h)
      */
-    totalCharge?: number
+    totalPower?: number
+    /**
+     * 停止类型
+     */
+    stopMethod?: number
+    /**
+     * 终端编号
+     */
+    connectorId?: string
+    /**
+     * 充电电费
+     */
+    totalMoney?: number
+
   }
 }

+ 8 - 7
src/subPack-charge/chargeOrderDetail/chargeOrderDetail.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { chargeOrderStatus } from '../utils/index'
+import { chargeOrderStatus, secondToTime, stopType } from '../utils/index'
 import router from '@/router'
 import { StaticUrl } from '@/config'
 
@@ -52,7 +52,7 @@ async function getOrderDetail() {
           </view>
         </view>
         <view class="mt-20rpx text-28rpx text-#9ED605 font-bold">
-          {{ chargeOrderDetail?.totalCharge }}度电
+          {{ chargeOrderDetail?.totalPower }}度电
         </view>
       </view>
       <view class="mt-20rpx rounded-16rpx bg-#FFF p-24rpx">
@@ -77,7 +77,8 @@ async function getOrderDetail() {
             终止方式
           </view>
           <view class="mt-20rpx text-32rpx font-bold">
-            {{ '--' }}
+            <!-- 0:用户手动停止充电;1:客户归属地运营商平台停止充电;2:BMS停止充电;3:充电机设备故障;4:连接器断开;其它:自定义 -->
+            {{ stopType(chargeOrderDetail?.stopMethod) }}
           </view>
         </view>
       </view>
@@ -103,7 +104,7 @@ async function getOrderDetail() {
             订单时间
           </view>
           <view class="text-28rpx text-#AAA">
-            {{ chargeOrderDetail?.chargeTime }}
+            {{ secondToTime(Number(chargeOrderDetail?.chargeTime)) }}
           </view>
         </view>
         <view class="mt-28rpx flex items-center justify-between">
@@ -111,7 +112,7 @@ async function getOrderDetail() {
             充电电站
           </view>
           <view class="text-28rpx text-#AAA">
-            {{ chargeOrderDetail?.powerStationName }}
+            {{ chargeOrderDetail?.powerStationName || '--' }}
           </view>
         </view>
         <view class="mt-28rpx flex items-center justify-between">
@@ -119,7 +120,7 @@ async function getOrderDetail() {
             终端编号
           </view>
           <view class="text-28rpx text-#AAA">
-            {{ '--' }}
+            {{ chargeOrderDetail?.connectorId || '--' }}
           </view>
         </view>
         <view class="mt-28rpx flex items-center justify-between">
@@ -127,7 +128,7 @@ async function getOrderDetail() {
             电费
           </view>
           <view class="text-28rpx text-#AAA">
-            {{ '--' }}元
+            {{ chargeOrderDetail?.totalMoney }}元
           </view>
         </view>
         <view class="mt-28rpx flex items-center justify-between">

+ 36 - 0
src/subPack-charge/utils/index.ts

@@ -36,6 +36,42 @@ export function chargeOrderStatus(status: any) {
   return statusObj
 }
 
+/**
+ * 停止方式
+ * @param stopMethod
+ */
+export function stopType(stopMethod: any) {
+  // 0:用户手动停止充电;1:客户归属地运营商平台停止充电;2:BMS停止充电;3:充电机设备故障;4:连接器断开;其它:自定义
+  let stopText = ''
+  switch (stopMethod) {
+    case 0:
+      stopText = '用户手动停止充电'
+      break
+    case 1:
+      stopText = '客户归属地运营商平台停止充电'
+      break
+    case 2:
+      stopText = 'BMS停止充电'
+      break
+    case 3:
+      stopText = '充电机设备故障'
+      break
+    case 4:
+      stopText = '连接器断开'
+  }
+  return stopText
+}
+
+/**
+ * 秒转为时间格式
+ */
+export function secondToTime(second: number) {
+  const h = Math.floor(second / 3600)
+  const m = Math.floor((second - h * 3600) / 60)
+  const s = Math.floor(second - h * 3600 - m * 60)
+  return `${h < 10 ? `0${h}` : h}:${m < 10 ? `0${m}` : m}:${s < 10 ? `0${s}` : s}`
+}
+
 /**
  * 扫码工具类
  */