<template>
	<view class="app">
		<loadlogo v-if="!loadlogo" />
		<view class="title">
			<filtertab
			:requestType="'服务列表'" 
			:isPageScroll="'1'" 
			@selectAreaid="selectAreaid" 
			@selectClassid="selectClassid" 
			@getmore="getmore" 
			@getResumeList="getResumeList"
			@selectClassTwoid="selectClassTwoid" 
			@selectOrders="selectOrders" 
			@getcityWork="getcityWork"
			:cate_one="cate_one"
			:title="title"
			:cate_two="cate_two"></filtertab>
		</view>
		<view class="item" v-if="storelist.length > 0">
			<view  v-for="(item,index) in storelist" :key="index">
				<homemakingItem :items="item"></homemakingItem>
			</view>
			<load-more :isMore="isMore"></load-more>
		</view>
		<view  v-else>
			<image style="width: 750upx;height: 560upx;" :src="imgfixUrls + 'homemakingImg/wushuju.png'" mode=""></image>
		</view>
		
		<TabBars :tabBarAct="0" pageType="18"></TabBars>
	</view>
</template>

<script>
	import App from '@/common/js/app.js';
	import filtertab from '@/components/template/filtertab.vue';
	import loadMore from '@/components/template/loadmore.vue';
	import Loadlogo from '@/components/template/loadlogo.vue';
	import TabBars from '@/components/template/tabBar.vue';
	import homemakingItem from '@/components/template/homemakingItem.vue';
	export default{
		data(){
			return{
				cate_one:'0',
				cate_two:'0',
				latlngs:{},
				page:1,
				storelist:[],
				page_number:1,
				isMore:true,
				loadlogo:false,
				sort:1,
				city_id:'',
				typeid:'',
				title:''
			}
		},
		components:{
			filtertab,
			homemakingItem,
			loadMore,
			Loadlogo,
			TabBars
		},
		onLoad(e) {
			if(e.onelevelid){
				this.cate_one = e.onelevelid;
				this.typeid = e.onelevelid;
				if(e.twolevelid != '0'){
					this.cate_two = e.twolevelid;
				}
				this.title = e.title;
			}
			console.log(e);
			this.latlngs = uni.getStorageSync('curLoction');
			
		},
		onReachBottom() {
			if(this.page_number == this.page) return
			this.isMore = false;
			this.page++;
			this.getstoreList(true)
		},
		methods:{
			getstoreList(flag){
				let data = {
					pege:this.page,
					lat:this.latlngs.latitude || '',
					lng:this.latlngs.longitude || '',
					sort:this.sort,
					city_id:this.city_id,
					typeid:this.typeid
				}
				App._post_form(
					`&p=housekeep&do=getNewStorelist`,
					data,
					res => {
						if(flag){
							this.storelist = this.storelist.concat(res.data.list);
						}else{
							this.storelist = res.data.list;
							this.page_number = res.data.page_number;
						}
						this.isMore = true;
						console.log(res);
					},
					false,
					() => {
						this.loadlogo = true;
					}
				);
			},
			selectAreaid(e){
				this.city_id = e.id;
				console.log(e,1);
				this.getstoreList()
			},
			selectClassid(e){
				this.typeid = e.cate_one;
				this.cate_one = e.cate_one;
				console.log(e,2);
				this.title = e.name;
				this.getstoreList()
			},
			getmore(e){
				console.log(e,3)
			},
			getResumeList(e){
				console.log(e,4)
			},
			selectClassTwoid(e){
				console.log(e,5);
				this.typeid = e.cate_two;
				this.cate_two = e.cate_two;
				this.title = e.name;
				this.getstoreList()
			},
			selectOrders(e){
				console.log(e,6);
				this.sort = e.val;
				this.getstoreList();
			},
			getcityWork(e){
				console.log(e,7)
			}
		}
	}
</script>

<style>
	page{
		background-color: #F8F8F8;
	}
</style>
<style lang="scss" scoped>
	.app{
		padding-bottom: 150upx;
		.title{
			padding: 10upx 30upx;
			background-color: #FFFFFF;
		}
		.item{
			margin: 30upx 30upx 0;
		}
	}
</style>
