价格计算:最低价/均价模式+占位降价+最低书价+搜索后自动填充
This commit is contained in:
parent
eb6fc6f38f
commit
12330f64b5
@ -840,6 +840,28 @@ export default {
|
||||
}
|
||||
return this.selectedCondition ? (map[this.selectedCondition] || '') : ''
|
||||
},
|
||||
calculatedPrice() {
|
||||
const sorted = this.sortedProductList
|
||||
if (sorted.length === 0) return 0
|
||||
const shipping = Number(this.shippingFee) || 0
|
||||
const discount = Number(this.priceDiscount) || 0
|
||||
const minPrice = Number(this.minBookPrice) || 0
|
||||
let result = 0
|
||||
if (this.priceMode === 'lowest') {
|
||||
const idx = Math.min((Number(this.lowestRank) || 1) - 1, sorted.length - 1)
|
||||
const selectedTotal = parseFloat(sorted[idx].totalPrice) || 0
|
||||
result = selectedTotal - shipping - discount
|
||||
} else {
|
||||
const count = Math.min(Number(this.averageCount) || 2, sorted.length)
|
||||
let sum = 0
|
||||
for (let i = 0; i < count; i++) {
|
||||
sum += parseFloat(sorted[i].totalPrice) || 0
|
||||
}
|
||||
result = (sum / count) - shipping - discount
|
||||
}
|
||||
if (result <= minPrice) return minPrice
|
||||
return parseFloat(result.toFixed(2))
|
||||
},
|
||||
sortedProductList() {
|
||||
let list = [...this.productList]
|
||||
// 筛选(精确匹配,同zhizhu)
|
||||
@ -1028,6 +1050,12 @@ export default {
|
||||
bookId: item.id || ''
|
||||
}
|
||||
})
|
||||
// 自动填充计算价格
|
||||
this.$nextTick(() => {
|
||||
if (this.calculatedPrice > 0) {
|
||||
this.price = String(this.calculatedPrice)
|
||||
}
|
||||
})
|
||||
}
|
||||
// 市场统计:使用facet接口的真实数据(totalFound为准)
|
||||
this.marketData = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user