Browse Source

更新评估页面相关文件

pull/19/head
徐飞洋 1 month ago
parent
commit
f781deb18e
  1. 12
      pages/evaluate1/index.js
  2. 33
      pages/evaluate1/spec-detail.js
  3. 6
      pages/evaluate1/spec-detail.wxml

12
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)}`
});
},

33
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
});

6
pages/evaluate1/spec-detail.wxml

@ -11,7 +11,7 @@
</view>
<view class="spec-item">
<text class="label">单价:</text>
<text class="value price">¥{{price.toFixed(2)}}</text>
<text class="value price">¥{{price || 0}}</text>
</view>
<view class="spec-info">
<text>您已选择此规格进行估价</text>
@ -34,8 +34,8 @@
</view>
<view class="result-section">
<text class="result-label">总价:</text>
<text class="result-value">¥{{totalPrice.toFixed(2)}}</text>
<text class="result-label">预估:</text>
<text class="result-value">¥{{totalPrice > 0 ? totalPrice : ''}}</text>
</view>
<view class="action">

Loading…
Cancel
Save