home.vue 2.11 KB
Newer Older
王建威's avatar
王建威 committed
1 2
<template>
	<view class="homeContent">
王建威's avatar
王建威 committed
3
		<component v-for="(item, index) in data" :key="index" :is="item.name" :wrapper_props="item.wrapper_props" :isLogin="isLogin" :ref="item.name"></component>
王建威's avatar
王建威 committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
		<BottomBar />
	</view>
</template>

<script>
	import SearchBar from './components/searchbar.vue';
	import Navigation from './components/navigation.vue';
	import Slide from './components/slide.vue';
	import MainTitle from './components/maintitle.vue';
	import GoodsList from './components/goodslist.vue';
	import FunctionMenu from './components/functionmenu.vue';
	import Promotion from './components/promotion.vue';
	import HotRecommd from './components/hotrecommd.vue';
	import CustomStyle from './components/custowstyle.vue';
	import MultImage from './components/multimage.vue';
	import BottomBar from "@/components/BottomBar/BottomBar.vue";
	export default {
		data() {
			return {
王建威's avatar
王建威 committed
23
				data: [],
王建威's avatar
王建威 committed
24 25
				isLogin: 0,
				fixFlag: false
王建威's avatar
王建威 committed
26 27 28 29
			}
		},
		onLoad() {
			this.getData();
王建威's avatar
王建威 committed
30 31 32
			uni.showLoading({
			    title: '加载中'
			});
王建威's avatar
王建威 committed
33 34 35 36 37 38
			// #ifdef H5
			//默认请求微信分享
			if (this.$wechat && this.$wechat.isWechat()) {
				this.$wechat.share({titie: this.$getNavigationBarTitle()});
			}
			// #endif
王建威's avatar
王建威 committed
39
		},
王建威's avatar
王建威 committed
40 41 42 43 44 45 46 47 48 49
		onPageScroll() {
			const top = this.$refs.HotRecommd[0].$refs.fix.$el.getBoundingClientRect().top;
			if(top <= 50  && !this.fixFlag) {
				this.fixFlag = true;
				this.$refs.HotRecommd[0].fixFlag = true;
			} else if(top > 50  && this.fixFlag) {
				this.fixFlag = false;
				this.$refs.HotRecommd[0].fixFlag = false;
			}
		},
王建威's avatar
王建威 committed
50 51 52 53 54 55 56 57
		methods: {
			getData() {
				uni.request({
					url: '/uni/api/index/style_info',
					method: 'GET',
					dataType: 'json',
					success: (res) => {
						this.data = res.data.data;
王建威's avatar
王建威 committed
58
						this.isLogin = res.data.login_flg;
王建威's avatar
王建威 committed
59
						uni.hideLoading();
王建威's avatar
王建威 committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
					}
				});
			}
		},
		components: {
			BottomBar,
			SearchBar,
			Navigation,
			Slide,
			MainTitle,
			GoodsList,
			FunctionMenu,
			Promotion,
			HotRecommd,
			CustomStyle,
			MultImage
		}
	}
</script>

<style lang="less" scoped>
	.homeContent {
王建威's avatar
王建威 committed
82
		padding: 100rpx 0 110rpx;
王建威's avatar
王建威 committed
83 84 85
		background-color: #f8f8f8;
	}
</style>