<template>
	<view v-if="pageloading">
		<view class="bg-white padding-top padding-lr margin-bottom">
			<view class="flex">
				<view class="flex-sub flex-direction align-center padding-right">
					<view class="text-lg text-cut echo-comjobs-item-title">
					<text class="text-bold">{{info.nickname}}</text>
					<text class="text-gray text-df">（{{info.jobintention_text || '不限'}}）</text>
				</view>
				<view class="text-gray text-df padding-top-sm">
					<text class="padding-right-xs">{{sex[info.gender] || '性别未知'}} ·</text>
					<text class="padding-right-xs">{{info.age ? info.age+'岁' : '年龄未知' }} ·</text>
					<text class="padding-right-xs">{{info.education_text || '学历未知'}}</text>
				</view>
				</view>
				<view class="round" style="width: 110rpx;position: relative;">
					<image class="round" :src="info.avatar" mode="aspectFit" style="width: 110rpx;height: 110rpx;"></image>
					<text class="round cuIcon-male bg-blue text-sm genderIcon" v-if="info.gender == 1"></text>
					<text class="round cuIcon-female bg-pink text-sm genderIcon" v-else-if="info.gender == 2"></text>
				</view>
			</view>
			<view class="text-cut text-sm flex justify-between align-center padding-bottom-sm padding-top-xs">
				<view class="basis-xl text-sm text-cut text-red">
					工作经验：{{info.worker_text}}
				</view>
				<view class="basis-xs text-cut text-right text-sm">
					浏览量:{{info.volume}}
				</view>
			</view>
		</view>
		
		<block v-if="(info.com_cate_type == 1 && info.com_cate.length > 0) || (info.com_cate_type == 2 && info.com_cate_other.length > 0)">
			<view class="cu-bar bg-white">
				<view class="action">
					<text class="cuIcon-titles text-red"></text> 意向工种
				</view>
			</view>
			<view class="echo-article-details bg-white solids-bottom" style="padding-top: 0rpx;" v-if="info.com_cate_type == 1">
				<view class="bg-white padding-top text-gray">
					<view v-for="(item,index) in info.com_cate" :key="index" class="cu-tag light bg-red echo-tags-item">{{item}}</view>
				</view>
			</view>
			<view class="echo-article-details bg-white solids-bottom" style="padding-top: 0rpx;" v-if="info.com_cate_type == 2">
				<view class="bg-white padding-top text-gray">
					<view class="cu-tag light bg-red echo-tags-item">{{info.com_cate_other}}</view>
				</view>
			</view>
		</block>
		
		<view class="cu-bar bg-white" v-if="info.emp_time.length > 0">
			<view class="action">
				<text class="cuIcon-titles text-red"></text> 用工时间
			</view>
		</view>
		<view class="echo-article-details bg-white solids-bottom" style="padding-top: 0rpx;" v-if="info.emp_time.length > 0">
			<view class="bg-white padding-top text-gray">
				<view v-for="(item,index) in info.emp_time" :key="index" class="cu-tag light bg-red echo-tags-item">{{item}}</view>
			</view>
		</view>
		
		<view class="cu-bar bg-white" v-if="info.work_place.length > 0">
			<view class="action">
				<text class="cuIcon-titles text-red"></text> 工作地点
			</view>
		</view>
		<view class="echo-article-details bg-white solids-bottom" style="padding-top: 0rpx;" v-if="info.work_place.length > 0">
			<view class="bg-white padding-top text-gray">
				<view v-for="(item,index) in info.work_place" :key="index" class="cu-tag light bg-red echo-tags-item">{{item}}</view>
			</view>
		</view>
		
		<view class="cu-bar bg-white">
			<view class="action">
				<text class="cuIcon-titles text-red"></text> 个人描述
			</view>
		</view>
		<view class="echo-article-details bg-white solids-bottom" style="padding-top: 0rpx;">
			<text>{{info.eduexperience}}</text>
		</view>
		
		<view class="cu-bar bg-white">
			<view class="action">
				<text class="cuIcon-titles text-red"></text> 服务流程
			</view>
		</view>
		<view class="echo-article-details bg-white solids-bottom" style="padding-top: 0rpx;">
			<image :src="$getImageUrl('static/images/applet/detaillu.png')" mode="widthFix" style="width: 100%;"></image>
		</view>
		
		<view class="padding"></view>
		<view class="padding"></view>
		<view class="cu-bar bg-white tabbar border shop foot" v-if="workerinfo">
			<!-- <button class="text-gray action" @tap="setComjobsStar">
				<view class="padding-bottom-xs">
					<image style="width: 38rpx; height: 38rpx;" :src="$getImageUrl('static/images/applet/detstar.png')"></image>
				</view>
				{{comjobsstar==0 ? '收藏' : '已收藏'}}
			</button> --> 
			<view class="bg-red submit echo-foot-button" @tap="resumeInvite()" v-if="!invite"> <text>发出邀请</text> </view>
			<view class="bg-grey submit echo-foot-button" @tap="contactUser()" v-if="invite && info.is_public == 1"> <text>联系对方</text> </view>
			<view class="bg-grey submit echo-foot-button" v-if="invite && info.is_public == 2"> <text>已邀请</text> </view>
		</view>
		
		<wxContact></wxContact>
	
	</skeleton>
	</view>
