Commit 83296dd7 by 李伟康

fix(boutique): 修复商品选择组件索引初始化和活动状态处理问题

- 将 goodsIndex 初始值从 0 改为 -1 以正确处理未选择状态
- 在切换车型时重置 goodsIndex 为 -1
- 移除调试用的 console.log 语句
- 调整 changeGoods 调用时机并优化延迟时间从 500ms 到 200ms
- 修复 Reception 组件中的事件处理逻辑
- 添加 setNoActivity 方法来正确处理无活动时的状态重置
- 移除无用的注释代码
1 parent 17561eff
......@@ -40,7 +40,7 @@ export default {
blockIndex: 0,
secondIndex: 0,
thirdlyIndex: 0,
goodsIndex: 0,
goodsIndex: -1,
contentHeight: '0',
currentItem: {},
goodsList: [],
......@@ -90,9 +90,10 @@ export default {
changeCar(newval) {
this.goodsList = []
let { activityData, tabIndex } = this
let carSeriesList = activityData[tabIndex].carSeriesList,
let carSeriesList = activityData[tabIndex].carSeriesList,
data = carSeriesList.find(e => e.carSeriesId == newval)
if (data) {
this.goodsIndex = -1
this.setGoodsList(data.productList)
this.$emit('noActivity', false)
} else this.$emit('noActivity', true)
......@@ -117,26 +118,19 @@ export default {
this.goodsList = []
this.flagObject.goodsFlag = false
data.map(e => {
console.log(e)
if (e.tabDescription) e.tabDescription = e.tabDescription.replace(/<\/?br\s*\/?>|\\n|\n/g, '<br>')
})
this.goodsList = data
this.flagObject.goodsFlag = true
this.flagObject.scrollTop = -100
this.changeGoods(data[0], 0, false)
setTimeout(() => {
this.setScrollHeight()
}, 500)
this.changeGoods(data[0], 0, false)
}, 200)
},
changePreView() {
this.$emit('changePreView', this.currentItem)
},
// setGoodsData(data, key) {
// let goodsList = []
// console.log(goodsList)
// return goodsList
// },
statusText(status) {
return status == 1 ? '主推' : '次推'
},
......
......@@ -47,8 +47,8 @@
<template v-if="showActivity">
<view class="sku-box">
<goods-box :currentCar="currentCarId" :activityData="activityData"
:show="show && [0, 1].includes(tabIndex)" @changePreView="changePreView" ref="goodsBox"
:tabIndex="tabIndex" @noActivity="noActivity = $event" />
:show="show && [0, 1].includes(tabIndex)" @changePreView="currentItem = $event" ref="goodsBox"
:tabIndex="tabIndex" @noActivity="setNoActivity" />
</view>
</template>
<template v-else>
......@@ -232,6 +232,14 @@ export default {
return tabs
},
hasBeforeActivity() {
// let { currentCarId } = this,
// hasBeforeActivity = this.activityData.some(e => e.marketingStage == 0),
// hasCar = false
// this.activityData.forEach(e => {
// if (!hasCar) e.carSeriesList.some(e => e.carSeriesId == currentCarId)
// })
// return hasBeforeActivity && hasCar
return this.activityData.some(e => e.marketingStage == 0)
},
hasAfterActivity() {
......@@ -342,7 +350,11 @@ export default {
{ carList } = this
if (index != 0 && item.id == carList[index - 1].id) result = false
return result
}
},
setNoActivity(val) {
this.noActivity = val
if (val) this.currentItem = null
},
}
}
</script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!