style:设备详情页采用动态设备数据

This commit is contained in:
2025-07-28 17:20:14 +08:00
parent 45f80e469a
commit a4d0bd4f71
22 changed files with 77 additions and 69 deletions
+26 -22
View File
@@ -50,10 +50,10 @@
<view class="pricing-banner">
<view class="pricing-main">
<text class="price">¥5.00</text>
<text class="price">¥{{deviceFeeConfig.maxHourPrice}}</text>
<text class="unit">/小时</text>
</view>
<text class="cap-price">封顶 ¥99</text>
<text class="cap-price">封顶 ¥{{deviceInfo.depositAmount}}</text>
</view>
<view class="pricing-rules">
@@ -109,7 +109,7 @@
<!-- 底部操作区 -->
<view class="footer">
<button class="rent-button" :class="{ 'return-button': hasActiveOrder }"
@click="handleRent('wx-score-pay')">
@@ -123,11 +123,11 @@
<text class="credit-score">550分及以上优享</text>
</view>
</view>
<view class="" style="align-items: center;align-content: center;text-align: center;line-height: 50rpx;"
<!-- <view class="" style="align-items: center;align-content: center;text-align: center;line-height: 50rpx;"
@click="handleRent('wx-pay')">
无法免押点这里></view>
无法免押点这里></view> -->
</view>
<!-- 手机号授权弹窗 -->
<view class="phone-auth-popup" v-if="showPhoneAuthPopup">
<view class="popup-mask" @click.stop></view>
@@ -181,6 +181,7 @@
// 响应式状态
const deviceInfo = ref({})
const deviceId = ref('')
const deviceFeeConfig = ref({})
const deviceLocation = ref('一号教学楼大厅')
const batteryLevel = ref(95)
const hasActiveOrder = ref(false)
@@ -191,7 +192,7 @@
const isLoggedIn = ref(true)
const phoneNumber = ref('')
const showPhoneAuthPopup = ref(false)
// 生命周期 onLoad 钩子
onLoad((options) => {
deviceId.value = options.deviceNo
@@ -199,16 +200,16 @@
console.log(options.deviceNo)
fetchDeviceInfo()
})
onMounted(()=>{
onMounted(() => {
checkUserPhone()
})
const checkUserPhone = async () => {
try {
const userInfoRes = await getUserInfo()
console.log(userInfoRes.data.phone, 'getUserInfoPhone')
if (userInfoRes.code == 200 && userInfoRes.data && userInfoRes.data.phone) {
phoneNumber.value = userInfoRes.data.phone
} else {
@@ -219,11 +220,11 @@
console.error('获取用户信息失败:', error)
}
}
// 处理获取手机号
const onGetPhoneNumber = (e) => {
console.log('getPhoneNumber event:', e.detail)
// 用户拒绝授权的情况
if (e.detail.errMsg && e.detail.errMsg.includes('deny')) {
uni.showToast({
@@ -232,22 +233,22 @@
})
return
}
// 获取到授权code
if (e.detail.code) {
uni.showLoading({
title: '获取中...'
})
console.log('获取到的授权code:', e.detail.code)
// 添加 try-catch 以捕获任何 Promise 外部的错误
try {
getUserPhoneNumber(e.detail.code)
.then(res => {
console.log('获取手机号API响应原始数据:', JSON.stringify(res))
uni.hideLoading()
// 不立即抛出错误,而是记录问题并继续处理
if (!res) {
console.error('API返回数据为空')
@@ -258,15 +259,15 @@
})
return
}
// 检查响应格式
console.log('响应code:', res.code, '响应类型:', typeof res.code)
console.log('是否有data:', !!res.data, '是否有phone:', res.data && !!res.data.phone)
if (res.code == 200 && res.data && res.data.phoneNumber) {
phoneNumber.value = res.data.phoneNumber
showPhoneAuthPopup.value = false
uni.showToast({
title: '手机号获取成功',
icon: 'success'
@@ -284,7 +285,7 @@
.catch(err => {
uni.hideLoading()
console.error('获取手机号码失败(catch):', err)
// 显示更详细的错误信息
let errMsg = err.message || err.toString()
uni.showModal({
@@ -333,6 +334,9 @@
deviceStatus.class = 'offline'
}
}
console.log('feeconfig',deviceInfo.value.feeConfig);
deviceFeeConfig.value = JSON.parse(deviceInfo.value.feeConfig)[0] || {}
}
}
@@ -388,7 +392,7 @@
showLoginTip()
return
}
// 检查是否有手机号,如果没有则提示授权
if (!phoneNumber.value) {
showPhoneAuthPopup.value = true