|
|
@@ -1,5 +1,5 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { formatStatusName } from '../utils/index'
|
|
|
+import { ScanCodeUtil, formatStatusName } from '../utils/index'
|
|
|
import router from '@/router'
|
|
|
import { StaticUrl } from '@/config'
|
|
|
|
|
|
@@ -64,6 +64,31 @@ function getTabStyle(tab: string) {
|
|
|
? { background: '#9ED605', color: '#FFF' }
|
|
|
: {}
|
|
|
}
|
|
|
+async function getDeviceInfo(connectorCode: string) {
|
|
|
+ useGlobalLoading().loading({})
|
|
|
+ const res = await Apis.charge.connectorDetail({ data: { connectorCode } })
|
|
|
+ useGlobalLoading().close()
|
|
|
+ if (res.data.status === 0 || res.data.status === 255) {
|
|
|
+ useGlobalMessage().alert('此设备异常或被占用,请更换其他设备')
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ router.push({ name: 'charge-start', params: { connectorCode } })
|
|
|
+ }
|
|
|
+}
|
|
|
+async function scanCode() {
|
|
|
+ try {
|
|
|
+ const connectorCode = await ScanCodeUtil.scanAndGetConnectorCode()
|
|
|
+ if (!connectorCode) {
|
|
|
+ useGlobalMessage().alert('二维码不正确')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 获取设备信息
|
|
|
+ getDeviceInfo(connectorCode)
|
|
|
+ }
|
|
|
+ catch (error) {
|
|
|
+ console.error('扫码失败:', error)
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -205,6 +230,7 @@ function getTabStyle(tab: string) {
|
|
|
<view class="h-180rpx" />
|
|
|
<view
|
|
|
class="fixed bottom-66rpx left-24rpx h-100rpx w-702rpx rounded-16rpx bg-[linear-gradient(90deg,#DBFC81_0%,#9ED605_100%)] text-center text-28rpx font-800 line-height-[100rpx] shadow-[inset_0rpx_6rpx_20rpx_2rpx_#FFFFFF]"
|
|
|
+ @click="scanCode"
|
|
|
>
|
|
|
扫码充电
|
|
|
</view>
|