<template>
	<view class="page">
		<navbar title="工作详情" leftClick @leftClick="$utils.navigateBack" />

		<view class="box">
			<view class="title">
				{{ detail.title }}
			</view>

			<view class="price">
				{{ detail.salaryLow }}-{{ detail.salaryUp }}元
			</view>

			<view class="line">
				<!-- <view>
					<image src="../static/work/address.png" mode=""></image>
					{{ detail.workAge }}
				</view> -->
				<view>
					<image src="../static/work/g.png" mode=""></image>
					{{ detail.workAge }}
				</view>
				<view>
					<image src="../static/work/x.png" mode=""></image>
					{{ detail.qulification }}
				</view>
			</view>

			<view class="line">
				该职位发布{{ $dayjs(detail.createTime).format('YYYY-MM-DD') }}
			</view>

			<view class="userHead">
				<userHead :image="hanHaiMember.headImage" :tips="personInfo.phone" :name="personInfo.name"
					:phoneCall="personInfo.phone" />
			</view>

			<view class="address"
			@click="openLocation(detail.latitude, detail.longitude)">
				<view class="title2">
					工作地址
				</view>
				<!-- 
					深圳罗湖区深圳市百货广场大厦罗湖区百货广场大厦东深圳罗湖区深圳市百货广场大厦罗湖区百货广场大厦东
					-->
				<view class="line" style="justify-content: space-between;">
					{{ detail.workAddress }}
					<uv-icon size="30rpx" color="666" name="arrow-right"></uv-icon>
				</view>

				<!-- <view class="tag-list">
					<view>
						距您14.6千米
					</view>
				</view> -->
			</view>

			<view class="info">
				<view class="title2">
					<text>职位详情</text>

					<view v-if="collectionFlag == false" @click="addJobCollection">
						<uv-icon size="30rpx" color="666" name="star"></uv-icon>
						收藏
					</view>



					<view v-else @click="addJobCollection" style="color: red;">
						<uv-icon size="30rpx" color="666" name="star"></uv-icon>
						已收藏
					</view>
				</view>

				<view class="tag-list">
					<view :key="i" v-for="(t, i) in detail.tab && detail.tab.split('、')">
						{{ t }}
					</view>
				</view>

				
				<view class="text">
					<uv-parse :content="detail.workDetail"></uv-parse>
				</view>
			</view>

		</view>

		<view class="boss-box" @click="$utils.navigateTo('/pages_order/work/bossDetail?id='+detail.id)">
			<view class="image">
				<image :src="companyInfo.logo" mode=""></image>
			</view>
			<view class="shop-box">
				<view class="title">
					{{companyInfo.companyName}}
				</view>
				<view class="desc">
					{{companyInfo.financing}}*{{companyInfo.industry}}*{{companyInfo.number}}
				</view>
			</view>
			<view class="arrow-right">
				<uv-icon name="arrow-right" size="40rpx" color="#5baaff"></uv-icon>
			</view>
		</view>

		<view class="list-work">

			<view class="text">
				推荐职位<text>{{total}}</text>
			</view>

			<view style="margin: 20rpx;" 
			@click="$utils.navigateTo('/pages_order/work/workDetail?id=' + item.id)"
				:key="index" v-for="(item, index) in list">
				<workItem :item="item" />
			</view>
		</view>

	</view>
</template>

<script>
	import userHead from '../components/user/userHead.vue'
	import mixinList from '@/mixins/list.js'
	import workItem from '@/components/list/workList/workItem.vue'
	export default {
		mixins: [mixinList],
		components: {
			userHead,
			workItem,
		},
		data() {
			return {
				text: '',
				id: 0,
				detail: {},
				personInfo: {},
				companyInfo: {},
				hanHaiMember: {},
				total: 0,
				collectionFlag: false,
				mixinsListApi: 'employeeQueryJobList',
			}
		},
		onLoad({
			id
		}) {
			this.id = id
			this.queryParams.id = id;
		},
		onShow() {
			this.getDetail()
		},
		methods: {
			getDetail() {
				let data = {
					jobId: this.id
				}
				if (uni.getStorageSync('token')) {
					data.token = uni.getStorageSync('token')
				}
				this.$api('employeeQueryJobById', data, res => {
					if (res.code == 200) {
						this.detail = res.result.jobInfo
						this.collectionFlag = res.result.collectionFlag
						this.personInfo = res.result.personInfo
						this.companyInfo = res.result.companyInfo
						this.hanHaiMember = res.result.hanHaiMember
					}
				})
			},
			addJobCollection() {
				let data = {
					jobId: this.id
				}
				if (uni.getStorageSync('token')) {
					data.token = uni.getStorageSync('token')
				}
				this.$api('addJobCollection', data, res => {
					if (res.code == 200) {
						uni.showToast({
							title: res.message,
							icon: 'none'
						})
					}
				})
				this.getDetail();
			}
		}
	}
</script>

<style scoped lang="scss">
	.page {
		min-height: 100vh;

		.box {
			padding: 30rpx;
			background-color: #fff;

			.title {
				font-size: 34rpx;
				font-weight: 900;
				padding-bottom: 20rpx;
			}

			.title2 {
				font-size: 28rpx;
				font-weight: 900;
				display: flex;
				justify-content: space-between;
				align-items: center;

				view {
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}

			.price {
				font-size: 30rpx;
				font-weight: 900;
				color: $uni-color;
			}

			.line {
				display: flex;
				font-size: 24rpx;
				color: #666666;
				margin-top: 30rpx;

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

				&>view {
					margin-right: 50rpx;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}

			.userHead {
				padding: 50rpx 0;
				border-bottom: 1px solid #00000011;
			}

			.address {
				padding: 30rpx 0;

				.line {
					margin-top: 20rpx;
				}
			}

			.info {
				.text {
					font-size: 24rpx;
					color: #666666;
					line-height: 44rpx;
				}
			}
		}

		.boss-box {
			margin: 10rpx 0;
			padding: 30rpx;
			background-color: #fff;
			display: flex;
			align-items: center;

			.image {
				width: 90rpx;
				height: 90rpx;
				margin-right: 10rpx;
				flex-shrink: 0;

				image {
					width: 100%;
					height: 100%;
					border-radius: 10rpx;
				}
			}

			.shop-box {
				flex: 1;
				width: calc(100% - 220rpx);

				.title {
					font-size: 28rpx;
					overflow: hidden; //超出的文本隐藏
					text-overflow: ellipsis; //溢出用省略号显示
					white-space: nowrap; //溢出不换行
				}

				.desc {
					margin-top: 10rpx;
					font-size: 24rpx;
					overflow: hidden; //超出的文本隐藏
					text-overflow: ellipsis; //溢出用省略号显示
					white-space: nowrap; //溢出不换行
				}
			}

			.arrow-right {
				flex-shrink: 0;
				margin-left: auto;
				display: flex;
				align-items: center;
				font-size: 26rpx;
			}
		}

		.list-work {
			.text {
				background-color: #fff;
				padding: 26rpx;
				font-weight: 900;

				text {
					font-weight: 500;
					color: #666666;
					font-size: 26rpx;
					margin-left: 20rpx;
				}
			}
		}
	}
</style>