<template>
	<view class="gongsi-info">
		<image src="../static/images/gongsi-bg.png" class="gongsi-bg" mode=""></image>
		<u-navbar :fixed="false" bgColor='rgba(0,0,0,0)' placeholder :safeAreaInsetTop="true"
			@leftClick="return1"></u-navbar>
		<view class="" style="padding:  0 24rpx 0;box-sizing: border-box;">
			<view class="gongsi-header">
				<view class="header-top u-flex">
					<image :src="detail.company.logo" class="gongsi-logo" mode="aspectFill"></image>
					<view class="top-right u-flex-col u-flex-1">
						<text>{{detail.company.name || ''}}</text>
						<text>{{detail.company.categoryindustry.name || ''}}｜{{detail.company.scale.name || ''}}·{{detail.company.stage.name || ''}}</text>
					</view>
				</view>
				<view class="gongso-label u-flex u-flex-wrap">
					<text v-for="(a,b) in detail.company.welfare_tag_text" :key="b">{{a}}</text>
				</view>
			</view>
			<!-- 			<view class="gongsi-address">
				<view class="address-title">
					公司地址
				</view>
				<view class="address-down u-flex u-row-between">
					<text>{{detail.province || ''}}{{detail.city || ''}}{{detail.address || ''}}</text>
					<image src="static/address.png" mode="" @click="openlocation"></image>
				</view>
			</view> -->
			<view class="gongsi-text">
				<view class="text-title">
					学校介绍
				</view>
				<view class="">
					{{detail.title}}
				</view>
				<view class="text-body">
					{{detail.content || ''}}
				</view>
			</view>
			<!-- 			<view class="gongsi-text">
				<view class="text-title">
					公司优势
				</view>
				<view class="text-body">
					{{detail.welfare_tag_text ? detail.welfare_tag_text.join(',') : ''}}
				</view>
			</view> -->
		</view>
		<view class="" style="height: 220rpx;"></view>
		<!-- <u-mask :show="showzhiwei" z-index="990" @click="closeshaixuan"></u-mask> -->
		<u-overlay :show="showzhiwei" z-index="990" @click="closeshaixuan"></u-overlay>
		<view class="gongsi-zhiwei u-flex-col" :style="{bottom:showzhiwei ? '0' : 'calc(210rpx - 90vh)'}">
			<view class="zhiwei-header">
				<view class="header-top" v-if="showsearch">
					<u-search placeholder="搜索职位" @search="tosearch(1)" action-text="取消" @custom="chongzhi"
						v-model="keyword1"></u-search>
				</view>
				<view class="header-top u-flex u-row-between" v-else @click="openzhiwei">
					<text class="text1">校招职位（{{total}}）</text>
					<!-- <view @click.stop="opensearch">
						<u-icon name="search" size="32"></u-icon>
					</view> -->
				</view>
				<view class="header-shaixuan u-flex u-row-between">
					<view class="shaixuan-item u-flex u-row-center"
						:class="{shaixuanItemActive:(showshaixuan == 1 || zhiwei > 0)}" @click="openshaixuan(1)">
						<text class="text u-line-1">{{zhiwei == 0 ? '职位' : zhiweilist[zhiwei].name}}</text>
						<u-icon name="arrow-down-fill" size="16"></u-icon>
					</view>
					<view class="shaixuan-item u-flex u-row-center"
						:class="{shaixuanItemActive:(showshaixuan == 2 || city.id)}" @click="openshaixuan(2)">
						<text class="text u-line-1">{{city.name || '城市'}}</text>
						<u-icon name="arrow-down-fill" size="16"></u-icon>
					</view>
					<view class="shaixuan-item u-flex u-row-center"
						:class="{shaixuanItemActive:showshaixuan == 3 || xinzi.name}" @click="openshaixuan(3)">
						<text class="text u-line-1">{{xinzi.name || '薪资'}}</text>
						<u-icon name="arrow-down-fill" size="16"></u-icon>
					</view>
				</view>
			</view>
			<view class="zhiwei-list u-flex-1">
				<scroll-view v-if="showshaixuan == 1" scroll-y="true" class="zhiwei-shaixuan">
					<view class="shaixuan1-item" v-for="(a,b) in zhiweilist" :key="b" :class="{shaixuan1:zhiwei == b}"
						@click="changeshaixuan(1,b)">
						{{a.name}}
					</view>
				</scroll-view>
				<scroll-view scroll-y="true" class="zhiwei-scroll">
					<view class="zhiwei-item" v-for="(item,index) in list" :key="index" @click.stop="toinfo(item)">
						<view class="item-top u-flex u-row-between">
							<view class="u-flex">
								<text class="text1">{{item.job_name}}</text>
								<view class="xue" >校</view>
							</view>
							<text class="text3 u-flex-1">{{item.salary_min}}-{{item.salary_max}}K</text>
						</view>
						<view class="item-label u-flex">
							<text v-for="(a,b) in item.city " :key = "b">{{a.city.slice(0,-1)}}</text>
							<text>应届</text>
							<text>{{item.education.name}}</text>
						</view>
						<view class="item-down u-flex u-row-between">
							<view class="u-flex">
								<image style="width: 50rpx;height: 50rpx; border-radius: 50%;margin-right: 16rpx;" :src="item.user.avatar" mode=""></image>
								<text>{{item.user.name}}·{{item.user.job_text}}</text>
							</view>
							<view class="u-flex">
								<view class="btn1" @click.stop="">立即聊聊</view>
								<view class="btn2" @click.stop="">投递简历</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
			<view class="safe-area-inset-bottom"></view>
		</view>
		<u-picker :columns="citylist" :show="showcity" keyName="name" @confirm="changecity"
			@cancel="confirm1"></u-picker>
		<!-- <u-picker :columns="xinzilist"  :show="showxinzi"  @confirm="changexinzi" @cancel="confirm1"></u-picker> -->
		<picker mode=region @change="bindPickerChange" value="0" :range="clitylist" range-key="name"></picker>
	</view>
