【新增】优化广告组件,表【CoreCmsAdvertPosition】新增【platform】广告平台字段,【type】广告位类型两个字段,用于区分pc,h5,小程序多端,以及图片还是轮播图展示形式。

This commit is contained in:
JianWeie
2023-01-10 16:04:48 +08:00
parent 3d8a3436a3
commit 8632c6fb26
21 changed files with 379 additions and 80 deletions

View File

@@ -2,8 +2,15 @@
<view>
<!--提示框组件-->
<u-toast ref="uToast" />
<view v-for="(item, index) in advert" :key="index">
<u--image :showLoading="true" :src="item.imageUrl" mode="widthFix" width="100%" height="auto" @click="showSliderInfo(item.type, item.val)"></u--image>
<view v-if="position && advert">
<view v-if="position.type==1">
<view v-for="(item, index) in advert" :key="index">
<u--image :showLoading="true" :src="item.imageUrl" mode="widthFix" width="100%" height="auto" @click="showSliderInfo(item.type, item.val)"></u--image>
</view>
</view>
<view v-else>
<u-swiper :list="advert" indicator indicatorMode="line" circular keyName="imageUrl" :showTitle="showTitle" @click="clickSwiper"></u-swiper>
</view>
</view>
</view>
</template>
@@ -11,29 +18,47 @@
<script>
export default {
props: {
codes: {
code: {
type: String,
required: true,
default: 'tpl1_class_banner1'
}
},
showTitle: {
type: Boolean,
required: false,
default: false
},
},
data() {
return {
position: {},
advert: [],
}
},
created() {
//console.log(this.codes);
this.getData();
},
methods: {
getData() {
this.$u.api.advert({
codes: this.codes
code: this.code,
platform: 3
}).then(res => {
this.advert = res.data;
if (res.status) {
this.advert = res.data.childs;
this.position = res.data.position;
if (this.advert) {
for (var i = 0; i < this.advert.length; i++) {
this.advert[i].title = this.advert[i].name;
}
}
}
});
},
clickSwiper(index) {
console.log(index);
this.showSliderInfo(this.advert[index].type, this.advert[index].val)
}
},
}
</script>

View File

@@ -69,7 +69,12 @@
</view>
</u-sticky>
<view class="coreshop-padding-10">
<coreshop-advert code="TplIndexBanner1" showTitle="true"></coreshop-advert>
</view>
<view class="wrapper">
<view class="list">
<view class="category" v-for="(good, key) in goodsList" :key="key" :id="`cate-${good.id}`">
<view class="items">