<template>
	<view style="padding-bottom: 100upx;">
		<loadlogo v-if="!loadlogo" />
		<far-bottom></far-bottom>
		<view v-if="loadlogo">
			<view class="dis-flex companiesList">
				<view  style="flex: 0.8;">
					<filtertab :pageName="'企业'" :requestType="'8'" :isPageScroll="'1'" @selectAreaid="selectAreaid" @selectClassid="selectClassid" @getmore="getmore" @getResumeList="getResumeList"
					 @selectClassTwoid="selectClassTwoid" @getcityWork="getcityWork" @selectOrders="selectOrders" :cate_one="cate_one" :cate_two="cate_two" :title="title"></filtertab>
				</view>
				<view class="f-26" style="flex: 0.2;line-height: 75upx;padding-left: 20upx;" @click="openclass">
					<text>更多</text>
					<text class="iconfont icon-unfold" style="padding-left: 10upx;vertical-align: top;"></text>
				</view>
			</view>
			<view class="enterpriseList" v-if="inviteList.length > 0">
				<view class="enterprise-item " v-for="(item,index) in inviteList" :key="index" @click="toCompanyDetails(item)">
					<view class="enterprise-border dis-flex">
						<view class="item-img"><image :src="item.logo" mode=""></image></view>
						<view class="item-content">
							<view class="content-title">
								{{item.storename}}
								<view class="dis-il-block title-tag" v-if="item.is_authentication == 1">已认证</view>
								<view class="f-24 col-9" style="float: right;font-weight: 500;">
									{{item.distances_text}}
								</view>
							</view>
							<view class="content-label">{{item.nature}} · {{item.scale}} · {{item.industry}}</view>
							<view class="content-num">
								{{item.area}} · 在招
								<text style="color: #3388FF;">{{ item.release_recruit }}</text>
								个
							</view>
						</view>
					</view>
				</view>
				<load-more :isMore="isMore" :bgc="'#ffffff'"></load-more>
			</view>
			<nonemores v-if="inviteList.length == 0 && isMore"></nonemores>
		</view>
		 <screening :check="check" :num="num" @close="close" @checkeda="checkeda" @confirm="confirm" v-bind:moreData.sync="moreData"></screening>
		
		<!-- 城市 -->
		<TabBars :tabBarAct="0" pageType="15"></TabBars>
	</view>
</template>

