From eb3db99cb8282a472bd7719d6ce2beb4ca0d1c09 Mon Sep 17 00:00:00 2001 From: LinCyJang Date: Sun, 2 Aug 2026 11:02:10 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A5595=20=E3=80=90=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E3=80=91=E7=A4=BC=E5=93=81=E9=9B=86?= =?UTF-8?q?=E9=87=87=E4=B8=AD=E5=BF=83=E6=94=B6=E5=88=B0=E7=A4=BC=E5=93=81?= =?UTF-8?q?=EF=BC=8C=E5=9C=A8=E5=95=86=E5=9F=8E=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?-=E6=88=91=E7=9A=84=E7=A4=BC=E5=93=81=E5=8D=A1-=E6=94=B6?= =?UTF-8?q?=E5=88=B0=E7=9A=84=EF=BC=8C=E6=9C=AA=E6=98=BE=E7=A4=BA=E5=95=86?= =?UTF-8?q?=E5=93=81=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg_user/views/giftList.vue | 62 ++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/pkg_user/views/giftList.vue b/pkg_user/views/giftList.vue index 6e2f5e3..180ca54 100644 --- a/pkg_user/views/giftList.vue +++ b/pkg_user/views/giftList.vue @@ -138,7 +138,7 @@ class="gift-item" > - {{ cart.productInfo.storeName }} + {{ cart._displayName }} - - {{ cart.productInfo.attrInfo.sku }} + + {{ cart._displaySku }} - + - {{ cart.productInfo.attrInfo.price }} + {{ cart._displayPrice }} @@ -442,7 +442,8 @@ export default { const { success, data } = res if (success) { const { list, hasMore } = this.getListResult(data, page) - this.receiveList = page === 1 ? list : this.receiveList.concat(list) + const formatList = list.map(item => this.normalizeReceiveGiftItem(item)) + this.receiveList = page === 1 ? formatList : this.receiveList.concat(formatList) this.receiveHasMore = hasMore this.receivePage = page + 1 this.receiveInited = true @@ -526,6 +527,51 @@ export default { } return status }, + normalizeReceiveGiftItem(item = {}) { + return { + ...item, + _renderGiftInfos: this.getReceiveGiftInfos(item) + } + }, + getReceiveGiftInfos(item = {}) { + if (item.customGiftInfo && typeof item.customGiftInfo === 'object') { + const customGift = this.formatCustomGiftInfo(item.customGiftInfo) + if (customGift) { + return [customGift] + } + } + const giftInfos = Array.isArray(item.giftInfos) ? item.giftInfos : [] + return giftInfos.map(gift => this.formatDefaultGiftInfo(gift)) + }, + formatCustomGiftInfo(customGiftInfo = {}) { + const giftImage = typeof customGiftInfo.giftImage === 'string' + ? customGiftInfo.giftImage.trim() + : '' + const giftValue = customGiftInfo.giftValue + const hasGiftValue = giftValue !== '' && giftValue !== null && giftValue !== undefined + return { + ...customGiftInfo, + _isCustomGift: true, + _displayImage: giftImage, + _displayName: customGiftInfo.giftName || '', + _displaySku: customGiftInfo.specName || '', + _displayPrice: hasGiftValue ? giftValue : '', + _showPrice: Number(customGiftInfo.isShowValue) === 1 && hasGiftValue + } + }, + formatDefaultGiftInfo(gift = {}) { + const productInfo = gift.productInfo || {} + const attrInfo = productInfo.attrInfo || {} + const price = attrInfo.price + return { + ...gift, + _displayImage: productInfo.image || '', + _displayName: productInfo.storeName || '', + _displaySku: attrInfo.sku || '', + _displayPrice: price, + _showPrice: price !== '' && price !== null && price !== undefined + } + }, showTips() { this.$refs.giftTips.showTips = true },