成功修改订单页面套餐金额 为 套餐金额/套餐小时 ,而不是固定的10元/小时

This commit is contained in:
8vd8
2025-04-25 17:10:15 +08:00
parent 9e10ea7f30
commit 1f264393b9
44 changed files with 5984 additions and 5872 deletions
+172 -137
View File
@@ -110,9 +110,28 @@
onLoad(options) {
// console.log(options);
this.deviceId = options.deviceNo
// 如果URL中包含了feeConfig参数,直接使用它
if (options.feeConfig) {
try {
console.log('从URL获取到feeConfig:', options.feeConfig)
const feeConfigStr = decodeURIComponent(options.feeConfig)
// 存储到设备信息中,这样后续处理逻辑可以保持不变
this.deviceInfo = { ...this.deviceInfo, feeConfig: feeConfigStr }
// 马上解析feeConfig并生成套餐选项
this.parseFeeConfig()
} catch (e) {
console.error('解析URL中的feeConfig失败:', e)
// 如果解析失败,继续正常流程获取设备信息
this.checkOrderStatus()
this.getDeviceInfo()
}
} else {
// 正常流程
this.checkOrderStatus() // 新增状态检查
console.log(options.deviceNo);
this.getDeviceInfo()
}
},
methods: {
// 检查登录状态和订单
@@ -148,133 +167,8 @@
}
}
// 解析feeConfig并生成套餐选项
if (this.deviceInfo.feeConfig) {
try {
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
// 检查是否为新格式 [{"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.timesPrice;
const unitPrice = (price / hour).toFixed(2);
return {
time: `${hour}小时`,
price: price.toFixed(2),
unitPrice: unitPrice,
hour: hour // 添加小时信息,用于后续处理
};
});
// 按小时排序
this.packages.sort((a, b) => a.hour - b.hour);
} else {
// 旧格式处理
// 通常使用common规格的配置
const commonConfig = feeConfig.find(item => item.specCode === 'common') || feeConfig[0];
if (commonConfig) {
// 根据收费类型生成套餐
if (this.deviceInfo.feeType === 'hour') {
// 按小时收费
const hourPrice = commonConfig.hourPrice > 0 ? commonConfig.hourPrice : commonConfig.timesPrice / 6;
this.packages = [
{
time: '1小时',
price: hourPrice.toFixed(2),
unitPrice: hourPrice.toFixed(2)
},
{
time: '6小时',
price: (hourPrice * 6).toFixed(2),
unitPrice: hourPrice.toFixed(2)
},
{
time: '12小时',
price: (hourPrice * 12).toFixed(2),
unitPrice: hourPrice.toFixed(2)
}
];
} else if (this.deviceInfo.feeType === 'times') {
// 按次收费
const timesPrice = commonConfig.timesPrice;
this.packages = [
{
time: '1次',
price: timesPrice.toFixed(2),
unitPrice: timesPrice.toFixed(2)
}
];
} else {
// 默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00'
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67'
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25'
}
];
}
}
}
// 默认选中中间套餐
this.selectedPackage = Math.min(1, this.packages.length - 1);
} catch (e) {
console.error('解析设备费用配置失败:', e);
// 使用默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00'
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67'
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25'
}
];
}
} else {
// 如果没有feeConfig,使用默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00'
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67'
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25'
}
];
}
// 使用抽取的方法解析feeConfig并生成套餐选项
this.parseFeeConfig();
}
},
@@ -355,16 +249,8 @@
return
}
const selectedPkg = this.packages[this.selectedPackage]
uni.showModal({
title: '确认租借',
content: `确认支付押金¥{{ depositAmount }}及${selectedPkg.time}套餐费用¥${selectedPkg.price}`,
success: (res) => {
if (res.confirm) {
// 直接提交订单,不显示确认对话框
this.submitRentOrder()
}
}
})
},
// 提交租借订单
@@ -424,7 +310,7 @@
// 跳转到订单支付页面,传递订单ID、套餐信息和总金额
uni.redirectTo({
url: `/pages/order/payment?orderId=${order.orderId}&packageTimeHours=${selectedPkg.time.replace('小时', '')}&packagePrice=${selectedPkg.price}&totalAmount=${totalAmount}&depositAmount=${this.depositAmount}`
url: `/pages/order/payment?orderId=${order.orderId}&packageTimeHours=${selectedPkg.time.replace('小时', '')}&packagePrice=${selectedPkg.price}&totalAmount=${totalAmount}&depositAmount=${this.depositAmount}${this.deviceInfo && this.deviceInfo.feeConfig ? '&feeConfig=' + encodeURIComponent(this.deviceInfo.feeConfig) : ''}`
})
} catch (error) {
uni.hideLoading()
@@ -433,6 +319,155 @@
icon: 'none'
})
}
},
// 单独抽取解析feeConfig的逻辑
parseFeeConfig() {
if (this.deviceInfo.feeConfig) {
try {
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
// 检查是否为新格式 [{"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.timesPrice;
const unitPrice = (price / hour).toFixed(2);
return {
time: `${hour}小时`,
price: price.toFixed(2),
unitPrice: unitPrice,
hour: hour // 添加小时信息,用于后续处理
};
});
// 按小时排序
this.packages.sort((a, b) => a.hour - b.hour);
} else {
// 旧格式处理
// 通常使用common规格的配置
const commonConfig = feeConfig.find(item => item.specCode === 'common') || feeConfig[0];
if (commonConfig) {
// 根据收费类型生成套餐
if (this.deviceInfo.feeType === 'hour') {
// 按小时收费
const hourPrice = commonConfig.hourPrice > 0 ? commonConfig.hourPrice : commonConfig.timesPrice / 6;
this.packages = [
{
time: '1小时',
price: hourPrice.toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 1
},
{
time: '6小时',
price: (hourPrice * 6).toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 6
},
{
time: '12小时',
price: (hourPrice * 12).toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 12
}
];
} else if (this.deviceInfo.feeType === 'times') {
// 按次收费
const timesPrice = commonConfig.timesPrice;
this.packages = [
{
time: '1次',
price: timesPrice.toFixed(2),
unitPrice: timesPrice.toFixed(2),
hour: 1
}
];
} else {
// 默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00',
hour: 1
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67',
hour: 6
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25',
hour: 12
}
];
}
}
}
// 默认选中中间套餐
this.selectedPackage = Math.min(1, this.packages.length - 1);
} catch (e) {
console.error('解析设备费用配置失败:', e);
// 使用默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00',
hour: 1
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67',
hour: 6
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25',
hour: 12
}
];
// 默认选中中间套餐
this.selectedPackage = 1;
}
} else {
// 如果没有feeConfig,使用默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00',
hour: 1
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67',
hour: 6
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25',
hour: 12
}
];
// 默认选中中间套餐
this.selectedPackage = 1;
}
}
}
}
+58 -2
View File
@@ -52,6 +52,7 @@
import {
URL
}from"@/config/url.js"
import { getDeviceInfo } from '@/config/user.js'
export default {
methods: {
async handleScan() {
@@ -125,12 +126,67 @@
url: `/pages/order/payment?orderId=${unpaidOrder.orderId}`
})
} else {
// 查询设备信息并直接跳转到设备详情页面
console.log('无待支付订单,直接跳转到设备详情页面, deviceNo:', deviceNo)
// 修改:直接获取设备信息,而不是跳转到详情页面
console.log('无待支付订单,获取设备信息, deviceNo:', deviceNo)
try {
// 获取设备信息
const deviceInfoRes = await getDeviceInfo(deviceNo)
if (deviceInfoRes.code == 200 && deviceInfoRes.data && deviceInfoRes.data.device) {
const deviceInfo = deviceInfoRes.data.device
// 如果有feeConfig,直接解析并处理
if (deviceInfo.feeConfig) {
console.log('获取到设备feeConfig信息:', deviceInfo.feeConfig)
// 这里可以直接解析feeConfig并进行前端处理
try {
const feeConfig = JSON.parse(deviceInfo.feeConfig)
// 根据解析后的feeConfig进行页面跳转并传递信息
uni.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}&feeConfig=${encodeURIComponent(deviceInfo.feeConfig)}`
})
} catch (e) {
console.error('解析feeConfig失败:', e)
// 解析失败时仍然跳转到详情页面,由详情页面处理
uni.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
})
}
} else {
// 没有feeConfig时,跳转到详情页面
uni.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
})
}
} else {
console.error('获取设备信息失败:', deviceInfoRes.msg || '未知错误')
uni.showToast({
title: '获取设备信息失败',
icon: 'none'
})
// 失败时仍然跳转到详情页面
uni.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
})
}
} catch (error) {
console.error('获取设备信息异常:', error)
uni.showToast({
title: '获取设备信息失败',
icon: 'none'
})
// 异常时仍然跳转到详情页面
uni.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
})
}
}
} catch (error) {
console.error('扫码处理失败:', error)
uni.showToast({
+43 -71
View File
@@ -96,6 +96,25 @@ export default {
const deposit = parseFloat(this.orderInfo.deposit || this.passedDepositAmount || 99)
const packagePrice = parseFloat(this.packageInfo.price || 0)
return (deposit + packagePrice).toFixed(2)
},
// 计算每小时的价格
hourlyRate() {
const price = parseFloat(this.packageInfo.price || 0);
let time = parseFloat(this.packageInfo.time || 1);
// 如果时间单位不是小时(例如分钟),需要转换
if (this.packageInfo.time && this.packageInfo.time.includes('分钟')) {
time = time / 60; // 将分钟转换为小时
} else if (this.packageInfo.time && this.packageInfo.time.includes('次')) {
// 按次计费时,暂时显示单次价格
return price.toFixed(2);
}
// 避免除以零
if (time <= 0) time = 1;
// 计算每小时价格
return (price / time).toFixed(2);
}
},
onLoad(options) {
@@ -110,6 +129,18 @@ export default {
this.passedDepositAmount = options.depositAmount;
}
// 如果URL中包含了feeConfig参数,保存它
if (options.feeConfig) {
try {
console.log('从URL获取到feeConfig:', options.feeConfig)
const feeConfigStr = decodeURIComponent(options.feeConfig)
// 创建一个临时的deviceInfo对象保存feeConfig
this.deviceInfo = { feeConfig: feeConfigStr }
} catch (e) {
console.error('解析URL中的feeConfig失败:', e)
}
}
this.loadOrderInfo()
} else {
uni.showToast({
@@ -158,7 +189,17 @@ export default {
deposit: this.passedDepositAmount || orderData.depositAmount || '99.00',
}
// 获取设备信息并解析套餐
// 直接从订单数据中获取套餐信息
if (orderData.packageTime && orderData.packagePrice) {
// 将分钟转换为小时
const timeInHours = (parseFloat(orderData.packageTime) / 60).toFixed(1);
this.packageInfo = {
time: timeInHours.toString(),
price: orderData.packagePrice.toString()
}
}
// 获取设备信息(但不再用于设置套餐信息)
this.deviceNo = orderData.deviceNo;
await this.loadDeviceInfo();
} else {
@@ -175,7 +216,7 @@ export default {
}
},
// 加载设备信息并解析套餐
// 加载设备信息
async loadDeviceInfo() {
if (!this.deviceNo) return;
@@ -184,75 +225,6 @@ export default {
if (res.code === 200 && res.data) {
this.deviceInfo = res.data.device;
// 解析feeConfig获取套餐信息
if (this.deviceInfo && this.deviceInfo.feeConfig) {
try {
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
// 检查是否为新格式 [{"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;
let closestPackage = feeConfig[0];
// 找出最接近目标时长的套餐
feeConfig.forEach(pkg => {
if (Math.abs(pkg.Hour - targetHours) < Math.abs(closestPackage.Hour - targetHours)) {
closestPackage = pkg;
}
});
this.packageInfo.time = closestPackage.Hour.toString();
this.packageInfo.price = closestPackage.Price.toString();
} else {
// 旧格式处理
// 通常使用common配置
const selectedConfig = feeConfig.find(item => item.specCode === 'common') || feeConfig[0];
if (selectedConfig) {
// 套餐时间
const packageHours = 6; // 默认6小时
// 如果是按次收费,则直接使用timesPrice
if (this.deviceInfo.feeType === 'times') {
this.packageInfo.price = selectedConfig.timesPrice.toString();
this.packageInfo.time = '1次';
}
// 如果是按小时收费
else if (this.deviceInfo.feeType === 'hour') {
if (selectedConfig.hourPrice > 0) {
// 如果有设置小时价格,计算套餐价格
this.packageInfo.price = (selectedConfig.hourPrice * packageHours).toString();
} else {
// 否则使用timesPrice作为套餐价格
this.packageInfo.price = selectedConfig.timesPrice.toString();
}
this.packageInfo.time = packageHours.toString();
}
// 如果是其他收费类型,使用timesPrice
else {
this.packageInfo.price = selectedConfig.timesPrice.toString();
this.packageInfo.time = packageHours.toString();
}
}
}
} catch (e) {
console.error('解析设备费用配置失败:', e);
}
}
// 设置存款金额
if (this.deviceInfo && this.deviceInfo.depositAmount) {
this.orderInfo.deposit = this.deviceInfo.depositAmount;
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvZGVwb3NpdC9pbmRleC52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/deposit/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/deposit/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/deposit/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -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;"}
{"version":3,"file":"detail.js","sources":["pages/device/detail.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/device/detail.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvZmVlZGJhY2svaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/feedback/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/feedback/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/feedback/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvaGVscC9pbmRleC52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/help/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/help/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/help/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvaW5kZXgvaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/index/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvbXkvaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/my/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/my/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/my/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvb3JkZXIvaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/order/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/order/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/order/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -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;"}
{"version":3,"file":"payment.js","sources":["pages/order/payment.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/order/payment.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"return-success.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvb3JkZXIvcmV0dXJuLXN1Y2Nlc3MudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/order/return-success.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"return-success.js","sources":["pages/order/return-success.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/order/return-success.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"success.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvb3JkZXIvc3VjY2Vzcy52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/order/success.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"success.js","sources":["pages/order/success.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/order/success.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvcmV0dXJuL2luZGV4LnZ1ZQ"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/return/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/return/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/return/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvc2VydmUvYmFnQ2hlY2svaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/serve/bagCheck/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/serve/bagCheck/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/serve/bagCheck/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
+2 -2
View File
@@ -6874,9 +6874,9 @@ function initOnError() {
};
}
function initRuntimeSocketService() {
const hosts = "192.168.1.15,127.0.0.1";
const hosts = "127.0.0.1,192.168.10.22,10.8.0.5";
const port = "8090";
const id = "mp-weixin_DyxEKd";
const id = "mp-weixin_PMV8-V";
const lazy = typeof swan !== "undefined";
let restoreError = lazy ? () => {
} : initOnError();
+146 -123
View File
@@ -23,9 +23,22 @@ const _sfc_main = {
},
onLoad(options) {
this.deviceId = options.deviceNo;
if (options.feeConfig) {
try {
common_vendor.index.__f__("log", "at pages/device/detail.vue:117", "从URL获取到feeConfig:", options.feeConfig);
const feeConfigStr = decodeURIComponent(options.feeConfig);
this.deviceInfo = { ...this.deviceInfo, feeConfig: feeConfigStr };
this.parseFeeConfig();
} catch (e) {
common_vendor.index.__f__("error", "at pages/device/detail.vue:124", "解析URL中的feeConfig失败:", e);
this.checkOrderStatus();
common_vendor.index.__f__("log", "at pages/device/detail.vue:114", options.deviceNo);
this.getDeviceInfo();
}
} else {
this.checkOrderStatus();
common_vendor.index.__f__("log", "at pages/device/detail.vue:132", options.deviceNo);
this.getDeviceInfo();
}
},
methods: {
// 检查登录状态和订单
@@ -54,115 +67,7 @@ const _sfc_main = {
};
}
}
if (this.deviceInfo.feeConfig) {
try {
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
if (feeConfig.length > 0 && "hour" in feeConfig[0] && "timesPrice" in feeConfig[0]) {
this.packages = feeConfig.map((pkg) => {
const hour = pkg.hour;
const price = pkg.timesPrice;
const unitPrice = (price / hour).toFixed(2);
return {
time: `${hour}小时`,
price: price.toFixed(2),
unitPrice,
hour
// 添加小时信息,用于后续处理
};
});
this.packages.sort((a, b) => a.hour - b.hour);
} else {
const commonConfig = feeConfig.find((item) => item.specCode === "common") || feeConfig[0];
if (commonConfig) {
if (this.deviceInfo.feeType === "hour") {
const hourPrice = commonConfig.hourPrice > 0 ? commonConfig.hourPrice : commonConfig.timesPrice / 6;
this.packages = [
{
time: "1小时",
price: hourPrice.toFixed(2),
unitPrice: hourPrice.toFixed(2)
},
{
time: "6小时",
price: (hourPrice * 6).toFixed(2),
unitPrice: hourPrice.toFixed(2)
},
{
time: "12小时",
price: (hourPrice * 12).toFixed(2),
unitPrice: hourPrice.toFixed(2)
}
];
} else if (this.deviceInfo.feeType === "times") {
const timesPrice = commonConfig.timesPrice;
this.packages = [
{
time: "1次",
price: timesPrice.toFixed(2),
unitPrice: timesPrice.toFixed(2)
}
];
} else {
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00"
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67"
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25"
}
];
}
}
}
this.selectedPackage = Math.min(1, this.packages.length - 1);
} catch (e) {
common_vendor.index.__f__("error", "at pages/device/detail.vue:238", "解析设备费用配置失败:", e);
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00"
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67"
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25"
}
];
}
} else {
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00"
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67"
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25"
}
];
}
this.parseFeeConfig();
}
},
// 显示登录提示
@@ -226,16 +131,7 @@ const _sfc_main = {
});
return;
}
const selectedPkg = this.packages[this.selectedPackage];
common_vendor.index.showModal({
title: "确认租借",
content: `确认支付押金¥{{ depositAmount }}及${selectedPkg.time}套餐费用¥${selectedPkg.price}`,
success: (res) => {
if (res.confirm) {
this.submitRentOrder();
}
}
});
},
// 提交租借订单
async submitRentOrder() {
@@ -264,19 +160,19 @@ const _sfc_main = {
packagePrice: parseFloat(selectedPkg.price)
});
if (updateRes.code !== 200) {
common_vendor.index.__f__("warn", "at pages/device/detail.vue:406", "更新订单套餐信息失败:", updateRes.msg);
common_vendor.index.__f__("warn", "at pages/device/detail.vue:292", "更新订单套餐信息失败:", updateRes.msg);
} else {
common_vendor.index.__f__("log", "at pages/device/detail.vue:409", "订单套餐信息已提前更新");
common_vendor.index.__f__("log", "at pages/device/detail.vue:295", "订单套餐信息已提前更新");
}
} catch (updateError) {
common_vendor.index.__f__("error", "at pages/device/detail.vue:412", "更新订单套餐信息时出错:", updateError);
common_vendor.index.__f__("error", "at pages/device/detail.vue:298", "更新订单套餐信息时出错:", updateError);
}
const deposit = parseFloat(this.depositAmount);
const packagePrice = parseFloat(selectedPkg.price);
const totalAmount = (deposit + packagePrice).toFixed(2);
common_vendor.index.hideLoading();
common_vendor.index.redirectTo({
url: `/pages/order/payment?orderId=${order.orderId}&packageTimeHours=${selectedPkg.time.replace("小时", "")}&packagePrice=${selectedPkg.price}&totalAmount=${totalAmount}&depositAmount=${this.depositAmount}`
url: `/pages/order/payment?orderId=${order.orderId}&packageTimeHours=${selectedPkg.time.replace("小时", "")}&packagePrice=${selectedPkg.price}&totalAmount=${totalAmount}&depositAmount=${this.depositAmount}${this.deviceInfo && this.deviceInfo.feeConfig ? "&feeConfig=" + encodeURIComponent(this.deviceInfo.feeConfig) : ""}`
});
} catch (error) {
common_vendor.index.hideLoading();
@@ -285,6 +181,133 @@ const _sfc_main = {
icon: "none"
});
}
},
// 单独抽取解析feeConfig的逻辑
parseFeeConfig() {
if (this.deviceInfo.feeConfig) {
try {
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
if (feeConfig.length > 0 && "hour" in feeConfig[0] && "timesPrice" in feeConfig[0]) {
this.packages = feeConfig.map((pkg) => {
const hour = pkg.hour;
const price = pkg.timesPrice;
const unitPrice = (price / hour).toFixed(2);
return {
time: `${hour}小时`,
price: price.toFixed(2),
unitPrice,
hour
// 添加小时信息,用于后续处理
};
});
this.packages.sort((a, b) => a.hour - b.hour);
} else {
const commonConfig = feeConfig.find((item) => item.specCode === "common") || feeConfig[0];
if (commonConfig) {
if (this.deviceInfo.feeType === "hour") {
const hourPrice = commonConfig.hourPrice > 0 ? commonConfig.hourPrice : commonConfig.timesPrice / 6;
this.packages = [
{
time: "1小时",
price: hourPrice.toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 1
},
{
time: "6小时",
price: (hourPrice * 6).toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 6
},
{
time: "12小时",
price: (hourPrice * 12).toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 12
}
];
} else if (this.deviceInfo.feeType === "times") {
const timesPrice = commonConfig.timesPrice;
this.packages = [
{
time: "1次",
price: timesPrice.toFixed(2),
unitPrice: timesPrice.toFixed(2),
hour: 1
}
];
} else {
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00",
hour: 1
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67",
hour: 6
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25",
hour: 12
}
];
}
}
}
this.selectedPackage = Math.min(1, this.packages.length - 1);
} catch (e) {
common_vendor.index.__f__("error", "at pages/device/detail.vue:419", "解析设备费用配置失败:", e);
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00",
hour: 1
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67",
hour: 6
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25",
hour: 12
}
];
this.selectedPackage = 1;
}
} else {
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00",
hour: 1
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67",
hour: 6
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25",
hour: 12
}
];
this.selectedPackage = 1;
}
}
}
};
+49 -9
View File
@@ -2,6 +2,7 @@
const common_vendor = require("../../common/vendor.js");
const util_index = require("../../util/index.js");
const config_url = require("../../config/url.js");
const config_user = require("../../config/user.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
methods: {
@@ -14,8 +15,8 @@ const _sfc_main = {
});
});
let deviceNo = util_index.getQueryString(scanResult.path, "deviceNo");
common_vendor.index.__f__("log", "at pages/index/index.vue:67", "扫码路径:", scanResult.path);
common_vendor.index.__f__("log", "at pages/index/index.vue:68", "解析到的设备号:", deviceNo);
common_vendor.index.__f__("log", "at pages/index/index.vue:68", "扫码路径:", scanResult.path);
common_vendor.index.__f__("log", "at pages/index/index.vue:69", "解析到的设备号:", deviceNo);
if (!deviceNo) {
common_vendor.index.showToast({
title: "无效的设备二维码",
@@ -34,14 +35,14 @@ const _sfc_main = {
"Clientid": common_vendor.index.getStorageSync("client_id")
}
});
common_vendor.index.__f__("log", "at pages/index/index.vue:93", "使用中订单检查结果:", JSON.stringify(inUseRes));
common_vendor.index.__f__("log", "at pages/index/index.vue:94", "使用中订单检查结果:", JSON.stringify(inUseRes));
if (inUseRes.statusCode == 200 && inUseRes.data.code == 200 && inUseRes.data.data) {
const inUseOrder = inUseRes.data.data;
common_vendor.index.__f__("log", "at pages/index/index.vue:98", "检测到使用中订单,准备跳转:", inUseOrder);
common_vendor.index.__f__("log", "at pages/index/index.vue:99", "检测到使用中订单,准备跳转:", inUseOrder);
common_vendor.index.reLaunch({
url: `/pages/return/index?orderId=${inUseOrder.orderId}&deviceId=${deviceNo || inUseOrder.deviceNo}`
});
common_vendor.index.__f__("log", "at pages/index/index.vue:104", "已发起页面跳转");
common_vendor.index.__f__("log", "at pages/index/index.vue:105", "已发起页面跳转");
return;
}
const orderRes = await common_vendor.index.request({
@@ -52,21 +53,60 @@ const _sfc_main = {
"Clientid": common_vendor.index.getStorageSync("client_id")
}
});
common_vendor.index.__f__("log", "at pages/index/index.vue:118", "待支付订单检查结果:", JSON.stringify(orderRes));
common_vendor.index.__f__("log", "at pages/index/index.vue:119", "待支付订单检查结果:", JSON.stringify(orderRes));
if (orderRes.statusCode == 200 && orderRes.data.code == 200 && orderRes.data.data) {
const unpaidOrder = orderRes.data.data;
common_vendor.index.__f__("log", "at pages/index/index.vue:123", "检测到待支付订单,准备跳转:", unpaidOrder);
common_vendor.index.__f__("log", "at pages/index/index.vue:124", "检测到待支付订单,准备跳转:", unpaidOrder);
common_vendor.index.navigateTo({
url: `/pages/order/payment?orderId=${unpaidOrder.orderId}`
});
} else {
common_vendor.index.__f__("log", "at pages/index/index.vue:129", "无待支付订单,直接跳转到设备详情页面, deviceNo:", deviceNo);
common_vendor.index.__f__("log", "at pages/index/index.vue:130", "无待支付订单,获取设备信息, deviceNo:", deviceNo);
try {
const deviceInfoRes = await config_user.getDeviceInfo(deviceNo);
if (deviceInfoRes.code == 200 && deviceInfoRes.data && deviceInfoRes.data.device) {
const deviceInfo = deviceInfoRes.data.device;
if (deviceInfo.feeConfig) {
common_vendor.index.__f__("log", "at pages/index/index.vue:141", "获取到设备feeConfig信息:", deviceInfo.feeConfig);
try {
const feeConfig = JSON.parse(deviceInfo.feeConfig);
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}&feeConfig=${encodeURIComponent(deviceInfo.feeConfig)}`
});
} catch (e) {
common_vendor.index.__f__("error", "at pages/index/index.vue:152", "解析feeConfig失败:", e);
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
} else {
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
} else {
common_vendor.index.__f__("error", "at pages/index/index.vue:166", "获取设备信息失败:", deviceInfoRes.msg || "未知错误");
common_vendor.index.showToast({
title: "获取设备信息失败",
icon: "none"
});
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:135", "扫码处理失败:", error);
common_vendor.index.__f__("error", "at pages/index/index.vue:178", "获取设备信息异常:", error);
common_vendor.index.showToast({
title: "获取设备信息失败",
icon: "none"
});
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:191", "扫码处理失败:", error);
common_vendor.index.showToast({
title: "扫码失败",
icon: "none"
+35 -49
View File
@@ -30,6 +30,19 @@ const _sfc_main = {
const deposit = parseFloat(this.orderInfo.deposit || this.passedDepositAmount || 99);
const packagePrice = parseFloat(this.packageInfo.price || 0);
return (deposit + packagePrice).toFixed(2);
},
// 计算每小时的价格
hourlyRate() {
const price = parseFloat(this.packageInfo.price || 0);
let time = parseFloat(this.packageInfo.time || 1);
if (this.packageInfo.time && this.packageInfo.time.includes("分钟")) {
time = time / 60;
} else if (this.packageInfo.time && this.packageInfo.time.includes("次")) {
return price.toFixed(2);
}
if (time <= 0)
time = 1;
return (price / time).toFixed(2);
}
},
onLoad(options) {
@@ -41,6 +54,15 @@ const _sfc_main = {
if (options.depositAmount) {
this.passedDepositAmount = options.depositAmount;
}
if (options.feeConfig) {
try {
common_vendor.index.__f__("log", "at pages/order/payment.vue:135", "从URL获取到feeConfig:", options.feeConfig);
const feeConfigStr = decodeURIComponent(options.feeConfig);
this.deviceInfo = { feeConfig: feeConfigStr };
} catch (e) {
common_vendor.index.__f__("error", "at pages/order/payment.vue:140", "解析URL中的feeConfig失败:", e);
}
}
this.loadOrderInfo();
} else {
common_vendor.index.showToast({
@@ -72,7 +94,7 @@ const _sfc_main = {
formattedTime = this.formatTime(/* @__PURE__ */ new Date());
}
} catch (e) {
common_vendor.index.__f__("error", "at pages/order/payment.vue:149", "时间格式化错误:", e);
common_vendor.index.__f__("error", "at pages/order/payment.vue:180", "时间格式化错误:", e);
formattedTime = this.formatTime(/* @__PURE__ */ new Date());
}
this.orderInfo = {
@@ -82,6 +104,13 @@ const _sfc_main = {
phone: orderData.phone,
deposit: this.passedDepositAmount || orderData.depositAmount || "99.00"
};
if (orderData.packageTime && orderData.packagePrice) {
const timeInHours = (parseFloat(orderData.packageTime) / 60).toFixed(1);
this.packageInfo = {
time: timeInHours.toString(),
price: orderData.packagePrice.toString()
};
}
this.deviceNo = orderData.deviceNo;
await this.loadDeviceInfo();
} else {
@@ -96,7 +125,7 @@ const _sfc_main = {
});
}
},
// 加载设备信息并解析套餐
// 加载设备信息
async loadDeviceInfo() {
if (!this.deviceNo)
return;
@@ -104,55 +133,12 @@ const _sfc_main = {
const res = await config_user.getDeviceInfo(this.deviceNo);
if (res.code === 200 && res.data) {
this.deviceInfo = res.data.device;
if (this.deviceInfo && this.deviceInfo.feeConfig) {
try {
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
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) => {
if (Math.abs(pkg.Hour - targetHours) < Math.abs(closestPackage.Hour - targetHours)) {
closestPackage = pkg;
}
});
this.packageInfo.time = closestPackage.Hour.toString();
this.packageInfo.price = closestPackage.Price.toString();
} else {
const selectedConfig = feeConfig.find((item) => item.specCode === "common") || feeConfig[0];
if (selectedConfig) {
const packageHours = 6;
if (this.deviceInfo.feeType === "times") {
this.packageInfo.price = selectedConfig.timesPrice.toString();
this.packageInfo.time = "1次";
} else if (this.deviceInfo.feeType === "hour") {
if (selectedConfig.hourPrice > 0) {
this.packageInfo.price = (selectedConfig.hourPrice * packageHours).toString();
} else {
this.packageInfo.price = selectedConfig.timesPrice.toString();
}
this.packageInfo.time = packageHours.toString();
} else {
this.packageInfo.price = selectedConfig.timesPrice.toString();
this.packageInfo.time = packageHours.toString();
}
}
}
} catch (e) {
common_vendor.index.__f__("error", "at pages/order/payment.vue:252", "解析设备费用配置失败:", e);
}
}
if (this.deviceInfo && this.deviceInfo.depositAmount) {
this.orderInfo.deposit = this.deviceInfo.depositAmount;
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/order/payment.vue:262", "获取设备信息失败:", error);
common_vendor.index.__f__("error", "at pages/order/payment.vue:234", "获取设备信息失败:", error);
}
},
// 处理支付
@@ -181,7 +167,7 @@ const _sfc_main = {
try {
await config_user.updateUserBalance(this.orderId);
} catch (error) {
common_vendor.index.__f__("warn", "at pages/order/payment.vue:299", "更新用户余额失败:", error);
common_vendor.index.__f__("warn", "at pages/order/payment.vue:271", "更新用户余额失败:", error);
}
setTimeout(() => {
common_vendor.index.redirectTo({
@@ -190,7 +176,7 @@ const _sfc_main = {
}, 1500);
},
fail: (err) => {
common_vendor.index.__f__("error", "at pages/order/payment.vue:310", "支付失败:", err);
common_vendor.index.__f__("error", "at pages/order/payment.vue:282", "支付失败:", err);
throw new Error("支付失败,请重试");
}
});
@@ -287,7 +273,7 @@ const _sfc_main = {
throw new Error("查询订单状态失败");
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/order/payment.vue:418", "查询订单状态错误:", error);
common_vendor.index.__f__("error", "at pages/order/payment.vue:390", "查询订单状态错误:", error);
return null;
}
}
+2 -2
View File
@@ -18,12 +18,12 @@
}
},
"compileType": "miniprogram",
"libVersion": "3.8.0",
"libVersion": "3.8.1",
"appid": "wxe752f45e7f7aa271",
"projectname": "fs",
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
"tabSize": 4
}
}