<script>
import App from '@/common/js/app.js';
import wPicker from '@/components/w-picker/w-picker.vue';
import loadMore from '@/components/template/loadmore.vue';
import Loadlogo from '@/components/template/loadlogo.vue';
import filtertab from '@/components/template/filtertab.vue';
import screening from '@/components/template/screening.vue';
import TabBars from '@/components/template/tabBar.vue';
import nonemores from '@/components/template/nonemores.vue'
export default {
	data() {
		return {
			cate_one:'',
			cate_two:'',
			title:'',
			check:false,
			resumeID:['','',''],
			inviteList:[],
			moreData:{},
			page:1,
			page_index:10,
			loadlogo:true,
			num:0,
			Areaid:'',
			ordersId:'',
			datas:{},
			isMore:true,
			total:1,
			enterpriseList:[],
			AreaidAt:''
		};
	},
	components: {
		wPicker,
		loadMore,
		Loadlogo,
		filtertab,
		screening,
		TabBars,
		nonemores
	},
	onLoad(e) {
		this.locationArray = uni.getStorageSync('agencyData');
		this.isMore = false;
		console.log(this.locationArray,'定位定位')
		// debugger
		// this.getCompaniesList()
	},
	onShow() {
		if(this.num != 0){
			// debugger
			this.confirm();
		}
	},
	onReachBottom() {
		if(this.total < this.page) return
		this.isMore = false;
		this.page++;
		this.confirm(false,true)
	},
	methods: {
		getcityWork(id){
			
			// debugger
			this.AreaidAt = id;
			if(this.num != 0){
				
				
				this.confirm();
			}
			
		},
		toCompanyDetails(item){
			App.navigationTo({
				url: "pages/subPages2/hirePlatform/companyDetails/companyDetails?id=" + item.id
			});
		},
		confirm(datas,flag){
			// debugger
			if(datas != false){
				this.page = 1;
			}
			if(datas){
				this.datas = datas;
			}
			let indata = {
				recruit_industry_id:this.resumeID[0],
				sort:this.ordersId,
				lat:this.locationArray.lat,
				lng:this.locationArray.lng,
				area_id:this.AreaidAt,
				is_total:1,
				page:this.page,
				page_index:this.page_index
			}
			let data = Object.assign(indata ,this.datas);
			App._post_form(
				`&p=recruit&do=enterpriseList`,
				data,
				res => {
					if(flag){
						this.inviteList = this.inviteList.concat(res.data.list);
					}else{
						this.inviteList = res.data.list;
					}
					this.inviteList.map(item=>{
						item.open = false;
					});
					this.total = res.data.total;
					this.check = false;
					this.isMore = true;
				},
				false,
				() => {
					this.loadlogo = true;
				}
			);
		},
		checkeda(index,key){
			console.log(index,key);
			this.moreData[key].map(item=>{
				item.checked = false
			});
			this.moreData[key][index].checked = true;
			let obj = Object.assign({},this.moreData);
			console.log(obj);
			this.moreData = {...obj}
			this.loadlogo = !this.loadlogo;
			this.loadlogo = !this.loadlogo;
		},
		getmore(data){
			data.top.map((item,index)=>{
				if(index > 2){
					this.moreData[item.subscript] = data[item.subscript];
				}
			});
			this.moreData.top = data.top;
			for(let key in this.moreData){
					this.moreData[key].map((item,index)=>{
							item.checked = false;
					})
			}
		},
		getResumeList(ids){
			this.resumeID = ids;
			this.num = 1;
			if(this.num != 0){
				this.confirm();
				console.log('职位');
			}
			
			// App._post_form(
			// 	`&p=recruit&do=resumeList`,
			// 	{},
			// 	res => {
			// 		this.inviteList = res.data;
			// 		this.inviteList.map(item=>{
			// 			item.open = false;
			// 		})
			// 	},
			// 	false,
			// 	() => {
					
			// 	}
			// );
		},
		close(flag){
			console.log(this.moreData);
			if(!flag){
				for(let key in this.moreData){
						this.moreData[key].map((item,index)=>{
								item.checked = false;
						})
				}
			}else{
				this.check = !this.check;
			}
		},
		openclass(){
			
			this.check = !this.check;
		},
		clickcheck(){
			this.check = !this.check;
		},
		selectOrders(data){
			
			this.ordersId = data.val;
			if(this.num != 0){
				// debugger
				this.confirm();
				console.log('排序');
			}
			console.log(data)
			
		},
		selectAreaid(data){
			this.num = 1;
			console.log('地区');
			this.Areaid = data.id;
			// debugger
			this.confirm();
			console.log(data)
		},
		selectClassid(data){
			console.log(data)
		},
		selectClassTwoid(data){
			console.log(data)
		}
	}
};
</script>

<style lang="scss" scoped>
.companiesList {
	padding: 10upx 0upx;
	.tab-item {
		font-size: 28upx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		.fonts {
			padding-left: 10upx;
			font-size: 26upx;
			color: #333333;
		}
	}
}
.enterpriseList {
	// padding-bottom: 100upx;
	.enterprise-item {
		padding: 0upx 30upx;
		.item-img {
			flex: 0.2;
			image {
				width: 100upx;
				height: 100upx;
				border-radius: 10upx;
			}
		}
		.item-content {
			padding-left: 30upx;
			flex: 0.8;
			.content-title {
				font-size: 32upx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				.title-tag {
					font-size: 22upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #ffffff;
					padding: 3upx 7upx;
					background: #3388ff;
					border-radius: 4upx;
					margin-left: 20upx;
				}
			}
			.content-label {
				font-size: 26upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
				padding: 30upx 0;
			}
			.content-num {
				font-size: 26upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
			}
		}
		.enterprise-border{
			padding: 40upx 0;
			border-top: 1upx solid #EEEEEE;
		}
	}
}
</style>
