From 110050ca587a800d4cca438c7fa0f714cba4c765 Mon Sep 17 00:00:00 2001 From: chenghuan Date: Wed, 26 Nov 2025 09:25:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=AF=BE=E7=A8=8B=E4=B8=8E=E5=9B=BE=E4=B9=A6?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=95=86=E5=93=81=E5=85=AC=E5=85=B1=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=BB=B7=E6=A0=BC=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/book/detail.vue | 10 ---------- utils/index.ts | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pages/book/detail.vue b/pages/book/detail.vue index af1b647..01b5002 100644 --- a/pages/book/detail.vue +++ b/pages/book/detail.vue @@ -235,16 +235,6 @@ async function loadBookInfo() { if (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) { console.error('Failed to load book info:', error) diff --git a/utils/index.ts b/utils/index.ts index 7490f19..8d31e23 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -56,4 +56,22 @@ export const copyToClipboard = (content: string, title: string = '') => { 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 }; } \ No newline at end of file