|
|
|
@ -338,6 +338,22 @@ function formatDateTime(dateString) { |
|
|
|
return dateString; |
|
|
|
} |
|
|
|
|
|
|
|
// 格式化价格,解决浮点数精度问题
|
|
|
|
function formatPrice(price) { |
|
|
|
if (price === null || price === undefined) { |
|
|
|
return price; |
|
|
|
} |
|
|
|
|
|
|
|
// 转换为数字
|
|
|
|
const numPrice = parseFloat(price); |
|
|
|
if (isNaN(numPrice)) { |
|
|
|
return price; |
|
|
|
} |
|
|
|
|
|
|
|
// 格式化到一位小数
|
|
|
|
return parseFloat(numPrice.toFixed(1)); |
|
|
|
} |
|
|
|
|
|
|
|
// 格式化北京时间的函数
|
|
|
|
function formatBeijingTime(dateString) { |
|
|
|
if (!dateString) return '未知时间'; |
|
|
|
@ -793,9 +809,9 @@ Page({ |
|
|
|
} |
|
|
|
|
|
|
|
const priceRange = middlePrice < 20 ? 1 : 5; |
|
|
|
const minPrice = middlePrice - priceRange; |
|
|
|
const maxPrice = middlePrice + priceRange; |
|
|
|
const defaultPrice = parseFloat(middlePrice.toFixed(2)); |
|
|
|
const minPrice = formatPrice(middlePrice - priceRange); |
|
|
|
const maxPrice = formatPrice(middlePrice + priceRange); |
|
|
|
const defaultPrice = formatPrice(middlePrice); |
|
|
|
const priceThreshold = middlePrice < 20 ? 0.1 : 2; |
|
|
|
|
|
|
|
console.log('计算后的价格数据:', { |
|
|
|
@ -855,9 +871,9 @@ Page({ |
|
|
|
} |
|
|
|
|
|
|
|
const priceRange = middlePrice < 20 ? 1 : 5; |
|
|
|
const minPrice = middlePrice - priceRange; |
|
|
|
const maxPrice = middlePrice + priceRange; |
|
|
|
const currentPrice = parseFloat(middlePrice.toFixed(2)); |
|
|
|
const minPrice = formatPrice(middlePrice - priceRange); |
|
|
|
const maxPrice = formatPrice(middlePrice + priceRange); |
|
|
|
const currentPrice = formatPrice(middlePrice); |
|
|
|
const priceThreshold = middlePrice < 20 ? 0.3 : 2; |
|
|
|
|
|
|
|
console.log('选择规格 - 价格数据:', { |
|
|
|
@ -926,7 +942,7 @@ Page({ |
|
|
|
|
|
|
|
if (bargainPrice > minPrice) { |
|
|
|
const step = bargainPrice < 20 ? 0.1 : 1; |
|
|
|
const newPrice = parseFloat((bargainPrice - step).toFixed(2)); |
|
|
|
const newPrice = formatPrice(bargainPrice - step); |
|
|
|
console.log('计算新价格:', newPrice); |
|
|
|
this.updatePrice(newPrice); |
|
|
|
} |
|
|
|
@ -943,7 +959,7 @@ Page({ |
|
|
|
|
|
|
|
if (bargainPrice < maxPrice) { |
|
|
|
const step = bargainPrice < 20 ? 0.1 : 1; |
|
|
|
const newPrice = parseFloat((bargainPrice + step).toFixed(2)); |
|
|
|
const newPrice = formatPrice(bargainPrice + step); |
|
|
|
console.log('计算新价格:', newPrice); |
|
|
|
this.updatePrice(newPrice); |
|
|
|
} |
|
|
|
@ -954,7 +970,7 @@ Page({ |
|
|
|
const { minPrice, maxPrice } = this.data; |
|
|
|
const clampedPrice = Math.max(minPrice, Math.min(maxPrice, newPrice)); |
|
|
|
const progress = ((clampedPrice - minPrice) / (maxPrice - minPrice)) * 100; |
|
|
|
const finalPrice = parseFloat(clampedPrice.toFixed(2)); |
|
|
|
const finalPrice = formatPrice(clampedPrice); |
|
|
|
|
|
|
|
console.log('更新价格:', { |
|
|
|
inputPrice: newPrice, |
|
|
|
@ -1018,8 +1034,10 @@ Page({ |
|
|
|
|
|
|
|
if (!isNaN(price)) { |
|
|
|
const clampedPrice = Math.max(minPrice, Math.min(maxPrice, price)); |
|
|
|
const formattedPrice = formatPrice(clampedPrice); |
|
|
|
console.log('计算后的价格:', clampedPrice); |
|
|
|
this.updatePrice(clampedPrice); |
|
|
|
console.log('格式化后的价格:', formattedPrice); |
|
|
|
this.updatePrice(formattedPrice); |
|
|
|
} |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
@ -1056,11 +1074,7 @@ Page({ |
|
|
|
const priceRange = maxPrice - minPrice; |
|
|
|
let price = minPrice + (progress / 100) * priceRange; |
|
|
|
|
|
|
|
if (bargainPrice < 20) { |
|
|
|
price = Math.round(price * 10) / 10; |
|
|
|
} else { |
|
|
|
price = Math.round(price); |
|
|
|
} |
|
|
|
price = formatPrice(price); |
|
|
|
|
|
|
|
const clampedPrice = Math.max(minPrice, Math.min(maxPrice, price)); |
|
|
|
|
|
|
|
|