Browse Source

小程序首页渲染

h5_css
yanyan 3 years ago
parent
commit
b31af81a5e
  1. 61
      pages/index/index.vue

61
pages/index/index.vue

@ -1,7 +1,7 @@
<template>
<view>
<view class="index-background">
<my-search @click="searchInfo"></my-search>
<image :src="topImg"></image>
</view>
<!-- 轮播图 -->
<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" :circular="true">
@ -9,12 +9,16 @@
<!-- <view class="swiper-item">
<image :src="item.image_src"></image>
</view> -->
<navigator class="swiper-item" :url="'/subpackage/detail/detail?goods_id='+item.goods_id">
<image :src="item.image_src"></image>
<navigator class="swiper-item">
<image :src="item"></image>
</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>
</view>
</template>
@ -22,22 +26,37 @@
export default {
data() {
return {
//
topImg: "",
//
swiperList: [],
//
sceneList:[]
};
},
onLoad() {
this.getSwiperList()
},
methods: {
async getSwiperList() {
const {
data: res
} = await uni.$http.get('/api/public/v1/home/swiperdata')
if (res.meta.status !== 200) return uni.$showMsg()
} = await uni.$http.post('/small/customImage/listAll')
if (!res.success) return uni.$showMsg()
this.swiperList = res.message
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)
}
})
uni.$showMsg('数据请求成功!')
},
}
@ -45,18 +64,34 @@
</script>
<style lang="scss">
.search-box{
position: sticky;
top: 0;
z-index: 9999;
.index-background{
image{
height: 270rpx;
width: 100%;
}
}
swiper {
height: 330rpx;
height: 630rpx;
.swiper-item,
image {
width: 100%;
height: 100%;
border-radius: 4px;
}
}
.scene-list {
display: flex;
justify-content: space-around;
margin: 5px 0;
}
.scene-img {
width: 358rpx;
height: 290rpx;
border-radius: 8px;
}
</style>

Loading…
Cancel
Save