Fix:4777 【商城小程序】如果某商品有产品故事封面,则将产品故事封面图显示在第一位
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
<image :src="product.image" class="pro-cover-image" mode="widthFix|heightFix" />
|
||||
</view>
|
||||
<view class="good-story"
|
||||
v-if="product.productStory"
|
||||
v-if="product.productStory && item.isShowProductStory"
|
||||
:style="{
|
||||
right: (item.productStoryX*2 || 0) + 'rpx',
|
||||
top: (item.productStoryY*2 || 0) + 'rpx'
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</view>
|
||||
<view
|
||||
class="good-story"
|
||||
v-if="card.isBlind !== 1 && card.giftProducts[0].productStory"
|
||||
v-if="card.isBlind !== 1 && card.giftProducts[0].productStory && card.isShowProductStory"
|
||||
:style="{
|
||||
right: (card.productStoryX*2 || 0) + 'rpx',
|
||||
top: (card.productStoryY*2 || 0) + 'rpx'
|
||||
|
||||
@@ -290,6 +290,34 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
adjustCoverListForProductStory(coverList, productInfo, defaultTemplate) {
|
||||
if (!productInfo || !productInfo.productStory) {
|
||||
return {
|
||||
coverList,
|
||||
template: defaultTemplate
|
||||
}
|
||||
}
|
||||
const list = coverList && coverList.length ? [...coverList] : []
|
||||
if (!list.length) {
|
||||
return {
|
||||
coverList: list,
|
||||
template: defaultTemplate
|
||||
}
|
||||
}
|
||||
const storyIndex = list.findIndex(item => item && item.isShowProductStory)
|
||||
if (storyIndex === -1) {
|
||||
return {
|
||||
coverList: list,
|
||||
template: defaultTemplate
|
||||
}
|
||||
}
|
||||
const storyCover = list.splice(storyIndex, 1)[0]
|
||||
list.unshift(storyCover)
|
||||
return {
|
||||
coverList: list,
|
||||
template: storyCover
|
||||
}
|
||||
},
|
||||
// 团购价计算
|
||||
computedTravelGroupPrice(useDefaultCouponId) {
|
||||
const params = {
|
||||
@@ -345,16 +373,19 @@ export default {
|
||||
}
|
||||
getGiftCardResend(params).then(res => {
|
||||
this.isPayOk = false
|
||||
this.coverList = [...res.data.giftCardTemplates, res.data.specialGiftCardTemplate]
|
||||
this.cartId = res.data.cartInfo[0].id
|
||||
const initialCoverList = [...res.data.giftCardTemplates, res.data.specialGiftCardTemplate]
|
||||
const goodsInfo = res.data.cartInfo[0]
|
||||
const { coverList, template } = this.adjustCoverListForProductStory(initialCoverList, goodsInfo && goodsInfo.productInfo, res.data.specialGiftCardTemplate)
|
||||
this.coverList = coverList
|
||||
this.cartId = goodsInfo.id
|
||||
this.giftNotice = res.data.giftCardGiftNotice
|
||||
this.orderKey = res.data.orderKey
|
||||
this.goodsInfo = res.data.cartInfo[0]
|
||||
this.templateId = res.data.specialGiftCardTemplate.id
|
||||
this.goodsInfo = goodsInfo
|
||||
this.templateId = template.id
|
||||
this.defaultIndex = this.coverList.findIndex(item => item.id === this.templateId)
|
||||
console.log(this.defaultIndex, 'defaultIndex');
|
||||
this.selectedCover = res.data.specialGiftCardTemplate.cover
|
||||
this.giftImage = res.data.specialGiftCardTemplate.image
|
||||
this.selectedCover = template.cover
|
||||
this.giftImage = template.image
|
||||
this.couponId = ''
|
||||
this.computedPrice(this.goodsInfo.cartNum)
|
||||
})
|
||||
@@ -423,13 +454,17 @@ export default {
|
||||
this.loading = true
|
||||
getGiftCardSendOrderConfirm(params).then(res => {
|
||||
const temp = this.isGroupBuy ? res.data.giftCardTemplates : res.data.giftCardTemplates.filter(e => e.isTravelGroup === 0)
|
||||
this.coverList = res.data.giftCardTemplates.map(e => e.id).includes(res.data.specialGiftCardTemplate.id) ? [...temp] : [...temp, res.data.specialGiftCardTemplate]
|
||||
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)
|
||||
this.coverList = coverList
|
||||
this.giftNotice = res.data.giftCardGiftNotice
|
||||
this.orderKey = res.data.orderKey
|
||||
this.goodsInfo = res.data.cartInfo[0]
|
||||
this.templateId = res.data.specialGiftCardTemplate.id
|
||||
this.selectedCover = res.data.specialGiftCardTemplate.cover
|
||||
this.giftImage = res.data.specialGiftCardTemplate.image
|
||||
this.goodsInfo = goodsInfo
|
||||
this.templateId = template.id
|
||||
this.selectedCover = template.cover
|
||||
this.giftImage = template.image
|
||||
this.blindImage = res.data.giftCardBlindBoxShareImage
|
||||
this.defaultIndex = this.coverList.findIndex(item => item.id === this.templateId)
|
||||
// if(!this.couponId) {
|
||||
@@ -752,4 +787,4 @@ export default {
|
||||
width: 100%;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user