fix:修复bug

This commit is contained in:
2026-02-26 09:16:35 +08:00
parent 99872dd6df
commit 3462a24d1e
6 changed files with 255 additions and 50 deletions
+59 -41
View File
@@ -1,5 +1,10 @@
<template>
<view class="container">
<!-- 骨架屏 -->
<DeviceDetailSkeleton v-if="loading&&!deviceInfo" />
<!-- 实际内容 -->
<view v-else>
<!-- 设备信息卡片 -->
<view class="card device-info-card">
<view class="device-location">
@@ -19,7 +24,6 @@
<text class="id-label">{{ $t('device.deviceNo') }}</text>
<text class="id-value">{{ deviceId }}</text>
</view>
</view>
<!-- 计费规则 -->
@@ -117,6 +121,7 @@
</view>
</view>
</view>
</view>
</view>
</template>
@@ -149,12 +154,14 @@
import {
useI18n
} from '@/utils/i18n.js'
import DeviceDetailSkeleton from '@/components/DeviceDetailSkeleton.vue'
const {
t
} = useI18n()
// 响应式状态
const loading = ref(true)
const deviceInfo = ref({})
const deviceId = ref('')
const deviceFeeConfig = ref({})
@@ -243,9 +250,9 @@
// 获取到授权code
if (e.detail.code) {
uni.showLoading({
title: t('auth.getting')
})
// uni.showLoading({
// title: t('auth.getting')
// })
console.log('获取到的授权code:', e.detail.code)
@@ -254,7 +261,7 @@
getUserPhoneNumber(e.detail.code)
.then(res => {
console.log('获取手机号API响应原始数据:', JSON.stringify(res))
uni.hideLoading()
// uni.hideLoading()
// 不立即抛出错误,而是记录问题并继续处理
if (!res) {
@@ -290,7 +297,7 @@
}
})
.catch(err => {
uni.hideLoading()
// uni.hideLoading()
console.error('获取手机号码失败(catch):', err)
// 显示更详细的错误信息
@@ -302,7 +309,7 @@
})
})
} catch (outerError) {
uni.hideLoading()
// uni.hideLoading()
console.error('获取手机号外部错误:', outerError)
uni.showModal({
title: t('common.unexpectedError'),
@@ -320,45 +327,55 @@
// 检查登录状态和订单
const fetchDeviceInfo = async () => {
console.log(deviceId.value);
const res = await getDeviceInfo(deviceId.value)
if (res.code == 200) {
deviceInfo.value = res.data.device || {}
try {
loading.value = true
console.log(deviceId.value);
const res = await getDeviceInfo(deviceId.value)
if (res.code == 200) {
deviceInfo.value = res.data.device || {}
// 保存 position 信息
if (res.data.position) {
positionInfo.value = res.data.position
}
// 更新设备位置信息
if (deviceInfo.value.deviceLocation) {
deviceLocation.value = deviceInfo.value.deviceLocation
} else if (res.data.position && res.data.position.name) {
deviceLocation.value = res.data.position.name
}
// 更新设备状态
if (deviceInfo.value.status) {
if (deviceInfo.value.status === 'online') {
deviceStatus.text = t('device.available')
deviceStatus.class = 'available'
} else if (deviceInfo.value.status === 'offline') {
deviceStatus.text = t('device.offline')
deviceStatus.class = 'offline'
// 保存 position 信息
if (res.data.position) {
positionInfo.value = res.data.position
}
}
if (deviceInfo.value.feeConfig) {
deviceFeeConfig.value = JSON.parse(deviceInfo.value.feeConfig)[0] || {}
console.log('deviceFeeConfig', deviceFeeConfig.value);
} else {
deviceFeeConfig.value = {
maxHourPrice: '5.00',
// 更新设备位置信息
if (deviceInfo.value.deviceLocation) {
deviceLocation.value = deviceInfo.value.deviceLocation
} else if (res.data.position && res.data.position.name) {
deviceLocation.value = res.data.position.name
}
// 更新设备状态
if (deviceInfo.value.status) {
if (deviceInfo.value.status === 'online') {
deviceStatus.text = t('device.available')
deviceStatus.class = 'available'
} else if (deviceInfo.value.status === 'offline') {
deviceStatus.text = t('device.offline')
deviceStatus.class = 'offline'
}
}
if (deviceInfo.value.feeConfig) {
deviceFeeConfig.value = JSON.parse(deviceInfo.value.feeConfig)[0] || {}
console.log('deviceFeeConfig', deviceFeeConfig.value);
} else {
deviceFeeConfig.value = {
maxHourPrice: '5.00',
}
}
}else{
uni.reLaunch({
url:'/pages/index/index'
})
}
}catch(error){
console.error('获取设备信息失败:', error)
}
finally {
}
}
@@ -394,6 +411,7 @@
if (inUseRes && inUseRes.code === 200 && inUseRes.data) {
const order = inUseRes.data
// 如果有正在进行的订单,跳转到归还页面,带上设备ID
console.log('1111111111');
uni.redirectTo({
url: `/subPackages/service/return/index?deviceId=${deviceId.value}`
})