<template>
	<view >
		<loadlogo v-if="!loadlogo" />
		<view class="goodsClass" v-if="loadlogo">
			<filtertab :requestType="'6'" :isPageScroll="'1'" @selectAreaid="selectAreaid" @selectClassid="selectClassid"
			 @selectClassTwoid="selectClassTwoid" @selectOrders="selectOrders" :cate_one="cate_one" :cate_two="cate_two" :title="title"></filtertab>
			 <view >
			 	<view  v-if="cardlist">
			 		<business-card :businCard_list="cardlist" :is_collcet="'0'" :is_have="1" :is_pading="false" :is_yellow="true"></business-card>
			 	</view>
			 	<load-more :isMore="isMore"></load-more>
			 </view>
			 <far-bottom></far-bottom>
		</view>
	</view>
</template>

<script>
	import App from '@/common/js/app.js';
	import loadMore from '@/components/template/loadmore.vue';
	import Loadlogo from '@/components/template/loadlogo.vue';
	import filtertab from '@/components/template/filtertab.vue';
	import businessCard from '@/components/page/pageComponents/businessCard.vue';
	export default{
		data(){
			return{
				cate_one:'0',
				cate_two:'0',
				title:'全部',
				cardlist:null,
				isMore:true,
				count:1,
				loadlogo:false,
				page:1,
				orderid:'',
				region_id:'',
				flag:false
			}
		},
		components:{
			filtertab,
			loadMore,
			Loadlogo,
			businessCard
		},
		onLoad(e) {
			console.log(e)
			let _this = this;
			_this.cate_one = e.cate_one;
			_this.cate_two = e.cate_two;
			_this.title = e.title;
			this.getlist(true);
		},
		computed:{
			curLoction(){
				return uni.getStorageSync('curLoction')
			}
		},
		methods:{
			getlist(flag){
				let _this = this;
				let data={
					page:_this.page,
					lng:_this.curLoction.longitude || '',
					lat:_this.curLoction.latitude || '',
					sort:_this.orderid || '',
					cate_one:_this.cate_one || '',
					cate_two:_this.cate_two || '',
					city_id:_this.region_id || ''
				};
				App._post_form(
					`&p=yellowpage&do=homeList`,
					data,
					res => {
						console.log(res);
						
						_this.cardlist = res.data.list;
						if(_this.cardlist.length == 0){
							_this.cardlist = null;
						}
						// debugger
						setTimeout(()=>{
							this.flag = true;
						},1000)
						// this.swiperList = res.data.adv;
						// this.strodatas = res.data;
						// this.loadlogo = true;
						_this.count = res.data.total;
						// this.shopNum = Number(res.data.cartnum);
						// console.log(this.$refs.shopPing);
						
					},
					false,
					() => {
						_this.loadlogo = true;
					}
				);
			},
			selectOrders(data) {
				let _this = this;
				if(!this.flag) return
				console.log('1分类',data);
				// _this.cate_one = '';
				// _this.cate_two = '';
				// _this.title = '';
				_this.page = 1;
				this.orderid = data.val;
				this.getlist();
			},
			selectClassTwoid(data) {
				let _this = this;
				if(!this.flag) return
				console.log('2分类',data);
				// _this.cate_one = '';
				_this.cate_two = '';
				_this.title = '';
				_this.page = 1;
				this.cate_two = data.cate_two;
				this.getlist();
			},
			selectClassid(data) {
				let _this = this;
				if(!this.flag) return
				console.log('3分类',data);
				_this.cate_one = '';
				_this.cate_two = '';
				_this.title = '';
				_this.page = 1;
				this.cate_one = data.cate_one;
				this.getlist();
			},
			selectAreaid(data,flag) {
				let _this = this;
				if(!this.flag) return
				console.log('4分类',data);
				_this.page = 1;
				this.region_id = data.id;
				this.flag = true;
				this.getlist();
			},
		},
		// 页面上拉触底事件的处理函数
		onReachBottom: function() {
			let _this = this;
			this.isMore = false;
			console.log(this.page,this.count)
			if (this.page == this.count) {
				this.isMore = true;
			} else {
				this.page++;
				let data={
					page:this.page,
					lng:this.curLoction.longitude || '',
					lat:this.curLoction.latitude || '',
					sort:this.orderid || '',
					cate_one:this.cate_one || '',
					cate_two:this.cate_two || '',
					city_id:this.region_id || ''
				};
				App._post_form(
					`&p=yellowpage&do=homeList`,
					data,
					res => {
						console.log(res)
						this.cardlist = this.cardlist.concat(res.data.list);
						this.isMore = true;
						// this.count = res.data.total;
					},
					false,
					() => {}
				);
			}
		}
	}
</script>

<style>
	page{
		background-color: #F7F7F7;
	}
</style>
<style lang="scss" scoped>
	.goodsClass{
		
	}
</style>
