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 { ...@@ -40,7 +40,7 @@ export default {
blockIndex: 0, blockIndex: 0,
secondIndex: 0, secondIndex: 0,
thirdlyIndex: 0, thirdlyIndex: 0,
goodsIndex: 0, goodsIndex: -1,
contentHeight: '0', contentHeight: '0',
currentItem: {}, currentItem: {},
goodsList: [], goodsList: [],
...@@ -90,9 +90,10 @@ export default { ...@@ -90,9 +90,10 @@ export default {
changeCar(newval) { changeCar(newval) {
this.goodsList = [] this.goodsList = []
let { activityData, tabIndex } = this let { activityData, tabIndex } = this
let carSeriesList = activityData[tabIndex].carSeriesList, let carSeriesList = activityData[tabIndex].carSeriesList,
data = carSeriesList.find(e => e.carSeriesId == newval) data = carSeriesList.find(e => e.carSeriesId == newval)
if (data) { if (data) {
this.goodsIndex = -1
this.setGoodsList(data.productList) this.setGoodsList(data.productList)
this.$emit('noActivity', false) this.$emit('noActivity', false)
} else this.$emit('noActivity', true) } else this.$emit('noActivity', true)
...@@ -117,26 +118,19 @@ export default { ...@@ -117,26 +118,19 @@ export default {
this.goodsList = [] this.goodsList = []
this.flagObject.goodsFlag = false this.flagObject.goodsFlag = false
data.map(e => { data.map(e => {
console.log(e)
if (e.tabDescription) e.tabDescription = e.tabDescription.replace(/<\/?br\s*\/?>|\\n|\n/g, '<br>') if (e.tabDescription) e.tabDescription = e.tabDescription.replace(/<\/?br\s*\/?>|\\n|\n/g, '<br>')
}) })
this.goodsList = data this.goodsList = data
this.flagObject.goodsFlag = true this.flagObject.goodsFlag = true
this.flagObject.scrollTop = -100 this.flagObject.scrollTop = -100
this.changeGoods(data[0], 0, false)
setTimeout(() => { setTimeout(() => {
this.setScrollHeight() this.setScrollHeight()
}, 500) this.changeGoods(data[0], 0, false)
}, 200)
}, },
changePreView() { changePreView() {
this.$emit('changePreView', this.currentItem) this.$emit('changePreView', this.currentItem)
}, },
// setGoodsData(data, key) {
// let goodsList = []
// console.log(goodsList)
// return goodsList
// },
statusText(status) { statusText(status) {
return status == 1 ? '主推' : '次推' return status == 1 ? '主推' : '次推'
}, },
......
...@@ -47,8 +47,8 @@ ...@@ -47,8 +47,8 @@
<template v-if="showActivity"> <template v-if="showActivity">
<view class="sku-box"> <view class="sku-box">
<goods-box :currentCar="currentCarId" :activityData="activityData" <goods-box :currentCar="currentCarId" :activityData="activityData"
:show="show && [0, 1].includes(tabIndex)" @changePreView="changePreView" ref="goodsBox" :show="show && [0, 1].includes(tabIndex)" @changePreView="currentItem = $event" ref="goodsBox"
:tabIndex="tabIndex" @noActivity="noActivity = $event" /> :tabIndex="tabIndex" @noActivity="setNoActivity" />
</view> </view>
</template> </template>
<template v-else> <template v-else>
...@@ -232,6 +232,14 @@ export default { ...@@ -232,6 +232,14 @@ export default {
return tabs return tabs
}, },
hasBeforeActivity() { 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) return this.activityData.some(e => e.marketingStage == 0)
}, },
hasAfterActivity() { hasAfterActivity() {
...@@ -342,7 +350,11 @@ export default { ...@@ -342,7 +350,11 @@ export default {
{ carList } = this { carList } = this
if (index != 0 && item.id == carList[index - 1].id) result = false if (index != 0 && item.id == carList[index - 1].id) result = false
return result return result
} },
setNoActivity(val) {
this.noActivity = val
if (val) this.currentItem = null
},
} }
} }
</script> </script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!