<template>
	<view class="content">
		<view class="top">
			<u-navbar title=" " @leftClick="leftClick" height="44px" bgColor="rgb(255,255,255,0)" :placeholder="true">
			</u-navbar>
			<view class="hflex acenter jbetween">
				<view >
					<view class="top_name">{{pageData.name}}</view>
					<view class="scale">{{pageData.scale}}</view>
				</view>
				<image :src="pageData.img" mode="aspectFill" class="top_avatar"></image>
			</view>
		</view>
		<view class="box">
			<view class="hflex acenter jcenter tabs">
				<view class="tabs_item" :class="tab_active == 1 ? 'tab_active' :''" @click="changeTab(1)">公司信息</view>
				<view class="tabs_item" :class="tab_active == 2 ? 'tab_active' :''" @click="changeTab(2)">职位信息</view>
			</view>
			<view class="box1" v-if="tab_active == 1">
				<view class="title cell">公司简介</view>
				<view class="cell">
					<u-read-more closeText="展开" :shadowStyle="shadowStyle" ref="uReadMore" :toggle="true" openText="收起" showHeight="66" backgroundImage="none">
						<u-parse :content="pageData.company.company_info" @load="load"></u-parse>
					</u-read-more>
				</view>
				<view class="title cell">公司地址</view>
				<view class="cell">
					<view class="text">{{pageData.company.company_address}}</view>
				</view>
				<view class="title cell">公司环境</view>
				<view class="cell">
					<block v-for="(item,index) in pageData.company.company_environment" :key="index">
						<image :src="item" mode="aspectFill" class="img"></image>
					</block>
				</view>
				<view class="title cell">产品介绍</view>
				<view class="cell">
					<view class="text">{{pageData.company.company_product}}</view>
				</view>
			</view>
			<view class="list" v-if="tab_active == 2">
				<block v-for="(item,index) in pageData.position" :key="index">
					<view class="list_item">
						<view class="hflex acenter jbetween">
							<view class="item_title">{{item.title}}</view>
							<view class="item_blue">{{item.salary}}·{{item.monthly}}薪</view>
						</view>
						<view class="hflex acenter" style="padding: 20rpx 0 24rpx;">
							<view class="item_box">{{item.city}}</view>
							<view class="item_box">{{item.education}}</view>
							<view class="item_box">{{item.experience}}</view>
						</view>
						<view class="item_name">{{item.company_name}}</view>
						<view class="hflex acenter jbetween" style="padding-top: 16rpx;">
							<view class="hflex acenter">
								<image class="item_avatar" :src="item.user.avatar"></image>
								<view class="user_name">{{item.user.position}}·{{item.user.name}}</view>
							</view>
							<view class="user_right">{{item.user.city}}·{{item.user.area}}</view>
						</view>
					</view>
				</block>
			</view>
		</view>
		<view class="bottom hflex acenter jbetween">
			<view class="vflex acenter" @click="collect">
				<u-icon name="star" color="#444444" size="20" v-if="pageData.is_collect == 0"></u-icon>
				<u-icon name="star-fill" color="#506DFF" size="20" v-else></u-icon>
				<view class="text_style1">收藏</view>	
			</view>	
			<view class="vflex acenter" @click="share('Poster1')">
				<image src="/static/images/comment/share.png" mode="" class="bottom_img"></image>	
				<view class="text_style1">分享</view>	
			</view>	
			<view class="bottom_btn">私信聊聊</view>
		</view>
		<view class="share_content" :class="share_show?'':'share_content1'">
			<view class="share_box vflex">
				<text class="share_name Poster1" style="margin: 40rpx 0 28rpx;" :data-enode="pageData.name">{{pageData.name}}</text>
				<text class="share_label Poster1" style="margin: 0 0 16rpx;" data-enode="船厂简介">船厂简介</text>
				<view class="share_text Poster1" style="margin: 0 0 24rpx;" data-etype="textarea" :data-enode="pageData.company.company_info">{{pageData.company.company_info}}</view>
				<text class="share_label Poster1" style="margin: 0 0 16rpx;" data-enode="船厂介绍">船厂介绍</text>
				<view class="share_text Poster1" style="margin: 0 0 42rpx;" data-etype="textarea" :data-enode="pageData.company.company_product">{{pageData.company.company_product}}</view>
				<view class="hflex acenter share_text jcenter Poster1" style="text-align: center; margin: 0 0 12rpx;" data-enode="长按或扫码查看">长按或扫码查看</view>
				<view style="width: 100%;" class="hflex acenter jcenter">
					<image class="Poster1" style="width: 25rpx;height: 20rpx;" data-enode="/static/images/comment/down2.png" data-etype="image" src="/static/images/comment/down2.png"></image>
				</view>
				<view class="hflex acenter jbetween">
					<view class="vflex">
						<view class="share_name Poster1" style="margin: 54rpx 0 20rpx;" data-enode="船百知">船百知</view>
						<view class="share_text Poster1" style="margin: 0 0 36rpx;" data-enode="船百知伴你一起杨帆启航,驶向成功彼岸">船百知伴你一起杨帆启航,驶向成功彼岸</view>
					</view>
					<image class="Poster1" data-etype="image" :data-enode="pageData.img" :src="pageData.img" style="width: 136rpx;height: 136rpx;"></image>
				</view>
			</view>
			<evils-el-poster width="750" height="1150" @on-error="onError" :list="list" backgroundColor="rgb(255, 255, 255)" @on-success="onSuccess" ref="Eposter"></evils-el-poster>
			<view class="share_bottom">
				<view class="hflex acenter jbetween">
					<button class="vflex acenter jcenter bottom_item" open-type="share">
						<image src="/static/images/comment/wx.png" class="item_icon"></image>
						<view class="item_text">微信好友</view>
					</button>
					<button class="vflex acenter jcenter bottom_item" open-type="share">
						<image src="/static/images/comment/moments.png" class="item_icon"></image>
						<view class="item_text">朋友圈</view>
					</button>
					<view class="vflex acenter jcenter bottom_item" @click="saveImg">
						<image src="/static/images/comment/download.png" class="item_icon"></image>
						<view class="item_text">保存图片</view>
					</view>
				</view>
				<view class="share_cancel" @click="close">取消</view>
			</view>
		</view>
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	var that = ''
	export default {
		data() {
			return {
				list: [],
				pageData: {
					img: require('@/static/images/mine/avatar1.jpg'),
					name: '江南造船厂',
					scale: '20-99人',
					company: {
						company_info: '2012年4月22日正式上线，推崇品质、青春、时尚的品牌内涵2012年4月22日正式上线，推崇品质、青春、时尚的品牌内涵2012年4月22日正式上线，推崇品质、青春、时尚的品牌内涵2012年4月22日正式上线，推崇品质、青春、时尚的品牌内涵2012年4月22日正式上线，推崇品质、青春、时尚的品牌内涵2012年4月22日正式上线，推崇品质、青春、时尚的品牌内涵',
						company_address: '江苏省南京市浦口区东方万汇城23号楼1单元2203',
						company_environment: ['/static/images/mine/avatar1.jpg','/static/images/mine/avatar1.jpg','/static/images/mine/avatar1.jpg'],
						company_product: ' 根据《中华人民共和国价格法》标准等，自2022年4月30日起执行。根据《中华人民共和国价格法》标准等，自2022年4月30日起执行。根据《中华人民共和国价格法》标准等，自2022年4月30日起执行。根据《中华人民共和国价格法》标准等，自2022年4月30日起执行。根据《中华人民共和国价格法》标准等，自2022年4月30日起执行。根据《中华人民共和国价格法》标准等，自2022年4月30日起执行。'	
					},
					position: [
						{
							id: 0,
							title: '船舶设计师',
							salary: '13-15K',
							monthly: '13',
							city: '北京',
							education: '本科',
							experience: '经验不限',
							company_name: '北京文化旅游产业发展集团有限公司',
							user: {
								avatar: '/static/images/mine/avatar1.jpg',
								name: '江女士',
								position: '行政总监',
								city: '北京市',
								area: '东城区',
							},
						},
						{
							id: 0,
							title: '船舶设计师',
							salary: '13-15K',
							monthly: '13',
							city: '北京',
							education: '本科',
							experience: '经验不限',
							company_name: '北京文化旅游产业发展集团有限公司',
							user: {
								avatar: '/static/images/mine/avatar1.jpg',
								name: '江女士',
								position: '行政总监',
								city: '北京市',
								area: '东城区',
							},
						},
						
						{
							id: 0,
							title: '船舶设计师',
							salary: '13-15K',
							monthly: '13',
							city: '北京',
							education: '本科',
							experience: '经验不限',
							company_name: '北京文化旅游产业发展集团有限公司',
							user: {
								avatar: '/static/images/mine/avatar1.jpg',
								name: '江女士',
								position: '行政总监',
								city: '北京市',
								area: '东城区',
							},
						}
					],
					is_collect: 0
				},
				tab_active: 1,
				shadowStyle: {
					backgroundImage: "none",
				},
				share_show: false,
				tempImage:''
			}
		},
		onLoad() {
			that = this
			
		},
		onShareAppMessage(res) {
			console.log(res);
		    if (res.from === 'button') {// 来自页面内分享按钮
		        console.log(res.target)
		    }
		    return {
		        title: '船百知', //分享的名称
		    }
		},
		onShareTimeline(res) {
			console.log(res);
		    return {
		        title: '船百知',
		        type: 0,
		        summary: "",
		    }
		},
		methods: {
			// 返回
			leftClick() {
				console.log('返回');
				$api.jump(-1)
			},
			// 切换tabs
			changeTab(index) {
				that.tab_active = index
			},
			load() {
				this.$refs.uReadMore.init();
			},
			// 收藏
			collect() {
				if(that.pageData.is_collect == 0) {
					that.pageData.is_collect = 1
					$api.info('收藏成功')
				} else {
					that.pageData.is_collect = 0
					$api.info('取消收藏')
				}
			},
			share(elClass) {
				let view = uni.createSelectorQuery().in(this).select(".Poster1");
				
				view.fields({
				  size: true,
				  rect: true,
				  scrollOffset: true
				}, data => {
				  console.log("得到节点信息" + JSON.stringify(data));
				  console.log("节点的宽为" + data.width);
				}).exec();
				that.share_show = true
				that.$refs.Eposter.createForElRect(elClass,false)
			},
			close() {
				that.share_show = false
			},
			onSuccess(e) {
				console.log(e);
				that.tempImage = e
			},
			onError(err) {
				console.log(err);
			},
			saveImg() {
				console.log(that.tempImage);
				uni.authorize({
				    scope: 'scope.writePhotosAlbum',
				    success() {
				        uni.saveImageToPhotosAlbum({
				        	filePath: that.tempImage,
				        	success: function () {
				        		console.log('save success');
				        	}
				        });
				    }
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	.content {
		position: relative;
		.top {
			background: url('../../../static/images/comment/nav_bg.png') no-repeat;
			background-size: 100%;
			box-sizing: border-box;
			padding: 30rpx;
			height: 540rpx;
			.top_name {
				font-size: 36rpx;
				font-weight: 500;
				color: #222222;
				line-height: 50rpx;
			}
			.scale {
				font-size: 24rpx;
				font-weight: 400;
				color: #222222;
				line-height: 34rpx;
			}
			.top_avatar {
				width: 116rpx;
				height: 116rpx;
				border-radius: 16rpx;
			}
		}
		.box {
			position: absolute;
			left: 0;
			top: 344rpx;
			width: 100%;
			min-height: calc(100vh - 256rpx);
			background: #FFFFFF;
			border-radius: 40rpx 40rpx 0px 0px;
			.tabs {
				width: 100%;
				padding: 36rpx 0 40rpx;
				.tabs_item {
					font-size: 32rpx;
					font-weight: 500;
					color: #959595;
					line-height: 44rpx;
					width: 50%;
					text-align: center;
				}
				.tab_active {
					position: relative;
					color: #222222;
				}
				.tab_active::after {
					content: "";
					position: absolute;
					bottom: -8rpx;
					left: 39%;
					width: 80rpx;
					height: 4rpx;
					background: #506DFF;
					border-radius: 4rpx;
				}
			}
			.box1 {
				width: 100%;
				box-sizing: border-box;
				padding: 0 30rpx;
				margin-bottom: 186rpx;
				.title {
					font-size: 36rpx;
					font-weight: 500;
					color: #222222;
					line-height: 50rpx;
				}
				.cell {
					padding: 14rpx 0;
				}
				.text {
					font-size: 28rpx;
					font-weight: 400;
					color: #555555;
					line-height: 40rpx;
				}
				.img {
					width: 220rpx;
					height: 220rpx;
					border-radius: 12rpx;
					margin: 0 16rpx 20rpx 0;
				}
				.img:nth-child(3n+3) {
					margin: 0 0 20rpx;
				}
			}
			.list {
				box-sizing: border-box;
				width: 100%;
				padding: 0 30rpx;
				.list_item {
					width: 100%;
					padding: 28rpx 0 20rpx;
					border-top: 1rpx solid #F4F4F4;
					.item_title {
						font-size: 32rpx;
						font-weight: 600;
						color: #222222;
					}
					.item_blue {
						font-size: 32rpx;
						font-weight: bold;
						color: #506DFF;
					}
					.item_box {
						height: 40rpx;
						background: #F0F2F6;
						border-radius: 2px;
						box-sizing: border-box;
						padding: 4rpx 18rpx;
						font-size: 22rpx;
						font-weight: 400;
						color: #444444;
						margin-right: 20rpx;
					}
					.item_name {
						font-size: 24rpx;
						font-weight: 400;
						color: #666666;
					}
					.item_avatar {
						width: 40rpx;
						height: 40rpx;
						border-radius: 50%;
						margin-right: 12rpx;
					}
					.item_avatar1 {
						width: 88rpx;
						height: 88rpx;
						border-radius: 50%;
						margin-right: 20rpx;
					}
					.item_right1 {
						
					}
					.text_style1 {
						font-size: 22rpx;
						font-weight: 400;
						color: #666666;
						padding: 12rpx 0;
					}
					.item_box1 {
						margin-top: 8rpx;
						background: #EDF0FF;
						border-radius: 8rpx;
						box-sizing: border-box;
						padding: 4rpx 16rpx;
						font-size: 24rpx;
						font-weight: 400;
						color: #506DFF;
					}
					.item_btn1 {
						width: 140rpx;
						height: 52rpx;
						background: #F1F3FF;
						border-radius: 28rpx;
						font-size: 26rpx;
						font-weight: 500;
						color: #506DFF;
						line-height: 52rpx;
						text-align: center;
					}
					.user_name {
						font-size: 20rpx;
						font-weight: 400;
						color: #333333;
					}
					.user_right {
						font-size: 20rpx;
						font-weight: 400;
						color: #A1A1A1;
					}
				}
			}
		}
		.bottom {
			width: 100%;
			z-index: 9;
			position: fixed;
			bottom: 0;
			height: 166rpx;
			background: #FFFFFF;
			box-sizing: border-box;
			padding: 8rpx 30rpx 74rpx;
			
			.bottom_btn {
				width: 530rpx;
				height: 84rpx;
				background: #506DFF;
				border-radius: 42rpx;
				font-size: 36rpx;
				font-weight: 500;
				color: #FFFFFF;
				text-align: center;
				line-height: 84rpx;
			}
			.bottom_btn1 {
				width: 204rpx;
				height: 84rpx;
				border-radius: 21px;
				border: 1px solid #506DFF;
				font-size: 36rpx;
				font-weight: 500;
				color: #506DFF;
				text-align: center;
				line-height: 84rpx;
				margin-right: 20rpx;
			}
			.bottom_btn2 {
				width: 300rpx;
				height: 84rpx;
				border-radius: 21px;
				background: #506DFF;
				color: #FFFFFF;
				font-size: 36rpx;
				font-weight: 500;
				text-align: center;
				line-height: 84rpx;
			}
			.bottom_img {
				width: 40rpx;
				height: 40rpx;
			}
			
		}
		.share_content {
			position: absolute;
			top: 0;
			left: 0;
			z-index: 99;
			width: 100vw;
			min-height: 100vh;
			background: rgba(0,0,0,0.5);
			backdrop-filter: blur(5px);
			.share_box {
				margin: 168rpx auto;
				width: 650rpx;
				background: #FFFFFF;
				border-radius: 20rpx;
				box-sizing: border-box;
				padding: 0 40rpx;
				.share_name {
					width: 100%;
					font-size: 32rpx;
					font-weight: 500;
					color: #222222;
					line-height: 44rpx;
				}
				.share_label {
					width: 100%;
					font-size: 28rpx;
					font-weight: 400;
					color: #222222;
					line-height: 40rpx;
				}
				.share_text {
					width: 100%;
					font-size: 24rpx;
					font-weight: 400;
					color: #999999;
					line-height: 34rpx;
					text-overflow: ellipsis;
					overflow: hidden;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					box-orient: vertical;
					line-clamp: 5;
					-webkit-line-clamp: 5;
				}
				.box_bottom {
					width: 100%;
					padding: 34rpx 0 16rpx;
					border-top: 1rpx dashed #C3C3C3;
					
					.bottom_left1 {
						font-size: 32rpx;
						font-weight: 500;
						color: #222222;
						line-height: 44rpx;
						padding-bottom: 20rpx;
						
					}
					.bottom_left2 {
						font-size: 22rpx;
						font-weight: 400;
						color: #999999;
						line-height: 32rpx;
					}
					.bottom_right {
						width: 136rpx;
						height: 136rpx;
					}
				}
			}
			.canvas {
				position: absolute;
				top: 188rpx;
				left: 50rpx;
				width: 650rpx;
				min-height: 494rpx;
				background: #FFFFFF;
				border-radius: 20rpx;
			}
			.share_bottom {
				position: fixed;
				bottom: 0;
				width: 100%;
				height: 388rpx;
				background: #F5F7FF;
				border-radius: 40rpx 40rpx 0px 0px;
				.bottom_item {
					width: 33%;
					margin: 50rpx 0 90rpx;
					border: none !important;
					background-color: #F5F7FF !important;
					
					
					.item_icon {
						width: 76rpx;
						height: 76rpx;
					}
					.item_text {
						font-size: 26rpx;
						font-weight: 400;
						color: #333333;
						line-height: 36rpx;
						margin-top: 12rpx;
					}
				}
				button::after {
					border: none !important;
				}
				.share_cancel {
					width: 100%;
					text-align: center;
					font-size: 32rpx;
					font-weight: 400;
					color: #333333;
					line-height: 44rpx;
				}
			}
		}
		.share_content1 {
			z-index: -99 !important;
		}
	}
</style>