Browse Source

开屏广告

master
jiazhipeng 2 weeks ago
parent
commit
5b642210e5
  1. 44
      pages/index/index.vue
  2. 112
      pages/index/startIndex.vue

44
pages/index/index.vue

@ -86,6 +86,18 @@
</view>
</view>
<uni-popup ref="alertAdv" type="center">
<view class="alertAdv">
<swiper class="alertAdv-banner" :circular="true" :interval="6000" style="margin-top: 27rpx;"
:duration="800" :indicator-dots="false" :autoplay="true" v-if="alertAdv && alertAdv.length > 0">
<swiper-item class="alertAdv-item" v-for="(item, index) in alertAdv" :key="index" @click.stop="gotoBannerDetail(item)">
<image class="alertAdv-img" :src="showImg(item.head_img)" mode="widthFix" lazy-load="true"></image>
</swiper-item>
</swiper>
</view>
</uni-popup>
</view>
</template>
@ -128,6 +140,7 @@
SHFlag: true,
alertAdv: [],
}
},
onLoad() {
@ -144,6 +157,7 @@
this.initRectInfo()
this.sendRequest()
this.getHeadImg(2378).then(res => {this.CKMap = res})
this.getAlertAdv()
},
methods: {
initSHFlag () {
@ -311,6 +325,18 @@
},
getAlertAdv () {
this.Post({position: 3,type_id: 3},"/api/adv/getAdv",).then(res => {
if (res.data.length > 0) {
this.alertAdv = res.data || []
if (this.alertAdv.length>0) {
this.$refs.alertAdv.open()
}
}
})
},
},
onReachBottom() {
setTimeout(() => {
@ -505,4 +531,22 @@
}
}
}
.alertAdv-banner{
width: 700rpx;
height: 1000rpx;
margin: 0 auto;
.alertAdv-item{
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.alertAdv-img{
width: 100%;
height: auto;
}
}
</style>

112
pages/index/startIndex.vue

@ -0,0 +1,112 @@
<template>
<view class="bg" @click="goIndex()">
<image :src="showImg(screenPng)"></image>
</view>
</template>
<script>
export default {
components: {
},
data() {
return {
topBanner: [],
screenPng: null,
}
},
onLoad() {
this.getAlertAdv()
},
onUnload() {
//
},
onReady() {
},
methods: {
// 广
gotoBannerDetail(item) {
if (this.SHFlag) { return }
// 1 2 3 4
switch (item.jump_type){
case 1:
this.gotoDetailByType(item.product_model)
break;
case 2:
this.gotoPath(item.front_model.inside)
break;
case 3:
this.gotoWebUrl(item.tdata.url)
break;
case 4:
// #ifdef MP-WEIXIN
uni.navigateToMiniProgram({
shortLink: item.tdata.url
})
// #endif
break;
default:
break;
}
},
getAlertAdv () {
this.Post({position: 2,type_id: 3},"/api/adv/getAdv",).then(res => {
if (res.data.length > 0) {
this.topBanner = res.data || []
if (this.topBanner.length<=0) {
uni.switchTab({
url:"/pages/index/index"
})
} else {
let num = Math.floor(Math.random() * length);
this.screenPng =this.topBanner[num].head_img
}
}
})
},
goIndex () {
uni.switchTab({
url:"/pages/index/index"
})
},
},
}
</script>
<style lang="scss" scoped>
.bg {
width: 100%;
height: 100vh;
}
image {
display: block;
}
</style>
Loading…
Cancel
Save