修复:补充提交课程与图书选择商品公共组件价格处理
This commit is contained in:
@@ -235,16 +235,6 @@ async function loadBookInfo() {
|
|||||||
|
|
||||||
if (res.bookInfo) {
|
if (res.bookInfo) {
|
||||||
bookInfo.value = res.bookInfo
|
bookInfo.value = res.bookInfo
|
||||||
goodsList.value = [{
|
|
||||||
productId: bookId.value,
|
|
||||||
productName: bookInfo.value.name,
|
|
||||||
productImages: bookInfo.value.images,
|
|
||||||
price: bookInfo.value.abroadPrice || 0,
|
|
||||||
vipPrice: null,
|
|
||||||
activityPrice: null,
|
|
||||||
isVipPrice: 0,
|
|
||||||
productAmount: 1,
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load book info:', error)
|
console.error('Failed to load book info:', error)
|
||||||
|
|||||||
@@ -56,4 +56,22 @@ export const copyToClipboard = (content: string, title: string = '') => {
|
|||||||
console.error('复制失败:', error)
|
console.error('复制失败:', error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算最低价格
|
||||||
|
*/
|
||||||
|
export const calculateLowestPrice = (priceData: object): { key: string, value: number } => {
|
||||||
|
const validEntries = Object.entries(priceData)
|
||||||
|
.filter(([, value]) => typeof value === 'number' && value !== 0);
|
||||||
|
|
||||||
|
if (validEntries.length === 0) {
|
||||||
|
throw new Error('No valid non-zero price found in the data');
|
||||||
|
}
|
||||||
|
|
||||||
|
const [minKey, minValue] = validEntries.reduce((min, curr) =>
|
||||||
|
curr[1] < min[1] ? curr : min
|
||||||
|
);
|
||||||
|
|
||||||
|
return { key: minKey, value: minValue };
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user