<template>
	<div class="app-main app-content">
		<!-- <button @click="pageTo('/pages/user/register')">注册</button>
		<button @click="pageTo('/pages/chat/index')">聊天</button>-->
		<!-- <app-footer /> -->
		<app-swiper v-if="!$util.isEmpty(ad)" :list="ad" @detail="adDetailFn" />
		<block v-if="!$util.isEmpty(category)">
			<div class="goods-module" v-for="(item, index) in category" :key="index">
				<goods-list-big v-if="item.showRow == 1" :info="item" />
				<!-- <goods-list-middle :list="[]" /> -->
				<goods-list-small v-if="item.showRow == 2" :info="item" />
			</div>
		</block>
		<app-trademark />
	</div>
</template>

<script>
	import { mapGetters } from 'vuex'
	import AppSwiper from '@/components/app-swiper'
	import AppTrademark from '@/components/module/app-trademark'
	// 商品组件
	import goodsListBig from '@/pages/home/components/goods-list-big'
	import goodsListMiddle from '@/pages/home/components/goods-list-middle'
	import goodsListSmall from '@/pages/home/components/goods-list-small'
	// import AppFooter from '@/components/app-footer'
	// api
	import { getMainIndex } from '@/api/home'
	import { getOrderShop } from '@/utils/config'
	export default {
		name: 'home',
		components: {
			AppSwiper,
			AppTrademark,
			goodsListBig,
			goodsListMiddle,
			goodsListSmall
			// AppFooter
		},
		data() {
			return {
				data: {},
				ad: [],
				category: [],
				columnStyle: null
			}
		},
		computed: {
			...mapGetters({ orderShop: 'getOrderShop' })
		},
		onLoad(option) {
			// if (this.$util.isLogin()) {
			// 	this.init()
			// }
		},
		mounted() {},
		methods: {
			init() {
				getOrderShop().then(res => {
					uni.setNavigationBarTitle({
						title: `${res.shop.merchantName}`
					})
				})
				// uni.setNavigationBarTitle({
				// 	title: '国兰花尚'
				// })
				this._detail()
			},
			_detail() {
				getMainIndex().then(res => {
					this.data = res.data
					if (this.$util.isEmpty(res.data)) return false
					this.ad = res.data.ad.map(e => {
						e.img = e.adImg
						return e
					})
					this.category = res.data.category
					this.columnStyle = res.data.columnStyle
				})
			},
			// operate
			adDetailFn(item) {
				// #ifdef H5
				location.href = item.url
				// #endif
				// #ifndef H5
				// #endif
			}
		}
	}
</script>

<style lang="scss" scoped>
	.app-content {
		// padding-bottom: 100px;
	}
	.goods-module {
		padding: 0 20px;
		margin-top: 40px;
		/deep/.buy-com-btn {
			font-size: 24px;
			padding: 10px 20px 12px;
			box-shadow: 8px 8px 20px #eee;
		}
	}
</style>