</template>

<script>
	var _this;
	export default {
		data() {
			return {
				appplatform: "",
				pageloading: false,
				userinfo: {},
				workerinfo: {},
				info: null,
				invite: null,
				
				comjobsstar: 0,

				modal: {
					name: null,
					comjobspic: ""
				},
				sex: ['未知','男','女'],
			}
		},
		onShareAppMessage: function(res) {
			return {
				title: _this.info.nickname,
				path: "/pages/resume/detail?id=" + _this.info.id + "&parentid=" + _this.userinfo == null ? 0 : _this.userinfo.id
			}
		},
		onLoad: function(option) {
			_this = this;
			
			//#ifdef APP-PLUS
			_this.appplatform = uni.getSystemInfoSync().platform;
			//#endif
			var id = option.id || 0;
			var parentid = option.parentid || 0;
			_this.userinfo = uni.getStorageSync('userinfo') || false;
			_this.workerinfo = uni.getStorageSync('workerinfo') || false;
			uni.setStorageSync('parentid', parentid);
			_this.$req.ajax({
				path: "resume/detail",
				title: "加载中...",
				data: {
					id: id,
					workerid: _this.workerinfo == null ? 0 : _this.workerinfo.id
				}
			}).then((data) => {
				_this.info = data.info;
				_this.invite = data.invite;
				_this.pageloading = true;
			}).catch((err) => {
				uni.showModal({
					title: '信息提示',
					content: err,
					showCancel: false
				});
			});
		},
		methods: {	
			resumeInvite: function() {
				_this.$req.ajax({
					title: "邀请中",
					path: "resume/invite",
					data: {
						userid: _this.info.id,
						workerid: _this.workerinfo.id
					}
				}).then((data) => {
					if (_this.info.is_public == 1) {
						uni.showModal({
							title: '温馨提示',
							content: '恭喜您，邀请成功!!!。',
							confirmText: '联系对方',
							cancelText: "好的",
							success: function(res){
								if (res.confirm) {
									uni.makePhoneCall({
										phoneNumber:_this.info.mobile
									});
								}
							},
						});
					} else {
						uni.showModal({
							title: '温馨提示',
							content: "恭喜您，邀请成功!!!。",
							showCancel: false
						});
					}
					_this.invite = data;
				}).catch((err) => {
					uni.showModal({
						title: '温馨提示',
						content: err,
						showCancel: false
					});
				});
			},
			contactUser: function() {
				uni.makePhoneCall({
				   phoneNumber: _this.info.mobile
				});
			},
		}
	}
</script>

<style lang="scss">
	.flex-1 {
		flex: 1;
	}

	.flex-6 {
		flex: 6;
	}

	.picmodal {
		width: 450rpx;
		background-color: transparent;
	}

	.picmodal image {
		width: 100%;
	}

	.picmodal .bg-img {
		position: relative;
	}

	.picmodalclose {
		position: absolute;
		top: 0rpx;
		right: 0rpx;
	}
	
	.picallitem{ width: 340rpx; height: 260rpx; }
	
	.echo-picalllist{ height: calc(100vh - 105rpx); }
	.echo-picalllist .picitem{ width: 345rpx !important; }
	.echo-picalllist image{ width: 345rpx; padding-bottom: 15rpx; }
	
	.cu-item .bg-img{ width: 100%; height: 390rpx; background-position: center top; }
	
	.myVideo{ width: 750rpx; height: calc(100vh - 130px); }
</style>
