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.

98 lines
1.8 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">
<!-- <view class="swiper-item">
<image :src="item.image_src"></image>
</view> -->
<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">
<image :src="item" class="scene-img"></image>
</view>
</view>
3 years ago
</view>
</template>
<script>
export default {
data() {
return {
//顶部图片
topImg: "",
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')
if (!res.success) return uni.$showMsg()
3 years ago
res.data.forEach(item=>{
item.uploadPath = 'http://localhost:85' +item.uploadPath
if (item.position === "top"){
this.topImg = item.uploadPath
} else if(item.position === "middle"){
this.swiperList.push(item.uploadPath)
} else if(item.position === "bottom"){
this.sceneList.push(item.uploadPath)
}
})
3 years ago
uni.$showMsg('数据请求成功!')
},
}
}
</script>
<style lang="scss">
.index-background{
image{
height: 270rpx;
width: 100%;
}
3 years ago
}
3 years ago
swiper {
height: 630rpx;
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>