You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.1 KiB

3 years ago
<template>
<view>
<view class="index-background">
<image :src="topImg"></image>
3 years ago
</view>
<!-- 轮播图 -->
<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" :circular="true">
<swiper-item v-for="(item, i) in swiperList" :key="i">
<navigator class="swiper-item">
<image :src="item"></image>
3 years ago
</navigator>
</swiper-item>
</swiper>
<view class="scene-list">
<view class="scene-item" v-for="(item,i) in sceneList" :key="i" @click="navClickHandler(item)">
<image :src="item" class="scene-img"></image>
</view>
</view>
3 years ago
</view>
</template>
<script>
export default {
data() {
return {
//顶部图片
topImg: "",
leftImg: "",
rightImg: "",
3 years ago
//轮播图数据列表
swiperList: [],
//场景入口
sceneList:[]
3 years ago
};
},
onLoad() {
this.getSwiperList()
},
methods: {
3 years ago
async getSwiperList() {
3 years ago
const {
data: res
} = await uni.$http.post('/small/customImage/listAll',{page:'home'})
if (!res.success) return uni.$showMsg()
3 years ago
res.data.forEach(item=>{
item.uploadPath = uni.$http.baseUrl +item.uploadPath
if (item.position === "top"){
this.topImg = item.uploadPath
} else if(item.position.indexOf("banner") !=-1){
this.swiperList.push(item.uploadPath)
} else if(item.position.indexOf("bottom-left") !=-1){
this.leftImg = item.uploadPath
} else if(item.position.indexOf("bottom-right") !=-1){
this.rightImg = item.uploadPath
}
})
this.sceneList.push(this.leftImg)
this.sceneList.push(this.rightImg)
3 years ago
uni.$showMsg('数据请求成功!')
},
navClickHandler(item) {
uni.navigateTo({
url: '/subpkg/list/list'
})
},
3 years ago
}
}
</script>
<style lang="scss">
.index-background{
image{
height: 220rpx;
width: 100%;
}
3 years ago
}
3 years ago
swiper {
height: 570rpx;
3 years ago
.swiper-item,
image {
width: 100%;
height: 100%;
border-radius: 4px;
3 years ago
}
}
.scene-list {
display: flex;
justify-content: space-around;
margin: 5px 0;
}
.scene-img {
width: 358rpx;
height: 290rpx;
border-radius: 8px;
}
3 years ago
</style>