<template>
	<view>
		<u-navbar title="公司详情" :custom-back="back" ></u-navbar>
		<view class="resumeInfo">
			<view class="resumeInfo-company">
				<view class="resumeInfo-company-text">
					<view class="resumeInfo-company-name">
						<h3>{{companyInfo.name}}</h3>
						<view class="u-flex">
							<span>{{companyInfo.scaleName}}</span>
							<u-line color="#ccc" length="20" direction="col" margin="0 20rpx"/>
							<span>{{companyInfo.industryName}}</span>
						</view>
					</view>	
				</view>
				<u-avatar :src="companyInfo.logo" size="100" mode="square"></u-avatar>
			</view>
			<view class="resumeInfo-info-foot">
				<view class="resumeInfo-title">
					公司地址
				</view>
				<view class="resumeInfo-address">
					{{companyInfo.address}}
				</view>
			</view>
		</view>
		<view class="jp-work">
			<view class="jp-work-title">
				招聘岗位（{{recordsTotal}}）
			</view>
			<view class="jp-work-list">
				  
				 <RecruitmentItem v-for="(item ,index) in list" :key="item.id" :item="item" :ck="vck" @ckItem="ckBtn" ></RecruitmentItem>
				 <u-loadmore @loadmore="myLoadmore" :status="list.length<recordsTotal?'loadmore':'nomore'" ></u-loadmore>
				 
			</view>
		</view>
	</view>
</template>


<script>
	import * as API from '@/apis/job/job.js'
	
	import RecruitmentItem from '@/components/job/RecruitmentItem.vue'
	
 	export default {
		name:"Common",
		props:{
			vshow: {
				require: true,
				default: false,
			},
			vck: {
				require: false,
				default: true,
			},
			companyId:{
				require: false,
				default:""
			},
			companyInfo:{
				require: false,
				default:{}
			}
		},
		components:{RecruitmentItem},
		
		data() {
			return {
				pageIndex:0,
				recordsTotal:0,
				 myCompanyId:null,
				list:[],
			};
			
		},methods:{
			
			myLoadmore(){
				 
				 if(this.list.length<this.recordsTotal){
				  this.pageIndex+=1;
				  this.getInfo()
				 }
				
			},
			back(){
				this.$emit("back")
			},
			ckBtn(id){
				this.$emit("ckItem",id)
			},
			getInfo(){
				uni.showLoading({
					title:"加载中",mask:true,
				})
				var data={
					id:this.companyId,
					pageIndex:this.pageIndex
				};
				API.getCompanyDetails(data).then((res)=>{
					this.myCompanyId=this.companyId
					  if(this.pageIndex==1){
						  this.list=res.data.data;
					  }else{
						  this.list=[
						  	...this.list,
						  	...res.data.data
						  ];
					  }
					  this.recordsTotal=res.data.recordsTotal
					  
					 //this.list=res
					 uni.hideLoading()		
				 }).catch(error => {
						uni.showToast({
							title:error
						})
				})
				
			}
		},mounted(){
			 
				
		},destroyed(){
			
		},watch:{
			vshow:function(val) {
				
				if(val&&this.companyId&&(!this.myCompanyId||(this.myCompanyId&&this.companyId!=this.myCompanyId))){
					this.pageIndex=1;
					this.getInfo()
					document.getElementsByTagName('uni-page-wrapper')[0].style="background-color: #F7F7F7;"
					
				}else{
					document.getElementsByTagName('uni-page-wrapper')[0].style=""
					
				}
			}
		}
		
	}
</script>

<style >
	
</style>
 
<style scoped lang="scss">
	
	.resumeInfo-info{
		padding-top: 20rpx;
		.resumeInfo-info-head{
			font-size: 36rpx;
			font-weight: bold;
		}
		.resumeInfo-info-main{
			padding: 20rpx 0;
		}
	}
	.resumeInfo-info-foot{
		margin-top: 40rpx;
		.resumeInfo-title{
			color:#999;
		}
		.resumeInfo-address{
			flex: 1;
			min-width: 0;
			margin-top: 10rpx;
		}
	}
	.resumeInfo{
		background-color: #fff;
		padding: 20rpx;
		margin-bottom: 20rpx;
		.resumeInfo-row{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 10rpx;
			h3{
				font-size: 46rpx;
			}
			span{
				color:#2295FF;
				border: 1px solid #2295FF;
				padding: 0 10rpx;
				border-radius: 6rpx;
			}
			.jp-work-tag{
				display: flex;
				align-items: center;
				*{
					margin-right: 10rpx;
				}
			}
			h2{
				color:#FF6D58;
				font-size: 36rpx;
			}
		}
		
	}
	.resumeInfo-company{
		display: flex;
		align-items: center;
		padding-top: 20rpx;
		.resumeInfo-company-text{
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex: 1;
		}
		.resumeInfo-company-name{
			h3{
				margin-bottom: 10rpx;
				font-size: 40rpx;
			}
			span{
				color:#999;
				font-size: 24rpx;
			}
		}
	}
	.resumeInfo-data{
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 20rpx;
		padding: 20rpx 0;
		border-top: 1px solid #F7F7F7;
		border-bottom: 1px solid #F7F7F7;
		.resumeInfo-data-item{
			display: flex;
			flex-direction: column;
			align-items: center;
			p{
				font-size: 24rpx;
				color:#999;
				margin-bottom: 10rpx;
			}
			span{
				font-size: 32rpx;
			}
		}
	}
	.jp-work-title{
		background-color: #fff;
		border-bottom: 1px solid #F7F7F7;
		font-size: 32rpx;
		padding: 20rpx 20rpx;
	}
	.jp-work-item{
		padding:30rpx;
		background-color: #fff;
		border-bottom: 1px solid #f7f7f7;
		&:last-child{
			border-bottom:none;
		}
		.jp-work-name{
			display: flex;
			justify-content: space-between;
			align-items: center;
			h3{
				font-size: 36rpx;
			}
			span{
				font-size: 32rpx;
				color:#FF1700
			}
		}
		.jp-work-tag{
			display: flex;
			align-items: center;
			margin-top: 10rpx;
			*{
				margin-right: 10rpx;
			}
		}
		.jp-work-info{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 10rpx;
			p{
				color:#999;
				font-size: 24rpx;
				margin-left: 10rpx;
			}
		}
	}
</style>
