<template>
	<view>
		<form>
			<button class="cu-form-group" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
				<view class="title">头像</view>
				<view class="cu-avatar radius bg-gray">
					<avatar selWidth="640rpx" selHeight="640rpx" :avatarSrc="userinfo.avatar" noTab="true" avatarStyle="top:16rpx;width: 75rpx; height: 75rpx; border-radius: 5%;"></avatar>
				</view>
			</button>
			<!-- <view class="cu-form-group">
				<view class="title">头像</view>
				<view class="cu-avatar radius bg-gray">
					<avatar selWidth="640rpx" selHeight="640rpx" @upload="setAvatar" :avatarSrc="userinfo.avatar" noTab="true" avatarStyle="width: 75rpx; height: 75rpx; border-radius: 5%;"></avatar>
				</view>
			</view> -->
			
			<view class="cu-list menu margin-top">
				<view class="cu-item arrow" data-title="昵称" data-infobox="input" data-field="nickname" :data-value="userinfo.nickname" @click="showModalNickname">
					<view class="content">
						<text>昵称</text>
					</view>
					<view class="action">
						<text class="text-grey">{{userinfo.nickname}}</text>
					</view>
				</view>
				<view class="cu-item">
					<view class="content">
						<text>手机号</text>
					</view>
					<view class="action">
						<text class="text-grey">{{userinfo.mobile}}</text>
					</view>
				</view>
				<view class="cu-item arrow" data-title="公开电话">
					<view class="content">
						<text>公开电话</text>
					</view>
					<view class="action">
						<picker mode="selector" @change="isPublicPickerChange" :value="isPublicIndex" :range="isPublicPickerList" :range-key="`text`">
							<view class="picker padding-tb text-right text-grey" style="width: 280rpx;line-height: 40rpx;">{{isPublicIndex>-1 ? isPublicPickerList[isPublicIndex].text : ("请选择...")}}</view>
						</picker>
					</view>
				</view>
			</view>
			
			<view class="cu-list menu margin-top" v-if="userinfo.authstatus==3">
				<view class="cu-item">
					<view class="content">
						<text>身份证号</text>
					</view>
					<view class="action">
						<text class="text-grey">{{userinfo.idcard}}</text>
					</view>
				</view>
				<view class="cu-item">
					<view class="content">
						<text>姓名</text>
					</view>
					<view class="action">
						<text class="text-grey">{{userinfo.realname}}</text>
					</view>
				</view>
				<view class="cu-item">
					<view class="content">
						<text>性别</text>
					</view>
					<view class="action">
						<text class="text-grey">{{userinfo.gender==1 ? "男" : "女"}}</text>
					</view>
				</view>
				<view class="cu-item">
					<view class="content">
						<text>出生日期</text>
					</view>
					<view class="action">
						<text class="text-grey">{{userinfo.birthday}}</text>
					</view>
				</view>
			</view>
			
			<view class="cu-list menu margin-top">
				<view class="cu-item arrow" data-title="岗位设置方式">
					<view class="content">
						<text>岗位设置方式</text>
					</view>
					<view class="action">
						<picker mode="selector" @change="comCateTypePickerChange" :value="comCateTypeIndex" :range="comCateTypePickerList" :range-key="`text`">
							<view class="picker padding-tb text-right text-grey" style="width: 280rpx;line-height: 40rpx;">{{comCateTypeIndex>-1 ? comCateTypePickerList[comCateTypeIndex].text : ("请选择...")}}</view>
						</picker>
					</view>
				</view>
				<view class="cu-item arrow" @click="toggleComCate(true)" v-if="userinfo.com_cate_type == 1">
					<view class="content">
						<text>岗位类型</text>
					</view>
					<view class="action">
						<view class="picker padding-tb text-right text-grey" style="width: 280rpx;line-height: 40rpx;">{{userinfo.com_cate.length > 0 ? userinfo.com_cate : "请选择..."}}</view>
					</view>
				</view>
				<view class="cu-item arrow" data-title="岗位类型" data-infobox="input" data-field="com_cate_other" :data-value="userinfo.com_cate_other" @click="showModal" v-if="userinfo.com_cate_type == 2">
					<view class="content">
						<text>岗位类型</text>
					</view>
					<view class="action">
						<text class="text-grey text-cut">{{userinfo.com_cate_other}}</text>
					</view>
				</view>
			</view>
			
			<view class="cu-list menu margin-top solid-bottom">
				<view class="cu-item arrow" data-title="求职意向">
					<view class="content">
						<text class="text-red">*</text>
						<text>求职意向</text>
					</view>
					<view class="action">
						<picker mode="selector" @change="jobintentiontypePickerChange" :value="jobintentiontypePickIndex" :range="jobintentiontypePickerList" :range-key="`title`">
							<view class="picker padding-tb text-right text-grey" style="width: 280rpx;line-height: 40rpx;">{{jobintentiontypePickIndex>-1 ? jobintentiontypePickerList[jobintentiontypePickIndex].title : ("请选择...")}}</view>
						</picker>
					</view>
				</view>
				<view class="cu-item arrow" @click="toggleFilter(true)" :style="userinfo.jobintention == 3 ? '' : 'display:none;'">
					<view class="content">
						<text>用工时间</text>
					</view>
					<view class="action">
						<view class="picker padding-tb text-right text-grey" style="width: 280rpx;line-height: 40rpx;">{{userinfo.emp_time.length > 0 ? userinfo.emp_time : "请选择..."}}</view>
					</view>
				</view>
				<view class="cu-item arrow" data-title="现居住地" data-infobox="input" data-field="address" :data-value="userinfo.address" @click="showModal">
					<view class="content">
						<text class="text-red">*</text>
						<text>现居住地</text>
					</view>
					<view class="action">
						<text class="text-grey text-cut">{{userinfo.address}}</text>
					</view>
				</view>
				<view class="cu-item arrow" @click="toggleCommunity(true)">
					<view class="content">
						<text>上班地点</text>
					</view>
					<view class="action">
						<view class="picker padding-tb text-right text-grey" style="width: 280rpx;line-height: 40rpx;">{{userinfo.work_place.length > 0 ? userinfo.work_place : "请选择..."}}</view>
					</view>
				</view>
			</view>
			
			<view class="cu-list menu margin-top solid-bottom">
				<!-- <view class="cu-item arrow" data-title="健康状况">
					<view class="content">
						<text>健康状况</text>
					</view>
					<view class="action">
						<picker mode="selector" @change="healthPickerChange" :value="healthPickIndex" :range="healthPickerList" :range-key="`text`">
							<view class="picker padding-tb text-right text-grey" style="width: 280rpx;line-height: 40rpx;">{{healthPickIndex>-1 ? healthPickerList[healthPickIndex].text : ("请选择...")}}</view>
						</picker>
					</view>
				</view> -->
				<view class="cu-item arrow" data-title="工作经验">
					<view class="content">
						<text class="text-red">*</text>
						<text>工作经验</text>
					</view>
					<view class="action">
						<picker mode="selector" @change="workexperiencePickerChange" :value="workexperiencePickIndex" :range="workexperiencePickerList" :range-key="`text`">
							<view class="picker padding-tb text-right text-grey" style="width: 280rpx;line-height: 40rpx;">{{workexperiencePickIndex>-1 ? workexperiencePickerList[workexperiencePickIndex].text : ("请选择...")}}</view>
						</picker>
					</view>
				</view>
				<view class="cu-item arrow" data-title="学历">
					<view class="content">
						<text class="text-red">*</text>
						<text>学历</text>
					</view>
					<view class="action">
						<picker mode="selector" @change="educationPickerChange" :value="educationPickIndex" :range="educationPickerList" :range-key="`text`">
							<view class="picker padding-tb text-right text-grey" style="width: 280rpx;line-height: 40rpx;">{{educationPickIndex>-1 ? educationPickerList[educationPickIndex].text : ("请选择...")}}</view>
						</picker>
					</view>
				</view>
				<view class="padding-tb padding-lr-xs bg-white solids-top">
					<view class="title padding-bottom-sm text-lg">技能证书</view>
					<view class="grid col-4 grid-square flex-sub">
						<block v-for="(picitem,picindex) in userinfo.skill_cert" :key="picindex">
							<view class="bg-img" @tap="viewImage" :data-url="picitem">
								<image :src="picitem" mode="aspectFill"></image>
								<view class="cu-tag bg-red" @tap.stop="delImg" :data-index="index">
									<text class='cuIcon-close'></text>
								</view>
							</view>
						</block>
						<view class="solids" @tap="chooseImage" v-if="userinfo.skill_cert.length <= 12">
							<text class='cuIcon-cameraadd'></text>
						</view>
					</view>
				</view>
				<view class="cu-item arrow" data-title="个人描述" data-infobox="textarea" data-field="eduexperience" :data-value="userinfo.eduexperience" @click="showModal">
					<view class="content">
						<text>个人描述</text>
					</view>
				</view>
			</view>
			<view class="padding bg-white">
				<text>{{userinfo.eduexperience}}</text>
			</view>	
			<view class="padding text-center">
				<button class="cu-btn bg-orange margin-tb-sm lg" @tap="goCDetail()">已确认完善信息，返回！</button>
			</view>
			<!-- <view class="padding text-center" v-if="userinfo.authstatus == 1">
				<button class="cu-btn bg-orange margin-tb-sm lg" @tap="goLPage('/pages/my/myauth')">您还未进行实名认证，请实名认证！</button>
			</view>
			<view class="padding text-center" v-else="userinfo.authstatus == 2">
				<button class="cu-btn bg-orange margin-tb-sm lg" @tap="goLPage('/pages/my/myauth')">您的实名认证已提交，正在等待审核！</button>
			</view> -->
		</form>
		
			
		<view class="cu-modal" :class="forminfo.isshow">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">修改 {{forminfo.title}}</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-grey"></text>
					</view>
				</view>
				<view class="padding-xl bg-white text-left solid-top solid-bottom">
					<input v-if="forminfo.infobox=='input'" :placeholder="'请输入'+forminfo.title+'...'" @input="bindInput" :value="forminfo.value"></input>
					<textarea v-if="forminfo.infobox=='textarea'" :placeholder="'请输入'+forminfo.title+'...'" @input="bindInput" maxlength="-1" :value="forminfo.value"></textarea>
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="action">
						<button class="cu-btn line-grey text-grey" @tap="hideModal">取消</button>
						<button class="cu-btn bg-green margin-left" @tap="subModal">确定</button>
					</view>
				</view>
			</view>
		</view>
		
		<view class="cu-modal" :class="formavatar">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">修改 昵称</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-grey"></text>
					</view>
				</view>
				<view class="padding-xl bg-white text-left solid-top solid-bottom">
					<input :placeholder="'请输入昵称...'" type="nickname" @input="bindInput" :value="forminfo.value"></input>
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="action">
						<button class="cu-btn line-grey text-grey" @tap="hideModal">取消</button>
						<button class="cu-btn bg-green margin-left" @tap="subModal">确定</button>
					</view>
				</view>
			</view>
		</view>
		
		<view class="filteremp" v-if="empTimeModal">
			<view class="padding bg-white emp-box">
				<block v-for="(item,index) in empTime" :key="index">
					<button class="cu-btn margin-lr-xs margin-tb-xs" v-if="!userinfo.emp_time.includes(item.name)" @click="selectEmpTime(item.name,'add')">
						{{item.name}}
					</button>
					<button class="cu-btn margin-lr-xs margin-tb-xs bg-red" v-else @click="selectEmpTime(item.name,'del')">
						{{item.name}}
					</button>
				</block>
				<view class="padding flex flex-wrap justify-between align-center">
				  <button class="cu-btn bg-red lg" @click="subFilter()">确定</button>
				  <button class="cu-btn bg-gray lg" @click="toggleFilter(false)">取消</button>
				</view>
			</view>
		</view>
		
		<view class="filteremp" v-if="communityModal">
			<view class="padding bg-white emp-box">
				<block v-for="(item,index) in community" :key="index">
					<button class="cu-btn margin-lr-xs margin-tb-xs" v-if="!userinfo.work_place.includes(item.name)" @click="selectCommunity(item.name,'add')">
						{{item.name}}
					</button>
					<button class="cu-btn margin-lr-xs margin-tb-xs bg-red" v-else @click="selectCommunity(item.name,'del')">
						{{item.name}}
					</button>
				</block>
				<view class="padding flex flex-wrap justify-between align-center">
				  <button class="cu-btn bg-red lg" @click="subCommunity()">确定</button>
				  <button class="cu-btn bg-gray lg" @click="toggleCommunity(false)">取消</button>
				</view>
			</view>
		</view>
		
		<view class="filteremp" v-if="comCateModal">
			<view class="padding bg-white emp-box">
				<block v-for="(item,index) in comCate" :key="index">
					<button class="cu-btn margin-lr-xs margin-tb-xs" v-if="!userinfo.com_cate.includes(item.title)" @click="selectComCate(item.title,'add')">
						{{item.title}}
					</button>
					<button class="cu-btn margin-lr-xs margin-tb-xs bg-red" v-else @click="selectComCate(item.title,'del')">
						{{item.title}}
					</button>
				</block>
				<view class="padding flex flex-wrap justify-between align-center">
				  <button class="cu-btn bg-red lg" @click="subComCate()">确定</button>
				  <button class="cu-btn bg-gray lg" @click="toggleComCate(false)">取消</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	var _this;
	import avatar from "@/components/yq-avatar/yq-avatar.vue";
	var sexPickerList = [
		{id: 0, text: '保密'},
		{id: 1, text: '男'},
		{id: 2, text: '女'},
	];
	var educationPickerList = [
		{id: 1, text: '初中及以下'},
		{id: 2, text: '高中'},
		{id: 3, text: '中技'},
		{id: 4, text: '中专'},
		{id: 5, text: '大专'},
		{id: 6, text: '本科'},
		{id: 7, text: '硕士'},
		{id: 8, text: '博士'},
	];
	var workexperiencePickerList = [
		{id: 1, text: '无经验'},
		{id: 2, text: '一年以下'},
		{id: 3, text: '1-3年'},
		{id: 4, text: '3-5年'},
		{id: 5, text: '5-10年'},
		{id: 6, text: '10年以上'}
	];
	var healthPickerList = [
		{id:1, text: '健康或良好'},
		{id:2, text: '一般或较弱'},
		{id:3, text: '有慢性病'},
		{id:4, text: '残疾'}
	];
	var healthPickerList = [
		{id:1, text: '健康或良好'},
		{id:2, text: '一般或较弱'},
		{id:3, text: '有慢性病'},
		{id:4, text: '残疾'}
	];
	var comCateTypePickerList = [
		{id:1, text: '选择项方式'},
		{id:2, text: '手工填写方式'},
	];
	var comCateTypePickerList = [
		{id:1, text: '选择项方式'},
		{id:2, text: '手工填写方式'},
	];
	var isPublicPickerList = [
		{id:1, text: '是'},
		{id:2, text: '否'},
	];
	export default {
		components: {
			avatar
		},
		data() {
			return {
				userinfo: {},
				
				formavatar: false,
				
				forminfo: {
					isshow: "",
					infobox: "input",
					title: "",
					field: "",
					value: ""
				},
				
				jobintentiontypePickIndex: -1,
				jobintentiontypePickerList: [],
				jobintentiontypeValue: {
					id: false,
					title: false
				},
				workexperiencePickIndex: -1,
				workexperiencePickerList: [],
				workexperienceValue: {
					id: false,
					text: false
				},
				educationPickIndex: -1,
				educationPickerList: [],
				educationValue: {
					id: false,
					text: false
				},
				healthPickIndex: -1,
				healthPickerList: [],
				healthValue: {
					id: false,
					text: false
				},
				comCateTypeIndex: -1,
				comCateTypePickerList: [],
				comCateTypeValue: {
					id: false,
					text: false,
				},
				isPublicIndex: -1,
				isPublicPickerList: [],
				isPublicValue: {
					id: false,
					text: false,
				},
				empTimeOrigin: [],
				empTime: [],
				empTimeModal: false,
				communityOrigin: [],
				community: [],
				communityModal: false,
				comCateOrigin: [],
				comCate: [],
				comCateModal: false,
			}
		},
		onLoad: function(option) {
			_this = this;
			_this.userinfo = _this.checkLogin("/pages/my/myinfo");
			_this.getJobintentiontype();
			_this.getEmpTime();
			_this.getCommunity();
			_this.getComCate();
			_this.healthPickerList = healthPickerList;
			if(_this.userinfo.health >= 1) {
				_this.healthPickIndex = _this.userinfo.health - 1;
				_this.healthValue.text = _this.healthPickerList[_this.healthPickIndex].text;
				_this.healthValue.id = _this.healthPickerList[_this.healthPickIndex].id;
			}
			_this.educationPickerList = educationPickerList;
			if(_this.userinfo.education >= 1) {
				_this.educationPickIndex = _this.userinfo.education - 1;
				_this.educationValue.text = _this.educationPickerList[_this.educationPickIndex].text;
				_this.educationValue.id = _this.educationPickerList[_this.educationPickIndex].id;
			}
			_this.workexperiencePickerList = workexperiencePickerList;
			if(_this.userinfo.workexperience >= 1) {
				_this.workexperiencePickIndex = _this.userinfo.workexperience - 1;
				_this.workexperienceValue.text = _this.workexperiencePickerList[_this.workexperiencePickIndex].text;
				_this.workexperienceValue.id = _this.workexperiencePickerList[_this.workexperiencePickIndex].id;
			}
			_this.comCateTypePickerList = comCateTypePickerList;
			if(_this.userinfo.com_cate_type >= 1) {
				_this.comCateTypeIndex = _this.userinfo.com_cate_type - 1;
				_this.comCateTypeValue.text = _this.comCateTypePickerList[_this.comCateTypeIndex].text;
				_this.comCateTypeValue.id = _this.comCateTypePickerList[_this.comCateTypeIndex].id;
			}
			_this.isPublicPickerList = isPublicPickerList;
			if(_this.userinfo.is_public >= 1) {
				_this.isPublicIndex = _this.userinfo.is_public - 1;
				_this.isPublicValue.text = _this.isPublicPickerList[_this.isPublicIndex].text;
				_this.isPublicValue.id = _this.isPublicPickerList[_this.isPublicIndex].id;
			}
			
			//数组删除值
			Array.prototype.remove = function(val) {
				var index = this.indexOf(val);
				if (index > -1) {
					this.splice(index, 1);
				}
			};
		},
		methods: {
			onChooseAvatar: function(e) {
				_this.$req.ajaxFile({
					path: "attachment/tplfieldimage",
					title:'正在上传',
					filePath: e.detail.avatarUrl,
					fileName:'file',
				}).then((filedata) => {
					var data = JSON.parse(filedata.data);
					if (data.code == 1) {
						uni.showModal({
							title: '信息提示',
							content: data.msg,
							showCancel: false
						});
					}
					return false;
					_this.editFiled('avatar', data.data.src);
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},
			// 获取求职意向
			getJobintentiontype: function() {
				_this.$req.ajax({
					path: "my/jobintention_lst",
					data: {}
				}).then((data) => {
					_this.jobintentiontypePickerList = data.plist;
					if(_this.userinfo.jobintention > 0) {
						_this.jobintentiontypePickerList.forEach((item,index) => {
							if(item.id == _this.userinfo.jobintention) {
								_this.jobintentiontypePickIndex = index;
								_this.jobintentiontypeValue.title = _this.jobintentiontypePickerList[_this.jobintentiontypePickIndex].title;
								_this.jobintentiontypeValue.id = _this.jobintentiontypePickerList[_this.jobintentiontypePickIndex].id;
							}
						});
					}
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},
			// 获取用工时间
			getEmpTime: function() {
				_this.$req.ajax({
					path: "index/getRensheCode",
					data: {type:"emp_time"}
				}).then((data) => {
					
					_this.empTime = data;
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},
			// 获取镇街
			getCommunity: function() {
				_this.$req.ajax({
					path: "index/getRensheCode",
					data: {type:"community"}
				}).then((data) => {
					data.push({code:0,id:0,name:"不限"});
					_this.community = data;
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},
			// 获取岗位类型
			getComCate: function() {
				_this.$req.ajax({
					path: "index/getComCate",
					data: {}
				}).then((data) => {
					_this.comCate = data;
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},
			// 求职意向岗位修改
			jobintentiontypePickerChange: function(e) {
				_this.jobintentiontypePickIndex = e.detail.value;
				_this.jobintentiontypeValue.title = _this.jobintentiontypePickerList[_this.jobintentiontypePickIndex].title;
				_this.jobintentiontypeValue.id = _this.jobintentiontypePickerList[_this.jobintentiontypePickIndex].id;
				_this.editFiled( "jobintention", _this.jobintentiontypeValue.id );
			},
			// 工作经验修改
			workexperiencePickerChange: function(e) {
				_this.workexperiencePickIndex = e.detail.value;
				_this.workexperienceValue.text = _this.workexperiencePickerList[_this.workexperiencePickIndex].text;
				_this.workexperienceValue.id = _this.workexperiencePickerList[_this.workexperiencePickIndex].id;
				_this.editFiled( "workexperience", _this.workexperienceValue.id );
			},
			// 学历修改
			educationPickerChange: function(e) {
				_this.educationPickIndex = e.detail.value;
				_this.educationValue.text = _this.educationPickerList[_this.educationPickIndex].text;
				_this.educationValue.id = _this.educationPickerList[_this.educationPickIndex].id;
				_this.editFiled( "education", _this.educationValue.id );
			},
			// 健康状况修改
			healthPickerChange: function(e) {
				_this.healthPickIndex = e.detail.value;
				_this.healthValue.text = _this.healthPickerList[_this.healthPickIndex].text;
				_this.healthValue.id = _this.healthPickerList[_this.healthPickIndex].id;
				_this.editFiled( "health", _this.healthValue.id );
			},
			// 岗位类型设置
			comCateTypePickerChange: function(e) {
				_this.comCateTypeIndex = e.detail.value;
				_this.comCateTypeValue.text = _this.comCateTypePickerList[_this.comCateTypeIndex].text;
				_this.comCateTypeValue.id = _this.comCateTypePickerList[_this.comCateTypeIndex].id;
				_this.editFiled( "com_cate_type", _this.comCateTypeValue.id );
			},
			//公开电话
			isPublicPickerChange: function(e) {
				_this.isPublicIndex = e.detail.value;
				_this.isPublicValue.text = _this.isPublicPickerList[_this.isPublicIndex].text;
				_this.isPublicValue.id = _this.isPublicPickerList[_this.isPublicIndex].id;
				_this.editFiled( "is_public", _this.isPublicValue.id );
			},
			// 填写字段
			hideModal: function() {
				_this.forminfo = {
					isshow: "",
					title: "",
					field: "",
					value: ""
				};
				_this.formavatar = "";
			},
			showModal: function(e) {
				_this.forminfo.title = e.currentTarget.dataset.title;
				_this.forminfo.infobox = e.currentTarget.dataset.infobox;
				_this.forminfo.field = e.currentTarget.dataset.field;
				_this.forminfo.value = e.currentTarget.dataset.value;
				_this.forminfo.isshow = "show";
			},
			showModalNickname: function(e) {
				_this.forminfo.title = e.currentTarget.dataset.title;
				_this.forminfo.infobox = e.currentTarget.dataset.infobox;
				_this.forminfo.field = e.currentTarget.dataset.field;
				_this.forminfo.value = e.currentTarget.dataset.value;
				_this.formavatar = 'show';
			},
			bindInput: function(e) {
				_this.forminfo.value = e.detail.value;
			},
			subModal: function() {
				_this.editFiled( _this.forminfo.field, _this.forminfo.value );
			},
			
			// 修改头像
			setAvatar: function(rsp) {
				_this.$req.ajaxFile({
					path: "attachment/tplfieldimage",
					title:'正在上传',
					filePath: rsp.path,
					fileName:'file',
				}).then((filedata) => {
					var data = JSON.parse(filedata.data);
					_this.editFiled('avatar', data.data.src);
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},
			//返回招聘详情
			goCDetail: function() {				
				_this.checkLogin("/pages/my/my");
				if (_this.userinfo===false){
					return false;
				}
				if(_this.userinfo.address==""){
					uni.showToast({
						title: '请完善您的现居住地',
						icon:'none',
						duration: 2000
					});
					return false;
				}
				if(_this.userinfo.jobintention==""){
					uni.showToast({
						title: '请选择您的求职意向',
						icon:'none',
						duration: 2000
					});
					return false;
				}
				if(_this.userinfo.workexperience==""){
					uni.showToast({
						title: '请选择您的工作经验',
						icon:'none',
						duration: 2000
					});
					return false;
				}
				if(_this.userinfo.education==""){
					uni.showToast({
						title: '请选择您的学历',
						icon:'none',
						duration: 2000
					});
					return false;
				}
				_this.$req.ajax({
					path: "my/perfectUserInfo",
					data: {
						userid: _this.userinfo.id,
						skill_cert: _this.userinfo.skill_cert ? _this.userinfo.skill_cert.join(",") : _this.userinfo.skill_cert,
					}
				})
				uni.showToast({
					title: '修改成功',
					icon:'none',
					duration: 2000
				});
				setTimeout(function () {
					uni.navigateBack();
				}, 1500);
			},
			//跳转 
			goLPage: function(pageurl) {
				_this.userinfo = _this.checkLogin("/pages/my/my");
				if (_this.userinfo===false){
					return false;
				}
				uni.navigateTo({
					url: pageurl,
					fail: function(){
						uni.switchTab({
						    url: pageurl
						});
					}
				});
			},
			// 更新用户字段
			editFiled: function (field, value) {
				_this.$req.ajax({
					path: "my/edituserinfo",
					data: {
						userid: _this.userinfo.id,
						field: field,
						value: value
					}
				}).then((data) => {
					_this.userinfo = data;
					uni.setStorageSync('userinfo', data);
					_this.hideModal();
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},
			selectEmpTime: function (name, option) {
				if (option == 'add') {
					_this.userinfo.emp_time.push(name);
				} else if (option == 'del') {
					_this.userinfo.emp_time.remove(name);
				}
			},
			selectCommunity: function (name, option) {
				if (option == 'add') {
					_this.userinfo.work_place.push(name);
				} else if (option == 'del') {
					_this.userinfo.work_place.remove(name);
				}
			},
			toggleFilter: function (value) {
				if (value) {
					_this.empTimeOrigin = [..._this.userinfo.emp_time];
				} else {
					_this.userinfo.emp_time = [..._this.empTimeOrigin];
				}
				_this.empTimeModal = value;
			},
			selectComCate: function (name, option) {
				if (option == 'add') {
					_this.userinfo.com_cate.push(name);
				} else if (option == 'del') {
					_this.userinfo.com_cate.remove(name);
				}
			},
			toggleComCate: function (value) {
				if (value) {
					_this.comCateOrigin = [..._this.userinfo.com_cate];
				} else {
					_this.userinfo.com_cate = [..._this.comCateOrigin];
				}
				_this.comCateModal = value;
			},
			toggleCommunity: function (value) {
				if (value) {
					_this.communityOrigin = [..._this.userinfo.work_place];
				} else {
					_this.userinfo.work_place = [..._this.communityOrigin];
				}
				_this.communityModal = value;
			},
			subFilter: function () {
				_this.editFiled( 'emp_time',_this.userinfo.emp_time );
				_this.empTimeModal = false;
			},
			subCommunity: function () {
				_this.editFiled( 'work_place',_this.userinfo.work_place );
				_this.communityModal = false;
			},
			subComCate: function () {
				_this.editFiled( 'com_cate',_this.userinfo.com_cate );
				_this.comCateModal = false;
			},
			// 图片上传
			chooseImage: function(e) {
				uni.chooseImage({
					count: 12,
					sizeType: ['original', 'compressed'],
					sourceType: ['album'],
					success: (res) => {
						_this.$req.ajaxFile({
							path: "attachment/tplfieldimage",
							title: '正在上传',
							filePath: res.tempFilePaths[0],
							fileName: 'file',
						}).then((filedata) => {
							var data = JSON.parse(filedata.data);
							_this.userinfo.skill_cert.push(data.data.src);
						}).catch((err) => {
							uni.showModal({
								title: '信息提示',
								content: err,
								showCancel: false
							});
						});
					}
				});
			},
			viewImage: function(e) {
				uni.previewImage({
					urls: _this.userinfo.skill_cert,
					current: e.currentTarget.dataset.url
				});
			},
			delImg: function(e) {
				_this.userinfo.skill_cert.splice(e.currentTarget.dataset.index, 1);
			},
		}
	}
</script>

<style>
	.filteremp{ width: 750rpx; position: fixed;top: 0; z-index: 999; height: 100vh; background-color:#000;background: rgba(0, 0, 0, 0.5); }
	.filteremp .emp-box{ width: 750rpx; position: absolute;bottom: 0;}
</style>