</template>

<script>
	import {
		get_company_job_list,
		jobdata,
		getexperience,
		getareacity,
		get_company_detail
	} from "@/units/inquire.js"
	export default {
		data() {
			return {
				showzhiwei: false,
				showsearch: false,

				showshaixuan: 0,

				zhiweilist: [],
				zhiwei: 0,

				jingyanlist: [],
				jingyan: -1,

				showcity: false,
				citylist: [],
				province: [], //省份
				city: [],
				area: [], //区域

				city: {
					id: '',
					name: ''
				},

				showxinzi: false,
				xinzilist: [],
				xinzi: {
					max: '',
					min: '',
					name: ''
				},

				keyword1: '',
				keyword: '',

				page: 1,
				total: 0,
				list: [],

				detail: {}
			}
		},
		onLoad(option) {
			this.id = option.id
			this.getdata()
			this.getlist()
			this.getconfig()
		},
		methods: {
			confirm1() {
				this.showxinzi = false,
					this.showcity = false
			},
			return1() {
				uni.navigateBack()
			},
			toinfo(item) {
				uni.navigateTo({
					url: "/pagesB/details?id=" + item.id
				})
			},
			openlocation() {
				uni.openLocation({
					longitude: Number(this.detail.lng),
					latitude: Number(this.detail.lat)
				})
			},
			getdata() {
				get_company_detail({
					id: this.id
				}).then((res) => {
					this.detail = res.data
				})
			},
			chongzhi() {
				this.keyword1 = ''
				this.showsearch = false
				this.tosearch()
			},
			opensearch() {
				if (this.showzhiwei) {
					this.showsearch = true
				} else {
					this.showzhiwei = true
				}
			},
			changexinzi(e) {
				if (e[0].value > e[1].value) {
					this.xinzi.min = e[1].value
					this.xinzi.max = e[0].value
					this.xinzi.name = e[1].value + "-" + e[0].label
				} else {
					this.xinzi.min = e[0].value
					this.xinzi.max = e[1].value
					this.xinzi.name = e[0].value + "-" + e[1].label
				}
				this.tosearch()
			},
			changeshaixuan(type, index) {
				if (type == 1) {
					this.zhiwei = index
				}
				this.showshaixuan = 0
				this.tosearch()
			},
			changecity(e) {
				this.city.id = e[1].value
				this.city.name = e[1].label
				this.tosearch()
			},
			closeshaixuan() {
				this.showzhiwei = false;
				this.showsearch = false
				this.showshaixuan1 = false
			},
			openshaixuan(type) {
				if (!this.showzhiwei) {
					this.showzhiwei = true
					return
				}
				if (this.showshaixuan == type) {
					this.showshaixuan = 0
				} else {
					this.showshaixuan = type
				}
				if (type == 3) {
					this.showcity = true
				}
				if (type == 4) {
					this.showxinzi = true
				}
			},
			tosearch(type) {
				if (type == 1) {
					this.keyword = this.keyword1
				}
				this.page = 1
				this.total = 0
				this.list = []
				this.getlist()
			},
			openzhiwei() {
				if (this.showzhiwei) {
					this.showzhiwei = false
					this.showsearch = false
				} else {
					this.showzhiwei = true
				}
			},
			getlist() {
				// 招聘信息列表
				get_company_job_list({
					id: this.id,
					category_job_id: this.zhiwei > 0 ? this.zhiweilist[this.zhiwei].id : '',
					city_id: this.city.id,
					education_id: this.jingyan == -1 ? '' : this.jingyanlist[this.jingyan].id,
					salary_min: this.xinzi.min,
					salary_max: this.xinzi.max
				}).then(res => {
					this.total = res.data.length
					this.list = res.data
				})
			},
			getconfig() {
				jobdata({
					id: this.id
				}).then(res => {
					this.zhiweilist = res.data
				})
				getexperience().then(res => {
					this.jingyanlist = res.data
				})
				getareacity().then(res => {
					this.citylist = res.data
				})
				var xinzilist = []
				for (var i = 1; i <= 100; i++) {
					xinzilist.push({
						label: `${i}K`,
						value: i
					})
				}
				this.xinzilist.push(xinzilist)
				this.xinzilist.push(xinzilist)
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F3F3F3;
	}
	
	
	.btn1{
		width: 150rpx;
		height: 60rpx;
		background: #0C66C2;
		border-radius: 8rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 60rpx;
		text-align: center;
	}
	.btn2{
		width: 150rpx;
		height: 60rpx;
		background: #FA6400;
		border-radius: 8rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 60rpx;
		text-align: center;
		margin-left: 20rpx;
	}

	.xue {
		width: 36rpx;
		height: 32rpx;
		background: #0C66C2;
		border-radius: 8rpx 0rpx 8rpx 0rpx;
		font-size: 22rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 32rpx;
		text-align: center;
		margin-left: 12rpx;
	}

	.gongsi-info {
		position: relative;
		z-index: 1;

		.zhiwei-list {
			min-height: 1rpx;
			position: relative;

			.zhiwei-shaixuan {
				position: absolute;
				top: 0;
				left: 0;
				z-index: 1;
				background-color: #fff;
				width: 750rpx;
				height: 100%;
				padding: 16rpx 0;
				box-sizing: border-box;

				.shaixuan1-item {
					padding: 16rpx 66rpx;
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #444444;
				}

				.shaixuan1 {
					font-size: 28rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #0C66C2;
				}
			}

			.zhiwei-scroll {
				height: 100%;

				.zhiwei-item {
					// width: 702rpx;
					background: #FFFFFF;
					border-radius: 20rpx;
					margin: 20rpx auto;
					padding: 0 20rpx 24rpx 20rpx;

					.item-down {
						text:first-child {
							font-size: 24rpx;
							font-family: SFPro-Regular, SFPro;
							font-weight: 400;
							color: #666666;
							margin-left: 16rpx;
						}
					}

					.item-label {
						margin-bottom: 24rpx;
						text {
							line-height: 46rpx;
							background: #F3F3F3;
							border-radius: 4rpx;
							padding: 0 14rpx;
							font-size: 24rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #5F5F5F;
							display: block;
							margin-left: 12rpx;
						}
					}

					.item-top {
						padding: 24rpx 0 20rpx 0;

						.text1 {
							font-size: 32rpx;
							font-family: PingFangSC-Medium, PingFang SC;
							font-weight: 500;
							color: #222222;
						}

						.text2 {
							margin: 0 16rpx;
							line-height: 32rpx;
							background: #E6EFF8;
							border-radius: 6rpx;
							padding: 0 4rpx;
							font-size: 20rpx;
							font-family: SFPro-Regular, SFPro;
							font-weight: 400;
							color: #0C66C2;
						}

						.text3 {
							text-align: right;
							font-size: 32rpx;
							font-family: JDZhengHT-Regular, JDZhengHT;
							font-weight: 400;
							color: #0C66C2;
						}
					}
				}
			}
		}


		.gongsi-zhiwei {
			position: fixed;
			left: 0;
			bottom: 0;
			width: 750rpx;
			height: 90vh;
			background: #F3F3F3;
			box-shadow: 0rpx -8rpx 48rpx 0rpx rgba(0, 0, 0, 0.2);
			border-radius: 28rpx 28rpx 0rpx 0rpx;
			z-index: 999;
			transition: all 0.3s;
			border-radius: 28rpx 28rpx 0 0;
			overflow: hidden;

			.zhiwei-header {
				border-bottom: 2rpx solid #F3F3F3;
				background-color: #fff;
				padding: 0 32rpx;

				.header-shaixuan {
					padding-bottom: 28rpx;

					.shaixuan-item {
						width: 150rpx;
						height: 60rpx;
						background: #F3F3F3;
						border-radius: 6rpx;

						.text {
							font-size: 26rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #333333;
							margin-right: 16rpx;
							max-width: 80rpx;
						}
					}

					.shaixuanItemActive {
						background-color: #E6EFF8;
						color: #0C66C2;

						.text {
							color: #0C66C2;
						}
					}
				}

				.header-top {
					padding: 32rpx 0;

					.text1 {
						font-size: 40rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #222222;
					}
				}
			}
		}

		.gongsi-text {
			// width: 702rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			padding: 0 20rpx 24rpx 20rpx;
			margin: 20rpx auto;

			.text-body {
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #555555;
			}

			.text-title {
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #222222;
				padding: 24rpx 0;
			}
		}

		.gongsi-address {
			// width: 702rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			margin: 20rpx auto;
			padding: 0 20rpx 24rpx 20rpx;

			.address-down {
				text {
					flex: 1;
					margin-right: 20rpx;
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
				}

				image {
					width: 70rpx;
					height: 70rpx;
				}
			}

			.address-title {
				padding: 24rpx 0;
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #222222;
			}
		}

		.gongsi-header {
			// width: 702rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			margin: 20rpx auto;
			padding: 0 24rpx;

			.gongso-label {
				text {
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #444444;
					padding: 0 12rpx;
					line-height: 50rpx;
					background: #F3F3F3;
					border-radius: 6rpx;
					margin-right: 16rpx;
					margin-bottom: 20rpx;
				}
			}

			.header-top {
				padding: 28rpx 0;

				.top-right {
					text:first-child {
						font-size: 40rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #222222;
						margin-bottom: 12rpx;
					}

					text:nth-child(2) {
						font-size: 26rpx;
						font-family: SFPro-Regular, SFPro;
						font-weight: 400;
						color: #555555;
					}
				}

				.gongsi-logo {
					width: 120rpx;
					height: 120rpx;
					border-radius: 12rpx;
					border: 2rpx solid rgba(151, 151, 151, 0.7);
					margin-right: 20rpx;
				}
			}
		}

		.gongsi-bg {
			position: absolute;
			top: 0;
			left: 0;
			width: 750rpx;
			height: 396rpx;
			z-index: -1;
		}
	}
</style>