Commit 1e9ac742 by 李伟康

feat(boutique): 新增商品展示组件并优化接待页面

- 新增 GoodsBox.vue 组件用于展示商品列表
- 修改 Reception.vue 页面集成新的商品展示功能
- 更新样式表适配新的商品展示布局
- 重构标签页切换逻辑以支持多种活动类型
- 调整优惠券弹窗和风险告知组件的显示逻辑
- 优化图片展示区域的样式和交互效果
- 修复选项卡切换时的状态管理问题
- 调整选装表格的间距参数
1 parent 02540f16
<template>
<view class="goods-content">
<template v-if="goodsList.length">
<scroll-view scroll-y class="content-scroll-box" id="content-scroll" :style="{ height: contentHeight }"
:scroll-top="flagObject.scrollTop">
<template v-for="(i, index) in goodsList">
<view :class="['goods-item', goodsIndex == index ? 'active' : '', `status-${i.status}`]" :key="index"
@click="changeGoods(i, index)">
<view :class="['goods-status flex']">{{ statusText(i.status) }}</view>
<image class="goods-image" :src="i.chooseCardPicurl"></image>
<view class="goods-title">{{ i.name }}</view>
<view class="goods-description">
<rich-text :nodes="i.descriptionText"></rich-text>
</view>
<view class="goods-price">
¥ {{ i.updatedDate }}
<view class="old-price">¥ {{ i.merchantConfigId }}</view>
</view>
</view>
</template>
</scroll-view>
</template>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'SkuBox',
props: {
defaultTabId: Number,
currentCar: [Number, String],
show: Boolean
},
data() {
return {
tabId: '1',
blockIndex: 0,
secondIndex: 0,
thirdlyIndex: 0,
goodsIndex: 0,
contentHeight: '0',
currentItem: {},
goodsList: [],
requested: false,
flagObject: {
goodsFlag: false,
scrollTop: 0
},
secondList: [],
secondName: ''
}
},
watch: {
defaultTabId: {
immediate: true,
handler(newval) {
if (this.show) this.tabId = newval
}
},
/**切换车型 */
currentCar: {
immediate: true,
handler(newval) {
if (this.show && this.requested) this.changeCar(newval)
}
},
show: {
immediate: true,
handler(newval) {
if (newval && !this.requested) {
this.requested = true
this.init(this.defaultTabId)
}
}
},
watchStatus: {
immediate: true,
handler(newval) {
this.tabId = '1'
}
},
},
computed: {
watchStatus() {
return this.$store.state.user.historyStatus;
},
blockClass() {
return ['block-0', 'block-1', 'block-2'][this.blockIndex]
},
boutiqueMediaConfig() {
return this.$store.state.user.boutiqueMediaConfig
},
list() {
let item = this.boutiqueMediaConfig[this.currentCar]
return item?.retrofitting || []
}
},
mounted() {
},
methods: {
changeCar(newval) {
let [item] = this.boutiqueMediaConfig[newval].retrofitting
this.changeTabId(item.tabId, 0, false)
},
init(tabId) {
let index = this.boutiqueMediaConfig[this.currentCar].retrofitting.findIndex(e => e.tabId == tabId)
this.changeTabId(tabId, index, false)
},
changeTabId(tabId, index, filter = true) {
if (filter && tabId == this.tabId && index == this.blockIndex) return
this.tabId = tabId
this.blockIndex = index
this.setSecondList()
},
async setSecondList() {
let secondList = this.boutiqueMediaConfig[this.currentCar].retrofitting,
index = secondList.findIndex(e => e.tabId == this.tabId)
if (index == -1) index = 0
let { list } = secondList[index]
this.secondList = list
this.secondClick(0, false)
},
setScrollHeight() {
this.$nextTick(() => {
let query = uni.createSelectorQuery()
query.select(`#content-scroll`).boundingClientRect(data => {
this.contentHeight = `calc(100% - ${data.top - 72}px)`
this.flagObject.scrollTop = 0
}).exec()
})
},
secondClick(index, filter = true) {
if (filter && this.secondIndex == index) return
let { secondList } = this
this.secondIndex = index
this.secondName = secondList[index].category
if (this.tabId == 2 && this.secondName == '窗膜') {
let { infoList } = this.secondList[index],
arr = Array.from(new Set([...infoList.map((e) => e.brand)])),
brandList = []
arr.map(e => {
let obj = {
brandName: e,
list: []
}
infoList.map(i => {
if (i.brand == e) obj.list.push(i)
})
brandList.push(obj)
})
this.brandList = brandList
this.thirdlyClick(0, false)
} else this.getGoodsList()
},
thirdlyClick(index, filter = true) {
if (filter && this.thirdlyIndex == index) return
this.thirdlyIndex = index
this.getGoodsList()
},
changeGoods(item, index, filter = true) {
if (filter && this.goodsIndex == index) return
this.goodsIndex = index
this.currentItem = item
this.changePreView()
},
getGoodsList() {
this.goodsList = []
this.flagObject.goodsFlag = false
let { secondIndex, secondList, tabId, brandList, thirdlyIndex, secondName } = this
let goodsList = this.setGoodsData(tabId == 2 && secondName == '窗膜' ? brandList[thirdlyIndex].list : secondList[secondIndex].infoList)
this.goodsList = goodsList
this.flagObject.goodsFlag = true
this.flagObject.scrollTop = -100
this.changeGoods(goodsList[0], 0, false)
setTimeout(() => {
this.setScrollHeight()
}, 500)
},
changePreView() {
this.$emit('changePreView', this.currentItem)
},
setGoodsData(data, key) {
let goodsList = []
data.map(e => {
if (e.description) e.descriptionText = e.description.replace(/<\/?br\s*\/?>|\\n|\n/g, '<br>')
goodsList.push(e)
})
console.log(goodsList)
return goodsList
},
firstClass(list = []) {
return list.length == 2 ? 'two-block' : ''
},
statusText(status) {
return status == 1 ? '主推' : '次推'
},
}
}
</script>
<style scoped lang='scss'>
.goods-content {
width: 100%;
height: 100%;
.content-scroll-box {
.goods-item {
position: relative;
width: calc(100% - #{toRpx(64)});
border: toRpx(3) solid #292D3333;
border-radius: toRpx(16);
padding: toRpx(24) toRpx(32) toRpx(24) toRpx(232);
margin-bottom: toRpx(24);
transition: all 0.15s;
.goods-status {
position: absolute;
right: 0;
top: 0;
height: toRpx(36);
color: #FFFFFF;
font-size: toRpx(24);
justify-content: center;
background: linear-gradient(90deg, #5C8AFF 0%, #49B6FF 100%);
padding: 0 20rpx;
border-radius: 0 toRpx(16) 0 toRpx(16);
}
.goods-image {
position: absolute;
width: toRpx(176);
height: toRpx(240);
top: toRpx(24);
left: toRpx(32);
}
.goods-title {
font-weight: 500;
font-size: toRpx(30);
color: #1A1A2E;
line-height: toRpx(36);
}
.goods-description {
margin-top: toRpx(8);
font-size: toRpx(26);
color: #6C6F75;
line-height: toRpx(36);
max-height: toRpx(144);
overflow: hidden;
}
.goods-price {
margin-top: toRpx(8);
font-size: toRpx(36);
color: #F24724;
line-height: toRpx(44);
display: flex;
align-items: baseline;
.old-price {
font-size: toRpx(26);
color: #999EA8;
text-decoration: line-through;
margin-left: toRpx(12);
}
}
}
.status-1 {
.goods-status {
background: linear-gradient(270deg, #FF6748 0%, #F24724 100%);
}
&::after{
position: absolute;
content: '';
width: 296rpx;
height: 228rpx;
top: 0;
right: 0;
background: url('https://img02.glsx.com.cn/weapp/resource/app-tape/common/goods-status-1.webp') no-repeat center center;
background-size: 100% 100%;
z-index: -1;
}
}
.active {
border-color: #292D33;
.goods-description {
max-height: none;
overflow: auto;
}
}
}
.nothing {
flex-direction: column;
padding-top: toRpx(136);
font-size: toRpx(28);
color: #999999;
line-height: toRpx(40);
&-icon {
width: toRpx(676);
height: toRpx(284);
margin-bottom: toRpx(24);
background-image: url('@/assets/images/boutique/nothing.webp');
background-size: 100%;
}
}
}
</style>
\ No newline at end of file
......@@ -171,7 +171,7 @@ export default {
height: 100%;
box-sizing: border-box;
margin: 0 auto;
padding-top: toRpx(236);
padding-top: toRpx(252);
animation: show-view-opacity 0.15s forwards;
.views-title-box {
height: toRpx(96);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!