From 9e10ea7f3072f5b68c4ed6330d0557915011cb2c Mon Sep 17 00:00:00 2001 From: 8vd8 <1936002261@qq.com> Date: Tue, 22 Apr 2025 18:10:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E5=A4=87=E8=B4=B9?= =?UTF-8?q?=E7=94=A8=E9=85=8D=E7=BD=AE=E8=A7=A3=E6=9E=90=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E6=96=B0=E6=97=A7=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E7=9A=84=E8=B4=B9=E7=94=A8=E9=85=8D=E7=BD=AE=E5=A4=84=E7=90=86?= =?UTF-8?q?=E3=80=82=E6=9B=B4=E6=96=B0=E4=BA=86=E5=A5=97=E9=A4=90=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E9=80=BB=E8=BE=91=EF=BC=8C=E9=BB=98=E8=AE=A4=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E4=B8=AD=E7=AD=89=E6=97=B6=E9=95=BF=E5=A5=97=E9=A4=90?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E6=B7=BB=E5=8A=A0=E5=B0=8F=E6=97=B6=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=BB=A5=E4=BE=BF=E5=90=8E=E7=BB=AD=E5=A4=84=E7=90=86?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/device/detail.vue | 18 +++++++++------- pages/order/payment.vue | 15 +++++++++++-- .../mp-weixin/pages/device/detail.js.map | 2 +- .../mp-weixin/pages/order/payment.js.map | 2 +- .../dist/dev/mp-weixin/pages/device/detail.js | 21 +++++++++++-------- .../dist/dev/mp-weixin/pages/order/payment.js | 18 ++++++++++------ 6 files changed, 50 insertions(+), 26 deletions(-) diff --git a/pages/device/detail.vue b/pages/device/detail.vue index fd105fd..94c08b8 100644 --- a/pages/device/detail.vue +++ b/pages/device/detail.vue @@ -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规格的配置 diff --git a/pages/order/payment.vue b/pages/order/payment.vue index b003b9c..176ba0e 100644 --- a/pages/order/payment.vue +++ b/pages/order/payment.vue @@ -189,8 +189,19 @@ export default { 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]) { + // 尝试找到对应包时长的套餐 + // 默认使用中等时长的套餐 + const allPackages = feeConfig.sort((a, b) => a.hour - b.hour); + const middleIndex = Math.floor(allPackages.length / 2); + const selectedPackage = allPackages[middleIndex]; + + this.packageInfo.time = selectedPackage.hour.toString(); + this.packageInfo.price = selectedPackage.timesPrice.toString(); + } + // 检查旧的大写格式 [{"Hour":1,"Price":4}] + else if (feeConfig.length > 0 && 'Hour' in feeConfig[0] && 'Price' in feeConfig[0]) { // 尝试找到对应包时长的套餐 // 默认使用6小时或最接近的套餐 const targetHours = 6; diff --git a/unpackage/dist/dev/.sourcemap/mp-weixin/pages/device/detail.js.map b/unpackage/dist/dev/.sourcemap/mp-weixin/pages/device/detail.js.map index ae07546..72101b2 100644 --- a/unpackage/dist/dev/.sourcemap/mp-weixin/pages/device/detail.js.map +++ b/unpackage/dist/dev/.sourcemap/mp-weixin/pages/device/detail.js.map @@ -1 +1 @@ -{"version":3,"file":"detail.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvZGV2aWNlL2RldGFpbC52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/device/detail.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"} \ No newline at end of file +{"version":3,"file":"detail.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvZGV2aWNlL2RldGFpbC52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/device/detail.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"} \ No newline at end of file diff --git a/unpackage/dist/dev/.sourcemap/mp-weixin/pages/order/payment.js.map b/unpackage/dist/dev/.sourcemap/mp-weixin/pages/order/payment.js.map index 2a32a0f..f399d10 100644 --- a/unpackage/dist/dev/.sourcemap/mp-weixin/pages/order/payment.js.map +++ b/unpackage/dist/dev/.sourcemap/mp-weixin/pages/order/payment.js.map @@ -1 +1 @@ -{"version":3,"file":"payment.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvb3JkZXIvcGF5bWVudC52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/order/payment.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"} \ No newline at end of file +{"version":3,"file":"payment.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvb3JkZXIvcGF5bWVudC52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/order/payment.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"} \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/pages/device/detail.js b/unpackage/dist/dev/mp-weixin/pages/device/detail.js index 6c1d4f8..d51197a 100644 --- a/unpackage/dist/dev/mp-weixin/pages/device/detail.js +++ b/unpackage/dist/dev/mp-weixin/pages/device/detail.js @@ -57,17 +57,20 @@ const _sfc_main = { if (this.deviceInfo.feeConfig) { try { const feeConfig = JSON.parse(this.deviceInfo.feeConfig); - if (feeConfig.length > 0 && "Hour" in feeConfig[0] && "Price" in feeConfig[0]) { + 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, + hour + // 添加小时信息,用于后续处理 }; }); + this.packages.sort((a, b) => a.hour - b.hour); } else { const commonConfig = feeConfig.find((item) => item.specCode === "common") || feeConfig[0]; if (commonConfig) { @@ -122,7 +125,7 @@ const _sfc_main = { } this.selectedPackage = Math.min(1, this.packages.length - 1); } catch (e) { - common_vendor.index.__f__("error", "at pages/device/detail.vue:234", "解析设备费用配置失败:", e); + common_vendor.index.__f__("error", "at pages/device/detail.vue:238", "解析设备费用配置失败:", e); this.packages = [ { time: "1小时", @@ -261,12 +264,12 @@ const _sfc_main = { packagePrice: parseFloat(selectedPkg.price) }); if (updateRes.code !== 200) { - common_vendor.index.__f__("warn", "at pages/device/detail.vue:402", "更新订单套餐信息失败:", updateRes.msg); + common_vendor.index.__f__("warn", "at pages/device/detail.vue:406", "更新订单套餐信息失败:", updateRes.msg); } else { - common_vendor.index.__f__("log", "at pages/device/detail.vue:405", "订单套餐信息已提前更新"); + common_vendor.index.__f__("log", "at pages/device/detail.vue:409", "订单套餐信息已提前更新"); } } catch (updateError) { - common_vendor.index.__f__("error", "at pages/device/detail.vue:408", "更新订单套餐信息时出错:", updateError); + common_vendor.index.__f__("error", "at pages/device/detail.vue:412", "更新订单套餐信息时出错:", updateError); } const deposit = parseFloat(this.depositAmount); const packagePrice = parseFloat(selectedPkg.price); diff --git a/unpackage/dist/dev/mp-weixin/pages/order/payment.js b/unpackage/dist/dev/mp-weixin/pages/order/payment.js index 857d420..bac23bf 100644 --- a/unpackage/dist/dev/mp-weixin/pages/order/payment.js +++ b/unpackage/dist/dev/mp-weixin/pages/order/payment.js @@ -107,7 +107,13 @@ const _sfc_main = { if (this.deviceInfo && this.deviceInfo.feeConfig) { try { const feeConfig = JSON.parse(this.deviceInfo.feeConfig); - if (feeConfig.length > 0 && "Hour" in feeConfig[0] && "Price" in feeConfig[0]) { + if (feeConfig.length > 0 && "hour" in feeConfig[0] && "timesPrice" in feeConfig[0]) { + const allPackages = feeConfig.sort((a, b) => a.hour - b.hour); + const middleIndex = Math.floor(allPackages.length / 2); + const selectedPackage = allPackages[middleIndex]; + this.packageInfo.time = selectedPackage.hour.toString(); + this.packageInfo.price = selectedPackage.timesPrice.toString(); + } else if (feeConfig.length > 0 && "Hour" in feeConfig[0] && "Price" in feeConfig[0]) { const targetHours = 6; let closestPackage = feeConfig[0]; feeConfig.forEach((pkg) => { @@ -138,7 +144,7 @@ const _sfc_main = { } } } catch (e) { - common_vendor.index.__f__("error", "at pages/order/payment.vue:241", "解析设备费用配置失败:", e); + common_vendor.index.__f__("error", "at pages/order/payment.vue:252", "解析设备费用配置失败:", e); } } if (this.deviceInfo && this.deviceInfo.depositAmount) { @@ -146,7 +152,7 @@ const _sfc_main = { } } } catch (error) { - common_vendor.index.__f__("error", "at pages/order/payment.vue:251", "获取设备信息失败:", error); + common_vendor.index.__f__("error", "at pages/order/payment.vue:262", "获取设备信息失败:", error); } }, // 处理支付 @@ -175,7 +181,7 @@ const _sfc_main = { try { await config_user.updateUserBalance(this.orderId); } catch (error) { - common_vendor.index.__f__("warn", "at pages/order/payment.vue:288", "更新用户余额失败:", error); + common_vendor.index.__f__("warn", "at pages/order/payment.vue:299", "更新用户余额失败:", error); } setTimeout(() => { common_vendor.index.redirectTo({ @@ -184,7 +190,7 @@ const _sfc_main = { }, 1500); }, fail: (err) => { - common_vendor.index.__f__("error", "at pages/order/payment.vue:299", "支付失败:", err); + common_vendor.index.__f__("error", "at pages/order/payment.vue:310", "支付失败:", err); throw new Error("支付失败,请重试"); } }); @@ -281,7 +287,7 @@ const _sfc_main = { throw new Error("查询订单状态失败"); } } catch (error) { - common_vendor.index.__f__("error", "at pages/order/payment.vue:407", "查询订单状态错误:", error); + common_vendor.index.__f__("error", "at pages/order/payment.vue:418", "查询订单状态错误:", error); return null; } }