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.

170 lines
3.4 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">
3 years ago
<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>
3 years ago
import { mapMutations, mapState } from 'vuex'
3 years ago
export default {
3 years ago
3 years ago
data() {
return {
//顶部图片
topImg: "",
leftImg: "",
rightImg: "",
3 years ago
//轮播图数据列表
swiperList: [],
//场景入口
sceneList: []
3 years ago
};
},
3 years ago
computed: {
...mapState('m_user', ['token'])
},
3 years ago
onLoad() {
uni.setTabBarItem({
index: 1,
"visible": false
});
uni.setTabBarItem({
index: 2,
"visible": false
});
uni.setTabBarItem({
index: 3,
"visible": false
});
uni.setTabBarItem({
index: 4,
"visible": false
});
this.listTabbar();
3 years ago
this.getSwiperList();
this.checkLogin()
3 years ago
},
methods: {
listTabbar() {
this.$api.listTabbar({})
.then(res => {
console.log(res)
for (var i = 0; i < res.data.length; i++) {
if (res.data[i].hide == 1) {
if (res.data[i].type == "home") {
uni.setTabBarItem({
index: 0,
text: res.data[i].title,
"visible": true
});
}
if (res.data[i].type == "scan") {
uni.setTabBarItem({
index: 1,
text: res.data[i].title,
"visible": true
});
}
if (res.data[i].type == "know") {
uni.setTabBarItem({
index: 2,
text: res.data[i].title,
"visible": true
});
}
if (res.data[i].type == "my") {
uni.setTabBarItem({
index: 3,
text: res.data[i].title,
"visible": true
});
}
}
}
}).catch((e) => console.log(e)); //捕获异常
},
3 years ago
async getSwiperList() {
3 years ago
const {
data: res
3 years ago
} = await uni.$http.post('/small/customImage/listAll',{page:"home"})
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
3 years ago
} else if (item.position.indexOf("banner") !=-1) {
this.swiperList.push(item.uploadPath)
3 years ago
} else if (item.position.indexOf("bottom") !=-1) {
this.sceneList.push(item.uploadPath)
}
})
3 years ago
uni.$showMsg('数据请求成功!')
},
3 years ago
navClickHandler(item) {
uni.navigateTo({
url: '/subpkg/list/list'
})
},
checkLogin() {
if(this.token === "") {
uni.reLaunch({
url: '/subpkg/login/login',
})
}
},
3 years ago
}
}
</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;
}
</style>