fix;修复bug
This commit is contained in:
+63
-94
@@ -23,16 +23,16 @@
|
||||
<text class="card-title">{{ $t('device.pricingRules') }}</text>
|
||||
</view>
|
||||
|
||||
<view class="pricing-banner">
|
||||
<view class="pricing-main">
|
||||
<text class="price-symbol">¥</text>
|
||||
<text class="price">{{ deviceFeeConfig.maxHourPrice || '5.00' }}</text>
|
||||
<text class="unit">/{{ $t('time.hour') }}</text>
|
||||
</view>
|
||||
<view class="cap-badge">
|
||||
<text class="cap-text">{{ deviceInfo.depositAmount || '99' }}{{ $t('device.capLimit') }}</text>
|
||||
</view>
|
||||
<view class="pricing-banner">
|
||||
<view class="pricing-main">
|
||||
<text class="price-symbol">¥</text>
|
||||
<text class="price">{{ deviceFeeConfig.maxHourPrice || '5.00' }}</text>
|
||||
<text class="unit">/{{ getPriceUnit() }}</text>
|
||||
</view>
|
||||
<view class="cap-badge">
|
||||
<text class="cap-text">{{ deviceInfo.depositAmount || '99' }}{{ $t('device.capLimit') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="pricing-info">
|
||||
<view class="info-icon">
|
||||
@@ -111,8 +111,7 @@
|
||||
onMounted
|
||||
} from 'vue'
|
||||
import {
|
||||
onLoad,
|
||||
onShow
|
||||
onLoad
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
getDeviceInfo,
|
||||
@@ -120,14 +119,9 @@
|
||||
} from '@/config/api/device.js'
|
||||
import {
|
||||
getOrderByOrderNoScore,
|
||||
getOrderByOrderNoScorePayStatus,
|
||||
getOrderByOrderNo,
|
||||
updateOrderPackage,
|
||||
cancelOrder
|
||||
} from '@/config/api/order.js'
|
||||
import {
|
||||
URL
|
||||
} from "@/config/url.js"
|
||||
import {
|
||||
initiateWeChatScorePayment,
|
||||
getUserInfo,
|
||||
@@ -147,7 +141,6 @@
|
||||
const deviceFeeConfig = ref({})
|
||||
const positionInfo = ref({})
|
||||
const deviceLocation = ref('一号教学楼大厅')
|
||||
const batteryLevel = ref(95)
|
||||
const hasActiveOrder = ref(false)
|
||||
const deviceStatus = reactive({
|
||||
text: $t('device.available'),
|
||||
@@ -164,7 +157,6 @@
|
||||
uni.setStorageSync('deviceId', options.deviceNo)
|
||||
} else {
|
||||
deviceId.value = uni.getStorageSync('deviceId')
|
||||
// uni.removeStorageSync('deviceId')
|
||||
}
|
||||
await checkOrderStatus()
|
||||
await fetchDeviceInfo()
|
||||
@@ -178,10 +170,6 @@
|
||||
await fetchDeviceInfo()
|
||||
})
|
||||
|
||||
// onShow(async () => {
|
||||
// await fetchDeviceInfo()
|
||||
// })
|
||||
|
||||
const checkUserPhone = async () => {
|
||||
try {
|
||||
const userInfoRes = await getUserInfo()
|
||||
@@ -318,15 +306,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceInfo.value.feeConfig) {
|
||||
deviceFeeConfig.value = JSON.parse(deviceInfo.value.feeConfig)[0] || {}
|
||||
console.log('deviceFeeConfig', deviceFeeConfig.value);
|
||||
} else {
|
||||
deviceFeeConfig.value = {
|
||||
maxHourPrice: '5.00',
|
||||
}
|
||||
discount.value = '99.00'
|
||||
if (deviceInfo.value.feeConfig) {
|
||||
deviceFeeConfig.value = JSON.parse(deviceInfo.value.feeConfig)[0] || {}
|
||||
console.log('deviceFeeConfig', deviceFeeConfig.value);
|
||||
} else {
|
||||
deviceFeeConfig.value = {
|
||||
maxHourPrice: '5.00',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -395,14 +382,23 @@
|
||||
submitRentOrder(payWay)
|
||||
}
|
||||
|
||||
const selectedPkg = reactive({
|
||||
time: '1小时',
|
||||
price: '5'
|
||||
})
|
||||
const depositAmount = ref('99.00')
|
||||
// 获取价格单位文本
|
||||
const getPriceUnit = () => {
|
||||
// 按分钟计费
|
||||
if (deviceInfo.value && deviceInfo.value.feeType === 'minute') {
|
||||
return '分钟'
|
||||
}
|
||||
// 按小时计费(默认)
|
||||
return $t('time.hour')
|
||||
}
|
||||
|
||||
// 计算计费单位时间(分钟)
|
||||
const getBillingUnitMinutes = () => {
|
||||
// 按分钟计费时,单位为1分钟
|
||||
if (deviceInfo.value && deviceInfo.value.feeType === 'minute') {
|
||||
return 1
|
||||
}
|
||||
// 按小时计费
|
||||
if (!deviceFeeConfig.value || !deviceFeeConfig.value.hourPrice) return 60
|
||||
const hourPrice = parseFloat(deviceFeeConfig.value.hourPrice)
|
||||
// hourPrice 为 0.5 时表示 30 分钟,为 1 时表示 60 分钟
|
||||
@@ -413,8 +409,14 @@
|
||||
const getBillingUnitPrice = () => {
|
||||
if (!deviceFeeConfig.value || !deviceFeeConfig.value.maxHourPrice) return '5'
|
||||
const maxHourPrice = parseFloat(deviceFeeConfig.value.maxHourPrice)
|
||||
|
||||
// 按分钟计费时,直接返回每分钟价格
|
||||
if (deviceInfo.value && deviceInfo.value.feeType === 'minute') {
|
||||
return maxHourPrice.toFixed(2)
|
||||
}
|
||||
|
||||
// 按小时计费
|
||||
const hourPrice = parseFloat(deviceFeeConfig.value.hourPrice || 1)
|
||||
// maxHourPrice 是1小时的价格,需要根据 hourPrice 换算
|
||||
const unitPrice = maxHourPrice * hourPrice
|
||||
return unitPrice.toFixed(2)
|
||||
}
|
||||
@@ -425,21 +427,18 @@
|
||||
return parseInt(positionInfo.value.freeRentTime)
|
||||
}
|
||||
|
||||
// 计算24小时封顶价格
|
||||
const get24HourCapPrice = () => {
|
||||
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)
|
||||
}
|
||||
|
||||
// 生成计费说明文本
|
||||
const getPricingInfoText = () => {
|
||||
const unitMinutes = getBillingUnitMinutes()
|
||||
const unitPrice = getBillingUnitPrice()
|
||||
const maxHourPrice = deviceFeeConfig.value.maxHourPrice || '5'
|
||||
|
||||
// 按分钟计费
|
||||
if (deviceInfo.value && deviceInfo.value.feeType === 'minute') {
|
||||
return `${unitPrice}元/分钟`
|
||||
}
|
||||
|
||||
// 按小时计费
|
||||
const unitMinutes = getBillingUnitMinutes()
|
||||
if (unitMinutes === 30) {
|
||||
return `${unitPrice}元/${unitMinutes}分钟,${maxHourPrice}元/小时`
|
||||
} else {
|
||||
@@ -453,6 +452,12 @@
|
||||
const unitMinutes = getBillingUnitMinutes()
|
||||
const depositAmount = deviceInfo.value.depositAmount || '99'
|
||||
|
||||
// 按分钟计费
|
||||
if (deviceInfo.value && deviceInfo.value.feeType === 'minute') {
|
||||
return `前${freeMinutes}分钟内归还免费,不足${unitMinutes}分钟按${unitMinutes}分钟计费,封顶${depositAmount}元,持续计费至${depositAmount}元视为买断`
|
||||
}
|
||||
|
||||
// 按小时计费
|
||||
return `前${freeMinutes}分钟内归还免费,不足${unitMinutes}分钟按${unitMinutes}分钟计费,封顶${depositAmount}元,持续计费至${depositAmount}元视为买断`
|
||||
}
|
||||
|
||||
@@ -496,54 +501,23 @@
|
||||
throw new Error(rentResult.msg || $t('device.rentFailed'))
|
||||
}
|
||||
|
||||
// 获取后端返回的订单信息
|
||||
const order = rentResult.data
|
||||
console.log('订单信息', order);
|
||||
// 获取后端返回的订单信息
|
||||
const order = rentResult.data
|
||||
console.log('订单信息', order);
|
||||
|
||||
// // --- 统一:先更新订单套餐信息 ---
|
||||
// try {
|
||||
// let packageTimeMinutes = 0;
|
||||
// if (selectedPkg.time.includes('小时')) {
|
||||
// packageTimeMinutes = parseInt(selectedPkg.time) * 60;
|
||||
// } else if (selectedPkg.time.includes('分钟')) {
|
||||
// packageTimeMinutes = parseInt(selectedPkg.time);
|
||||
// } else {
|
||||
// packageTimeMinutes = parseInt(selectedPkg.time) * 60; // 默认按小时处理
|
||||
// }
|
||||
|
||||
// const updateRes = await updateOrderPackage({
|
||||
// orderId: order.orderId,
|
||||
// packageTime: packageTimeMinutes,
|
||||
// packagePrice: parseFloat(selectedPkg.price)
|
||||
// });
|
||||
// if (updateRes.code !== 200) {
|
||||
// console.warn("更新订单套餐信息失败:", updateRes.msg);
|
||||
// // 这里可以选择是否提示用户或阻止流程,当前不阻止
|
||||
// } else {
|
||||
// console.log("订单套餐信息已提前更新");
|
||||
// }
|
||||
// } catch (updateError) {
|
||||
// console.error("更新订单套餐信息时出错:", updateError);
|
||||
// // 即使更新失败,也继续流程
|
||||
// }
|
||||
// --- 套餐信息更新结束 ---
|
||||
|
||||
if (payWay == 'wx-pay') {
|
||||
//当支付方式为押金支付时
|
||||
if (payWay == 'wx-pay') {
|
||||
// 当支付方式为押金支付时
|
||||
uni.hideLoading()
|
||||
const res = await getOrderByOrderNo(order.orderNo);
|
||||
console.log(res);
|
||||
// --- 新增:计算总金额 ---
|
||||
|
||||
const deposit = parseFloat(order.depositAmount);
|
||||
const packagePrice = parseFloat(order.unitPrice);
|
||||
const totalAmount = deposit.toFixed(2);
|
||||
// --- 计算结束 ---
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 跳转到订单支付页面,传递订单ID、套餐信息和总金额
|
||||
// 跳转到订单支付页面
|
||||
uni.redirectTo({
|
||||
url: `/pages/order/payment?orderId=${order.orderId}&packageTimeHours=${selectedPkg.time.replace('小时', '')}&packagePrice=${packagePrice}&totalAmount=${totalAmount}&depositAmount=${depositAmount.value}${deviceInfo.value && deviceInfo.value.feeConfig ? '&feeConfig=' + encodeURIComponent(deviceInfo.value.feeConfig) : ''}`
|
||||
url: `/pages/order/payment?orderId=${order.orderId}&packagePrice=${packagePrice}&totalAmount=${totalAmount}&depositAmount=${deposit}${deviceInfo.value && deviceInfo.value.feeConfig ? '&feeConfig=' + encodeURIComponent(deviceInfo.value.feeConfig) : ''}`
|
||||
})
|
||||
|
||||
} else if (payWay == 'wx-score-pay') {
|
||||
@@ -915,15 +889,10 @@
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
|
||||
.credit-text {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
|
||||
.divider {
|
||||
margin: 0 8rpx;
|
||||
color: #ddd;
|
||||
}
|
||||
}
|
||||
.credit-text {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user