diff --git a/api/gift.js b/api/gift.js index 17e7767..7664480 100644 --- a/api/gift.js +++ b/api/gift.js @@ -148,3 +148,15 @@ export function aiGiftImageStatus(params) { login: true }) } + +/** + * 获取商品以前使用过的AI礼品卡图片 + * @param {*} params + * @returns + */ + +export function aiGiftImageHistory(params) { + return request.get("/giftCard/aiGiftImages/history?productId=" + params.productId, { + login: true + }) +} diff --git a/pkg_user/views/gift/components/AiHistoryCoverPicker.vue b/pkg_user/views/gift/components/AiHistoryCoverPicker.vue new file mode 100644 index 0000000..2782b1f --- /dev/null +++ b/pkg_user/views/gift/components/AiHistoryCoverPicker.vue @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + 确定 + + + 礼包封面在对方领取时展示 + (*图片由云灵AI生成,仅供参考) + + + + + + + diff --git a/pkg_user/views/gift/gift.vue b/pkg_user/views/gift/gift.vue index 0329c7e..6c88272 100644 --- a/pkg_user/views/gift/gift.vue +++ b/pkg_user/views/gift/gift.vue @@ -36,49 +36,96 @@ > - - - {{ aiCoverDesc.length }}/300 - - - - + + + {{ aiCoverDesc.length }}/300 + + + + + + + + + + + + - - - {{ aiCoverGenerateLoading ? '礼包封面生成中...' : 'AI生成礼包封面' }} - + + + + 历史图片 + + + {{ aiCoverGenerateLoading ? '礼包封面生成中...' : 'AI生成礼包封面' }} + + + - - - - - 预览 + + + 预览 + + + 重新生成 + - - 重新生成 + + + + + 预览 + + + 使用AI生成 + - + @@ -232,6 +279,12 @@ :index="aiDefaultIndex" @confirm="onAiCoverConfirm" /> + { + const { success, data } = res + if (success && data) { + this.aiHistoryCoverImgsList = data || [] + this.aiHistoryCoverImgsList.map(historyItem => { + historyItem.cover = historyItem.coverUrl, + historyItem.image = historyItem.shareUrl, + historyItem.name = historyItem.name || '' + }) + } + }) + }, handleGenerateAiCover() { if (!this.aiCoverDesc || !this.aiCoverDesc.trim()) { uni.showToast({ @@ -577,6 +658,11 @@ export default { if (this.isCountyLotteryGift) return 0 return this.couponId || 0 }, + setCouponIdSilently(value) { + if (this.couponId === value) return + this.skipCouponIdWatch = true + this.couponId = value + }, isCountyLotteryCartItem(item) { return Number( (item && item.drawActivityId) || @@ -591,7 +677,7 @@ export default { if (!this.isCountyLotteryGift) return this.couponTitle = '' if (Number(this.couponId || 0) !== 0) { - this.couponId = 0 + this.setCouponIdSilently(0) } }, adjustCoverListForProductStory(coverList, productInfo, defaultTemplate) { @@ -636,10 +722,10 @@ export default { if (this.isCountyLotteryGift) { this.couponTitle = '' if (this.couponId !== 0) { - this.couponId = 0 + this.setCouponIdSilently(0) } } else if(useDefaultCouponId) { - this.couponId = res.data.result.defaultCouponId || 0 + this.setCouponIdSilently(res.data.result.defaultCouponId || 0) } }) }, @@ -649,6 +735,27 @@ export default { handleShowAiCover() { this.showAiCoverPicker = true }, + handleShowAiHistoryCoverPicker() { + this.showAiHistoryCoverPicker = true + }, + toggleShowAiImgHistoryListSelect(show) { + this.showAiImgHistoryListSelect = show + this.selectedAiCoverImage = {} + this.selectedCover = '' + this.giftImage = '' + this.templateId = '' + this.aiHistoryDefaultIndex = 0 + this.aiDefaultIndex = 0 + if (show) { + if (this.aiHistoryCoverImgsList.length > 0 && this.aiHistoryDefaultIndex === 0) { + const index = this.aiHistoryCoverImgsList.findIndex(item => item.isLastSelected) + if (index !== -1) { + this.aiHistoryDefaultIndex = index + } + this.handleSelectAiHistoryCover(this.aiHistoryCoverImgsList[this.aiHistoryDefaultIndex]) + } + } + }, showCouponsPopup() { if (this.isCountyLotteryGift) return if (this.couponList.usable && this.couponList.usable.length === 0) return @@ -664,7 +771,7 @@ export default { if (this.couponList.usable && this.couponList.usable.length === 0) return this.showPopup = !this.showPopup if(!item.id) { - this.couponId = 0 + this.setCouponIdSilently(0) this.couponTitle = '' if(this.isGroupBuy) { this.computedTravelGroupPrice(false) @@ -673,7 +780,7 @@ export default { } return } - this.couponId = item.id + this.setCouponIdSilently(item.id) this.couponTitle = item.couponTitle if(this.isGroupBuy) { this.computedTravelGroupPrice(false) @@ -708,7 +815,7 @@ export default { this.giftImage = this.selectedAiCoverImage.image this.templateId = this.selectedAiCoverImage.id } - this.couponId = '' + this.setCouponIdSilently('') this.computedPrice(this.goodsInfo.cartNum) }) }, @@ -745,10 +852,10 @@ export default { if (this.isCountyLotteryGift) { this.couponTitle = '' if (this.couponId !== 0) { - this.couponId = 0 + this.setCouponIdSilently(0) } } else if(!f) { - this.couponId = res.data.result.defaultCouponId || 0 + this.setCouponIdSilently(res.data.result.defaultCouponId || 0) this.$forceUpdate() } this.payPrice = res.data.result.payPrice @@ -800,6 +907,16 @@ export default { this.aiDefaultIndex = this.aiCoverImgsList.findIndex(item => item.id === cover.id) } }, + onAiHistoryCoverConfirm(cover) { + // 封面图片 + this.selectedCover = cover.cover + // 分享对话图片 + this.giftImage = cover.image + if (this.selectCoverType === 'ai') { + this.selectedAiCoverImage = cover + this.aiHistoryDefaultIndex = this.aiHistoryCoverImgsList.findIndex(item => item.id === cover.id) + } + }, handleSelectAiCover(cover) { this.selectedAiCoverImage = cover this.aiDefaultIndex = this.aiCoverImgsList.findIndex(item => item.id === cover.id) @@ -807,6 +924,13 @@ export default { this.giftImage = cover.image this.templateId = cover.id }, + handleSelectAiHistoryCover(cover) { + this.selectedAiCoverImage = cover + this.aiHistoryDefaultIndex = this.aiHistoryCoverImgsList.findIndex(item => item.id === cover.id) + this.selectedCover = cover.cover + this.giftImage = cover.image + this.templateId = cover.id + }, showTips() { this.$refs.giftTips.showTips = true }, @@ -817,25 +941,27 @@ export default { } this.loading = true getGiftCardSendOrderConfirm(params).then(res => { - const temp = this.isGroupBuy ? res.data.giftCardTemplates : res.data.giftCardTemplates.filter(e => e.isTravelGroup === 0) - const hasSpecial = res.data.giftCardTemplates.map(e => e.id).includes(res.data.specialGiftCardTemplate.id) - const initialCoverList = hasSpecial ? [...temp] : [...temp, res.data.specialGiftCardTemplate] - const goodsInfo = res.data.cartInfo[0] - const { coverList, template } = this.adjustCoverListForProductStory(initialCoverList, goodsInfo && goodsInfo.productInfo, res.data.specialGiftCardTemplate) + const data = res.data + const temp = this.isGroupBuy ? data.giftCardTemplates : data.giftCardTemplates.filter(e => e.isTravelGroup === 0) + const hasSpecial = data.giftCardTemplates.map(e => e.id).includes(data.specialGiftCardTemplate.id) + const initialCoverList = hasSpecial ? [...temp] : [...temp, data.specialGiftCardTemplate] + const goodsInfo = data.cartInfo[0] + const { coverList, template } = this.adjustCoverListForProductStory(initialCoverList, goodsInfo && goodsInfo.productInfo, data.specialGiftCardTemplate) this.coverList = coverList - this.giftNotice = res.data.giftCardGiftNotice - this.orderKey = res.data.orderKey + this.giftNotice = data.giftCardGiftNotice + this.orderKey = data.orderKey this.goodsInfo = goodsInfo this.syncCountyLotteryGiftFlag(goodsInfo) this.templateId = template.id this.selectedCover = template.cover this.giftImage = template.image - this.blindImage = res.data.giftCardBlindBoxShareImage + this.blindImage = data.giftCardBlindBoxShareImage this.defaultIndex = this.coverList.findIndex(item => item.id === this.templateId) // if(!this.couponId) { - // this.couponId = res.data.couponList.usable[0] && res.data.couponList.usable[0].id || '' + // this.couponId = data.couponList.usable[0] && data.couponList.usable[0].id || '' // } this.computedPrice(this.goodsInfo.cartNum) + this.aiGiftImageHistoryReq() this.isLoad = true }).finally(() => { this.loading = false @@ -854,6 +980,7 @@ export default { if (this.isCountyLotteryGift && this.isEligibleForDraw) { this.showLotteryGiftPopup = true } + this.aiGiftImageHistoryReq() }, closeLotteryGiftPopup() { this.showLotteryGiftPopup = false @@ -1338,10 +1465,16 @@ export default { gap: 24rpx; padding: 20rpx 0; box-sizing: border-box; + &.scrollable { + justify-content: flex-start; + flex-wrap: nowrap; + overflow-x: auto; + } } .img-image { display: block; height: 176rpx; + flex-shrink: 0; &.active { transform: scale(1.2); }
{{ aiCoverDesc.length }}/300