diff --git a/config/url.js b/config/url.js index 6c5808c..cb4e171 100644 --- a/config/url.js +++ b/config/url.js @@ -1,6 +1,6 @@ export const URL = "https://my.gxfs123.com/api" //正式服务器 // export const URL = "https://fansdev.gxfs123.com/api" //测试服务器 -// export const URL = "http://192.168.5.120:8080" //本地调试 +// export const URL = "http://192.168.5.149:8080" //本地调试 // export const URL = "http://127.0.0.1:8080" //本地调试 export const appid = "wx2165f0be356ae7a9" //小程序appid \ No newline at end of file diff --git a/pages/device/detail.vue b/pages/device/detail.vue index cccf83d..ebe6509 100644 --- a/pages/device/detail.vue +++ b/pages/device/detail.vue @@ -133,9 +133,13 @@ getUserInfo, getUserPhoneNumber } from '@/util/index.js' - import { useI18n } from '@/utils/i18n.js' + import { + useI18n + } from '@/utils/i18n.js' - const { t: $t } = useI18n() + const { + t: $t + } = useI18n() // 响应式状态 const deviceInfo = ref({}) @@ -146,7 +150,7 @@ const batteryLevel = ref(95) const hasActiveOrder = ref(false) const deviceStatus = reactive({ - get text() { return $t('device.available') }, + text: $t('device.available'), class: 'available' }) const isLoggedIn = ref(true) @@ -302,18 +306,21 @@ 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.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', @@ -321,6 +328,7 @@ discount.value = '99.00' } + } } @@ -419,7 +427,8 @@ // 计算24小时封顶价格 const get24HourCapPrice = () => { - if (!deviceFeeConfig.value || !deviceFeeConfig.value.maxHourPrice || !deviceFeeConfig.value.maxHour) return '45.00' + if (!deviceFeeConfig.value || !deviceFeeConfig.value.maxHourPrice || !deviceFeeConfig.value.maxHour) + return '45.00' const maxHourPrice = parseFloat(deviceFeeConfig.value.maxHourPrice) const maxHour = parseFloat(deviceFeeConfig.value.maxHour) return (maxHourPrice * maxHour).toFixed(2) @@ -430,7 +439,7 @@ const unitMinutes = getBillingUnitMinutes() const unitPrice = getBillingUnitPrice() const maxHourPrice = deviceFeeConfig.value.maxHourPrice || '5' - + if (unitMinutes === 30) { return `${unitPrice}元/${unitMinutes}分钟,${maxHourPrice}元/小时` } else { @@ -443,7 +452,7 @@ const freeMinutes = getFreeMinutes() const unitMinutes = getBillingUnitMinutes() const depositAmount = deviceInfo.value.depositAmount || '99' - + return `前${freeMinutes}分钟内归还免费,不足${unitMinutes}分钟按${unitMinutes}分钟计费,封顶${depositAmount}元,持续计费至${depositAmount}元视为买断` } @@ -462,7 +471,7 @@ tmplIds: ['o7OMTIcHnFBR7mvsggxFtdt8FfIgSl-v0swVUefGx6w'], success: (subscribeRes) => { console.log('订阅消息success回调,时间:', new Date() - .toLocaleTimeString(), subscribeRes); + .toLocaleTimeString(), subscribeRes); resolve(subscribeRes); }, fail: (subscribeErr) => { @@ -550,7 +559,8 @@ const payResult = await initiateWeChatScorePayment(res); console.log('支付分调用结果', payResult); // 成功则跳转到等待页面 - if (payResult.errCode == '0' && payResult.extraData && Object.keys(payResult.extraData).length > 0) { + if (payResult.errCode == '0' && payResult.extraData && Object.keys(payResult.extraData) + .length > 0) { console.log('支付分授权成功,准备跳转到等待页,时间:', new Date().toLocaleTimeString()); // 跳转到等待页面(订阅消息已经在前面完成了) uni.redirectTo({ @@ -564,16 +574,18 @@ uni.showLoading({ title: $t('order.cancelling') }); - const cancelRes = await cancelOrder({ orderId: order.orderNo }); + const cancelRes = await cancelOrder({ + orderId: order.orderNo + }); console.log('订单取消结果:', cancelRes); uni.hideLoading(); - + uni.showToast({ title: $t('order.orderCancelled'), icon: 'none', duration: 2000 }); - + // 延迟返回首页 setTimeout(() => { uni.switchTab({ @@ -597,19 +609,21 @@ uni.showLoading({ title: $t('order.cancelling') }); - const cancelRes = await cancelOrder({ orderId: order.orderNo }); + const cancelRes = await cancelOrder({ + orderId: order.orderNo + }); console.log('订单取消结果:', cancelRes); uni.hideLoading(); } catch (cancelError) { console.error('取消订单失败:', cancelError); uni.hideLoading(); } - + uni.showToast({ title: $t('device.payScoreFailedCancelled'), icon: 'none' }); - + setTimeout(() => { uni.switchTab({ url: '/pages/index/index' diff --git a/pages/index/index.vue b/pages/index/index.vue index 504c9b5..e4cb78d 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -3,8 +3,7 @@ - - 风电者共享风扇 + {{ $t('home.title') }}