优化设备费用配置解析逻辑,支持新旧格式的费用配置处理。更新了套餐选择逻辑,默认选择中等时长套餐,并添加小时信息以便后续处理。
This commit is contained in:
+11
-7
@@ -153,20 +153,24 @@
|
||||
try {
|
||||
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
|
||||
|
||||
// 检查是否为新格式 [{"Hour":1,"Price":4},{"Hour":3,"Price":10},{"Hour":5,"Price":15}]
|
||||
if (feeConfig.length > 0 && 'Hour' in feeConfig[0] && 'Price' in feeConfig[0]) {
|
||||
// 新格式处理
|
||||
// 检查是否为新格式 [{"hour":1,"timesPrice":4},{"hour":3,"timesPrice":10},{"hour":5,"timesPrice":15}]
|
||||
if (feeConfig.length > 0 && 'hour' in feeConfig[0] && 'timesPrice' in feeConfig[0]) {
|
||||
// 新格式处理 - 直接使用所有套餐
|
||||
this.packages = feeConfig.map(pkg => {
|
||||
const hour = pkg.Hour;
|
||||
const price = pkg.Price;
|
||||
const hour = pkg.hour;
|
||||
const price = pkg.timesPrice;
|
||||
const unitPrice = (price / hour).toFixed(2);
|
||||
|
||||
return {
|
||||
time: `${hour}${hour > 1 ? '小时' : '小时'}`,
|
||||
time: `${hour}小时`,
|
||||
price: price.toFixed(2),
|
||||
unitPrice: unitPrice
|
||||
unitPrice: unitPrice,
|
||||
hour: hour // 添加小时信息,用于后续处理
|
||||
};
|
||||
});
|
||||
|
||||
// 按小时排序
|
||||
this.packages.sort((a, b) => a.hour - b.hour);
|
||||
} else {
|
||||
// 旧格式处理
|
||||
// 通常使用common规格的配置
|
||||
|
||||
Reference in New Issue
Block a user