From f781deb18e65ddfd68f5b1bfa731c616d9ad7d43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?=
<15778543+xufeiyang6017@user.noreply.gitee.com>
Date: Fri, 23 Jan 2026 17:04:58 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AF=84=E4=BC=B0=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=E7=9B=B8=E5=85=B3=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/evaluate1/index.js | 12 +++++++++---
pages/evaluate1/spec-detail.js | 33 +++++++++++++++++++++-----------
pages/evaluate1/spec-detail.wxml | 6 +++---
3 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/pages/evaluate1/index.js b/pages/evaluate1/index.js
index 068a77b..4bd1b80 100644
--- a/pages/evaluate1/index.js
+++ b/pages/evaluate1/index.js
@@ -204,7 +204,7 @@ Page({
// 解析规格
const specInfo = this.parseSpecification(spec);
- let finalPrice = price;
+ let finalPrice = parseFloat(price) || 0;
let finalPriceText = price;
// 根据规格类型和价格水平计算最终价格
@@ -222,13 +222,17 @@ Page({
}
}
- return {
+ const specObj = {
name: spec,
price: price,
priceText: price,
finalPrice: finalPrice,
finalPriceText: finalPriceText
};
+
+ console.log('创建的规格对象:', specObj);
+
+ return specObj;
});
console.log('提取的规格和价格:', specifications);
@@ -243,8 +247,10 @@ Page({
// 跳转到规格详情页面
goToSpecDetail(e) {
const specItem = e.currentTarget.dataset.spec;
+ console.log('点击的规格项:', specItem);
+ console.log('传递的价格:', specItem.finalPriceText);
wx.navigateTo({
- url: `/pages/evaluate1/spec-detail?productName=${encodeURIComponent(this.data.productName)}&specification=${encodeURIComponent(specItem.name)}&price=${encodeURIComponent(specItem.finalPrice)}`
+ url: `/pages/evaluate1/spec-detail?productName=${encodeURIComponent(this.data.productName)}&specification=${encodeURIComponent(specItem.name)}&price=${encodeURIComponent(specItem.finalPriceText)}`
});
},
diff --git a/pages/evaluate1/spec-detail.js b/pages/evaluate1/spec-detail.js
index 9e429e6..0a47a20 100644
--- a/pages/evaluate1/spec-detail.js
+++ b/pages/evaluate1/spec-detail.js
@@ -9,29 +9,40 @@ Page({
error: ''
},
onLoad(options) {
- if (options.productName && options.specification && options.price) {
- const price = parseFloat(options.price) || 0;
- this.setData({
- productName: decodeURIComponent(options.productName),
- specification: decodeURIComponent(options.specification),
- price: price,
- totalPrice: price
- });
+ console.log('接收到的参数:', options);
+ // 即使参数不完整,也要尝试获取并设置
+ const productName = options.productName ? decodeURIComponent(options.productName) : '';
+ const specification = options.specification ? decodeURIComponent(options.specification) : '';
+ let price = 0;
+
+ if (options.price) {
+ const decodedPrice = decodeURIComponent(options.price);
+ console.log('解码后的价格:', decodedPrice);
+ price = parseFloat(decodedPrice) || 0;
}
+
+ console.log('解析后的参数:', { productName, specification, price });
+
+ this.setData({
+ productName: productName,
+ specification: specification,
+ price: price,
+ totalPrice: 0 // 初始时总价为0,不显示
+ });
},
// 件数输入变化
onQuantityChange(e) {
const quantity = parseInt(e.detail.value) || 1;
this.setData({
- quantity: quantity,
- totalPrice: this.data.price * quantity
+ quantity: quantity
+ // 只更新件数,不更新总价,等待点击计算按钮
});
},
// 计算价格
calculatePrice() {
- const totalPrice = this.data.price * this.data.quantity;
+ const totalPrice = Math.round(this.data.price * this.data.quantity * 10) / 10;
this.setData({
totalPrice: totalPrice
});
diff --git a/pages/evaluate1/spec-detail.wxml b/pages/evaluate1/spec-detail.wxml
index 9a3c101..701718f 100644
--- a/pages/evaluate1/spec-detail.wxml
+++ b/pages/evaluate1/spec-detail.wxml
@@ -11,7 +11,7 @@
单价:
- ¥{{price.toFixed(2)}}
+ ¥{{price || 0}}
您已选择此规格进行估价
@@ -34,8 +34,8 @@
- 总价:
- ¥{{totalPrice.toFixed(2)}}
+ 预估:
+ ¥{{totalPrice > 0 ? totalPrice : ''}}