<template>
	<view class="myDemand">
		<loadlogo v-if="!loadlogo" />
		<filtertab
		:requestType="'需求列表'" 
		:isPageScroll="'1'" 
		@selectAreaid="selectAreaid" 
		@selectClassid="selectClassid" 
		@getmore="getmore"
		@getResumeList="getResumeList"
		@selectClassTwoid="selectClassTwoid" 
		@selectOrders="selectOrders" 
		@getcityWork="getcityWork"
		:cate_one="cate_one" 
		:cate_two="cate_two"></filtertab>
		<view  v-if="demandList.length > 0">
			<view class="myDemand-item" v-for="(item,index) in demandList" :key="index">
				<demand-item :demanItem="item"></demand-item>
			</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>
		<!-- <view class="issue-myDemand">
			<text class="iconfont icon-add" style="font-size: 32upx;color: #FFFFFF;padding-right: 20upx;"></text> 
			 发布需求
		</view> -->
		<TabBars :tabBarAct="0" pageType="18"></TabBars>
	</view>
</template>

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

<style lang="scss" scoped>
	.myDemand{
		// padding: 20upx 30upx;
		margin-bottom: 150upx;
		.myDemand-item{
			margin-bottom: 20upx;
			padding: 20upx 30upx;
		}
		.reject{
			width: 610upx;
			padding: 20upx;
			border-radius: 0 0 20upx 20upx;
			background-color: #FF4444;
			color: #FFFFFF;
			font-size: 28upx;
			font-weight: 400;
			margin-left: 20upx;
			
		}
		.issue-myDemand{
			width: 690upx;
			height: 80upx;
			text-align: center;
			line-height: 80upx;
			color: #FFFFFF;
			font-size: 32upx;
			background: linear-gradient(360deg, #6094FD 0%, #70A8FD 100%);
			opacity: 1;
			border-radius: 20upx;
			position: fixed;
			bottom: 30upx;
			left: 30upx;
		}
	}
</style>
<style>
	page{
		background-color: #F8F8F8;
	}
</style>
