<template>
	<div class="addResume" style="padding-bottom: 20px;">
		<div class="info flex align-center justify-center">
			<div class="info-box">
				<div class="info-boxs flex justify-between">
					<div class="info-box-l">
						<div class="info-box-l-box">
							<div class="info-box-l-title">
								企业中心
								<div class="info-box-l-line"></div>
							</div>
							<div class="info-box-l-info-hover">
								<div class="info-box-l-info-hovers" v-if="userInfoEdit == false">
									<div class="info-box-l-info flex align-center justify-between">
										<div class="info-box-l-info-l flex align-center">
											<div class="info-box-l-info-avatar">
												<img :src="companyInfos.companyLogo ? companyInfos.companyLogo :'/default.jpg'"
													style="width: 100%;height: 100%;" class="avatar" />
											</div>
											<div class="info-box-l-info-info">
												<div class="info-box-l-info-info-t flex align-center">
													<div>
														{{ companyInfos.companyName || companyInfos.companyAllName }}
													</div>
													<div v-if="isUserVip==false">
														升级VIP
													</div>
													<div v-else style="background-color: #00DD9A;color: #ffffff;">
														会员用户
													</div>

												</div>
												<div style="font-size: 16px;color: #666666;margin-top: 20px;">
													{{ companyInfos.companyPeople}}<el-divider
														direction="vertical" />{{companyInfos.companyDevelop }}
												</div>
											</div>
										</div>
										<div @click="userInfoEdit = true" class="info-box-l-seid flex align-center">
											<el-icon class="info-box-l-seid-icon" style="cursor: pointer;"
												color="#00DD9A" size="20">
												<Edit />
											</el-icon>
											编辑
										</div>
									</div>
								</div>
								<div v-else class="info-box-l-edit">
									<view class="info-box-l-edit-title">
										编辑企业信息
									</view>
									<el-form ref="formResume" v-loading="loading" size="large" style="margin-top: 20px;"
										class="flex align-center justify-between" label-position="top" :inline="true"
										:model="companyInfo" label-width="120px">
										<el-form-item prop="companyName"
											:rules="[{required: true,message: '请输入企业名称',trigger: 'blur',},]"
											class="row45" label="企业名称">
											<el-input placeholder="请输入企业名称" class="inputClass"
												v-model="companyInfo.companyName" disabled />
										</el-form-item>

										<el-form-item prop="companyPeople"
											:rules="[{required: true,message: '请选择公司规模',trigger: 'blur',},]"
											class="row45" label="公司规模">
											<el-select v-model="companyInfo.companyPeople" style="width: 100%;" disabled
												class="inputClass" placeholder="请选择公司规模" size="large">
												<el-option v-for="item in comList" :key="item.value" :label="item.value"
													:value="item.value" />
											</el-select>
										</el-form-item>

										<el-form-item prop="workTime"
											:rules="[{ required: true, message: '请选择公司标准工作时间', trigger: 'blur', },]"
											class="row45" label="公司标准工作时间">
											<el-time-picker v-model="companyInfo.workTime" is-range range-separator="至"
												start-placeholder="上班时间" end-placeholder="下班时间" format="HH:mm"
												value-format="HH:mm" placeholder="请选择时间范围" />
										</el-form-item>

										<el-form-item prop="welfare" label="公司福利"
											:rules="[{ required: true, message: '请选择公司福利', trigger: 'change' }]"
											class="row45">
											<el-select v-model="companyInfo.welfare" multiple placeholder="请选择公司福利">
												<el-option-group v-for="group in welfareOptions" :key="group.label"
													:label="group.label">
													<el-option v-for="item in group.options" :key="item.value"
														:label="item.label" :value="item.value" />
												</el-option-group>
											</el-select>
										</el-form-item>

										<el-form-item prop="companyPeopleDevelop" label="人才发展"
											:rules="[{ required: true, message: '请选择人才发展', trigger: 'change' }]"
											class="row45">
											<el-select v-model="companyInfo.companyPeopleDevelop" multiple
												placeholder="请选择人才发展">
												<el-option-group v-for="group in companyPeopleDevelopList"
													:key="group.label" :label="group.label">
													<el-option v-for="item in group.options" :key="item.value"
														:label="item.label" :value="item.value" />
												</el-option-group>
											</el-select>
										</el-form-item>

										<el-form-item prop="workRestTime" class="row45" label="休息时间（可选）">
											<el-select v-model="companyInfo.workRestTime" style="width: 100%;"
												class="inputClass" placeholder="请选择休息时间" size="large">
												<el-option label="单休" value="单休" />
												<el-option label="双休" value="双休" />
											</el-select>
										</el-form-item>

										<el-form-item prop="workOverTime" class="row45" label="加班情况（可选）">
											<el-select v-model="companyInfo.workOverTime" style="width: 100%;"
												class="inputClass" placeholder="请选择加班情况" size="large">
												<el-option label="不加班" value="不加班" />
												<el-option label="偶尔加班" value="偶尔加班" />
												<el-option label="弹性工作" value="弹性工作" />
											</el-select>
										</el-form-item>

										<el-form-item prop="companyDevelop" 
											label="发展阶段" 
											:rules="[{ required: true, message: '请选择发展阶段', trigger: 'change', },]" 
											class="row45">
											<el-select v-model="companyInfo.companyDevelop" style="width: 100%;"
												class="inputClass" placeholder="请选择发展阶段" size="large">
												<el-option :label="item" :value="item" v-for="item in companyDevelopList" :key="item"></el-option>
											</el-select>
										</el-form-item>

										<el-form-item prop="companyContent"
											:rules="[{required: true,message: '请输入公司介绍',trigger: 'blur',},]"
											class="row45" label="公司介绍">
											<el-input v-model="companyInfo.companyContent" :rows="4" type="textarea"
												placeholder="请输入公司介绍" />
										</el-form-item>

										<el-form-item label="主营业务介绍" prop="companyScope" class="row45"
											:rules="[{ required: true, message: '请至少添加一个主营业务标签', trigger: 'blur' }]">
											<el-tag size="large" style="margin-right: 10px;margin-bottom: 10px;"
												v-for="(item, index) in companyInfo.companyScope" :key="item" closable
												@close="handleClose(index)">
												{{ item }}
											</el-tag>
											<el-input v-if="inputVisible" ref="InputRef" v-model="inputValue"
												style="width: fit-content;margin-bottom: 10px;" class="w-20" size="default"
												@keyup.enter="handleInputConfirm" @blur="handleInputConfirm" />
											<el-button v-else class="button-new-tag ml-1" size="default" style="margin-bottom: 10px;"
												@click="inputVisible = true">
												+ 添加标签
											</el-button>
										</el-form-item>

										<el-form-item prop="companyCertification"
											:rules="[{required: true,message: '请上传营业执照照片',trigger: 'blur',},]"
											class="row45" label="营业执照">
											<el-upload class="avatar-uploader flex align-center justify-center"
												:action="action" :show-file-list="false"
												:on-success="handleAvatarSuccessC">
												<img style="width: 100px;height: 100px;border-radius: 6px;"
													v-if="companyInfo.companyCertification"
													:src="companyInfo.companyCertification" />
												<el-icon v-else class="avatar-uploader-icon">
													<Plus />
												</el-icon>
											</el-upload>
										</el-form-item>

										<el-form-item prop="companyLogo"
											:rules="[{required: true,message: '请上传公司头像',trigger: 'blur',},]"
											class="row45" label="公司头像">
											<el-upload class="avatar-uploader flex align-center justify-center"
												:action="action" :show-file-list="false"
												:on-success="handleAvatarSuccessL">
												<img v-if="companyInfo.companyLogo" :src="companyInfo.companyLogo"
													style="width: 100px;height: 100px;border-radius: 6px;" />
												<el-icon v-else class="avatar-uploader-icon">
													<Plus />
												</el-icon>
											</el-upload>
										</el-form-item>

										<el-form-item prop="photos" label="公司展示照片" class="width100" style="display: initial;"
											:rules="[{ required: true, message: '请上传公司展示照片', trigger: 'change' }]">
											<el-upload class="upload-demo" :action="action" list-type="picture-card"
												:file-list="companyInfo.photos" :limit="20"
												:on-success="handlePhotosSuccess" :on-preview="handlePreview"
												:on-remove="handleRemove">
												<el-icon v-if="companyInfo.photos.length < 20"
													class="avatar-uploader-icon">
													<Plus />
												</el-icon>
											</el-upload>
											<!-- 预览弹窗 -->
											<el-dialog v-model="dialogVisible" width="50%">
												<img :src="dialogImageUrl" alt="Preview" style="width: 100%" />
											</el-dialog>
										</el-form-item>
										
										<el-form-item class="row45"></el-form-item>
										<el-form-item>
											<div class="info-box-l-edit-btn flex align-center justify-end">
												<el-button @click="userInfoEdit = false" style="width: 100px;"
													type="Info">取消</el-button>
												<el-button @click="saveCompany()"
													style="width: 100px;margin-left: 30px;"
													type="primary">保存</el-button>
											</div>
										</el-form-item>
									</el-form>
								</div>

							</div>

						</div>
						<div class="info-box-l-lines"></div>
						<!-- 求职岗位 -->
						<div class="info-box-l-gw">
							<div class="info-box-l-gw-title" @click="goMyPostPush('')">
								我的招聘
							</div>
							<div class="info-box-l-gw-items flex align-center">
								<div @click="goMyPostPush(1)" class="info-box-l-gw-item">
									<img src="/images/postimg/dsh.png" alt="" srcset="" />
									<div>待审核</div>
								</div>
								<div @click="goMyPostPush(2)" class="info-box-l-gw-item">
									<img src="/images/postimg/zpz.png" alt="" srcset="" />
									<div>招聘中</div>
								</div>
								<div @click="goMyPostPush(5)" class="info-box-l-gw-item">
									<img src="/images/postimg/ygb.png" alt="" srcset="" />
									<div>已关闭</div>
								</div>
								<div @click="goMyPostPush(3)" class="info-box-l-gw-item">
									<img src="/images/postimg/yjj.png" alt="" srcset="" />
									<div>已拒绝</div>
								</div>
							</div>


						</div>
					</div>
					<div class="info-box-r flex justify-center flex-wrap">
						<div class="info-box-r-b " style="height: 376px;">
							<div class="info-box-r-t-title">
								常用功能
							</div>
							<div style="margin-top: 20px;" class="flex align-center">
								<!-- <div @click="openShar()" class="info-box-r-b-item">
									<div class="info-box-r-b-item-t flex align-center justify-center">
										<img src="/images/resume/yq.png" alt="" srcset="">
									</div>
									<div class="info-box-r-b-item-b">
										邀请好友
									</div>
								</div>
								<div @click="refreshJob()" class="info-box-r-b-item">
									<div class="info-box-r-b-item-t flex align-center justify-center">
										<img src="/images/resume/sx.png" alt="" srcset="">
									</div>
									<div class="info-box-r-b-item-b">
										招聘刷新
									</div>
								</div> -->
								<div class="info-box-r-b-item" @click="goMyCollect('myCollect')">
									<div class="info-box-r-b-item-t flex align-center justify-center">
										<img src="/images/resume/myLove.png" alt="" srcset="">
									</div>
									<div class="info-box-r-b-item-b">
										简历收藏
									</div>
								</div>
								<!-- <div class="info-box-r-b-item" @click="goJilu('resume')">
									<div class="info-box-r-b-item-t flex align-center justify-center">
										<img src="/images/resume/ms.png" alt="" srcset="">
									</div>
									<div class="info-box-r-b-item-b">
										已投简历
									</div>
								</div> -->
								<div class="info-box-r-b-item" @click="goMyRecord()">
									<div class="info-box-r-b-item-t flex align-center justify-center">
										<img src="/images/resume/msjl.png" alt="" srcset="">
									</div>
									<div class="info-box-r-b-item-b">
										面试记录
									</div>
								</div>
								<div class="info-box-r-b-item" @click="goJilu('browse')">
									<div class="info-box-r-b-item-t flex align-center justify-center">
										<img src="/images/resume/lljl.png" alt="" srcset="">
									</div>
									<div class="info-box-r-b-item-b">
										沟通记录
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- 招聘岗位 -->
				<div class="postPushList">
					<div class="postPushList-title">
						招聘岗位
					</div>
					<div v-if="postPushList.length>0" class="postPushList-con flex justify-between flex-wrap">
						<div class="postPushList-con-item" @click="goMyPostPush('')"
							v-for="(item,index) in postPushList" :key="index">
							<div class="postPushList-con-item-top">
								{{ item.ruleClassifyName }}
								<span style="color: #00DD9A;margin-left: 20px;">
									{{item.salaryRange}}
								</span>
							</div>
							<div class="postPushList-con-item-con" style="white-space: pre-wrap;">
								<div v-if="isHtml(item.positionDetails)" v-html="formatHtml(item.positionDetails)"></div>
								<template v-else>{{ item.positionDetails }}</template>
							</div>
							<div class="postPushList-con-item-tag flex algin-center flex-wrap">
								<div class="postPushList-con-item-tag-i">
									{{ item.city }}-{{ item.county }}
								</div>
								<div class="postPushList-con-item-tag-i">
									{{item.education}}
								</div>
								<div class="postPushList-con-item-tag-i">
									{{item.experience}}
								</div>
								<div class="postPushList-con-item-tag-i">
									{{ item.salaryTimes }}
								</div>
							</div>
						</div>
						<div class="postPushList-con-item" style="height: 0;">

						</div>
					</div>
					<div v-else class="" style="width: 100%;">
						<el-empty description="暂无岗位" />
					</div>
				</div>
			</div>
		</div>
		<!-- 分享好友 -->
		<el-dialog class="share" v-model="dialogShare" destroy-on-close width="35%">
			<el-image style="width: 100%; height: 650px;border-radius: 12px;" :src="backgroundImage" fit="fill" />
			<el-icon @click="dialogShare = false" style="position: absolute;right: 10px;top: 10px;cursor: pointer;"
				size="25" color="#ffffff">
				<Close />
			</el-icon>
			<div class="share-content flex align-center justify-center">
				<div class="share-content-box">
					<div class="share-content-box-top flex flex-wrap align-center">
						<div style="width: 100%;" class="flex flex-wrap justify-between align-center">
							<div class="flex align-center">
								<img :src="avatar" alt="" srcset="" />
								<div class="share-content-box-topi">
									<div class="share-content-box-topi1">
										{{nickName}}
									</div>
									<div class="share-content-box-topi2">
										邀请码：{{invitationCode}}
									</div>
								</div>
							</div>
							<div class="">
								<div class="yaoqingpeop">
									已邀请<span>{{peopleNum}}</span>人
								</div>
								<div @click="goMyTeam()" class="mytuandui flex align-center justify-between">
									<div class="flex align-center">
										我的团队
										<el-icon>
											<ArrowRight />
										</el-icon>
									</div>

								</div>
							</div>
						</div>

						<div class="share-content-box-topi-btn flex algin-center justify-center">
							<div @click="tuiguang()"
								class="share-content-box-topi-btn-l flex align-center justify-center">
								<span>文案推广</span>
							</div>
							<div @click="shareImg()"
								class="share-content-box-topi-btn-r flex align-center justify-center">
								<span>生成海报</span>
							</div>
						</div>
					</div>
				</div>
			</div>
			<canvas ref="poster" class="poster_canvas" width="375" height="673"></canvas>
		</el-dialog>
	</div>
</template>

<script>
	import citys from './citys.json'
	import axios from 'axios';
	import jsonp from 'axios-jsonp'
	import {ElMessageBox,ElMessage,} from 'element-plus'
	import {ROOTPATH,ROOTPATH4} from '../../../comment/httpUrl.js'
	export default {
		data() {
			return {
				companyInfos: {},
				companyInfo: {
					companyName: '', //企业名称
					companyLegalPerson: '', //公司规模
					// companyAddress1: '', //省市区
					// companyAddress: '', //营业地址
					companyScope: [], //主营业务
					// companyPeople: '', //公司法人
					// companyRegisteredFund: '', //注册资金
					// companyCreateTime: '', //注册时间
					// companyContent: [], //招聘信息
					companyContent: '', //简介
					companyLogo: '',//公司logo
					companyCertification: '', //营业执照
					// email: '', //企业邮箱
					// companyLng: '',
					// companyLat: '',
					workTime: '', //公司标准工作时间
					workRestTime: '', //休息时间
					workOverTime: '', //加班情况
					companyDevelop: '', //发展阶段
					welfare: '', //福利
					companyPeopleDevelop:'', //人才发展
					photos: [], //公司展示照片
				}, //企业信息
				companyDevelopList: [
					"未融资",
					"天使轮",
					"A轮",
					"B轮",
					"C轮",
					"D轮及以上",
					"已上市",
					"不需要融资",
				],
				welfareOptions: [
					{
						label: '保险',
						options: [
							{ value: '五险一金', label: '五险一金' },
							{ value: '补充医疗保险', label: '补充医疗保险' },
							{ value: '意外险', label: '意外险' },
							{ value: '定期体检', label: '定期体检' }
						]
					},
					{
						label: '薪资期权',
						options: [
							{ value: '年终奖', label: '年终奖' },
							{ value: '绩效奖金', label: '绩效奖金' },
							{ value: '保底工资', label: '保底工资' },
							{ value: '底薪加提成', label: '底薪加提成' },
							{ value: '股票期权', label: '股票期权' },
							{ value: '企业年金', label: '企业年金' }
						]
					},
					{
						label: '补贴',
						options: [
							{ value: '餐补', label: '餐补' },
							{ value: '交通补贴', label: '交通补贴' },
							{ value: '住房补贴', label: '住房补贴' },
							{ value: '加班补贴', label: '加班补贴' },
							{ value: '团建补贴', label: '团建补贴' }
						]
					},
					{
						label: '休假',
						options: [
							{ value: '带薪年假', label: '带薪年假' },
							{ value: '节假日加班费', label: '节假日加班费' },
							{ value: '法定节假日三薪', label: '法定节假日三薪' },
							{ value: '员工购房', label: '员工购房' }
						]
					}
				],
				companyPeopleDevelopList: [
					{
						label: '晋升制度',
						options: [
							{ value: '考核晋升', label: '考核晋升' },
							{ value: '定期晋升', label: '定期晋升' },
							{ value: '完善的晋升机制', label: '完善的晋升机制' }
						]
					},
					{
						label: '人才激励',
						options: [
							{ value: '定期普调', label: '定期普调' },
							{ value: '定期绩效调薪', label: '定期绩效调薪' },
							{ value: '晋级涨薪', label: '晋级涨薪' },
							{ value: '项目奖金', label: '项目奖金' },
							{ value: '团队奖金', label: '团队奖金' },
							{ value: '个人奖金', label: '个人奖金' },
							{ value: '绩效提成', label: '绩效提成' },
							{ value: '股票期权', label: '股票期权' },
							{ value: '人才补贴', label: '人才补贴' }
						]
					},
					{
						label: '能力培养',
						options: [
							{ value: '老员工带新', label: '老员工带新' },
							{ value: '导师一对一', label: '导师一对一' },
							{ value: '岗前带薪培训', label: '岗前带薪培训' },
							{ value: '内部定期培训', label: '内部定期培训' },
							{ value: '专业技能培训', label: '专业技能培训' },
							{ value: '内部课程资源', label: '内部课程资源' },
							{ value: '大牛带队', label: '大牛带队' },
							{ value: '人脉积累', label: '人脉积累' },
							{ value: '国内外进修', label: '国内外进修' },
							{ value: '校招培养', label: '校招培养' }
						]
					}
				],
				inputVisible: false,
				inputValue:'',
				action: ROOTPATH + '/alioss/upload', //上传图片地址
				// industryDialog: false, //是否打开行业选择
				loading: false, //设置加载中
				userInfoEdit: false,
				// industryArr: [], //选择的行业数组
				// industryArrList: [], //可选择的行业列表
				// industryList: [], //行业列表
				backgroundImage: '', //邀请背景图
				peopleNum: 0, //邀请的人数
				numPeople: 0, //邀请人数要求
				tuiguangTxt: '', //推广文字
				url: '', //邀请链接
				token: '',
				comList: [],
				citysList: citys,
				postPushList: [], //岗位列表
				dialogShare: false,
				dialogImageUrl: '', // 预览图片URL
				dialogVisible: false, // 预览图片是否可见
			}

		},
		computed: {
			invitationCode() {
				return this.$store.state.invitationCode;
			},
			isUserVip() {
				return this.$store.state.isUserVip;
			},
			avatar() {
				return this.$store.state.avatar;
			},
			nickName() {
				return this.$store.state.nickName;
			},
		},
		mounted() {
			this.screenHeight = window.innerHeight
			this.token = localStorage.getItem('token')
			this.getCompanyInfo()
			this.getComList()
			this.getlist()
		},
		watch: {
			//监听行业选择变化
			industryArr: {
				handler(newItems) {
					this.industryArr.map(item => {
						this.industryList.map(ite => {
							ite.childrenList.map(it => {
								if (item == it.industryName) {
									it.select = true
								}
							})
						})
					})
				},
				deep: true, // 使用deep属性来监听数组中元素的变化  
			}
		},
		methods: {
			formatHtml(html) {
				return html.replace(/<p>/g, '<p style="margin:0;padding:0;">')
			},
			isHtml(str) {
				return /<\/?[a-z][\s\S]*>/i.test(str)
			},
			//删除主营业务介绍标签
			handleClose(index) {
				this.companyInfo.companyScope.splice(index, 1)
			},
			//确认
			handleInputConfirm() {
				if (this.inputValue) {
					this.companyInfo.companyScope.push(this.inputValue)
					this.inputVisible = false
					this.inputValue = ''
				} else {
					this.inputVisible = false
				}
			},
			// 上传成功
			handlePhotosSuccess(response, file, fileList) {
				// 这里 fileList 是 element-ui 内部生成的文件对象数组
				// 如果接口返回 url，在这里更新 companyInfo.photos
				this.companyInfo.photos = fileList.map(item => {
					return {
						name: item.name,
						url: item.response ? item.response.data : item.url
					}
				})
			},

			// 删除图片
			handleRemove(file, fileList) {
				this.companyInfo.photos = fileList.map(item => ({
					name: item.name,
					url: item.url
				}))
			},

			// 点击预览
			handlePreview(file) {
				this.dialogImageUrl = file.url
				this.dialogVisible = true
			},
			//选择地址
			// handleSelect(item) {
			// 	this.companyInfo.province = item.province
			// 	this.companyInfo.city = item.city
			// 	this.companyInfo.district = item.district
			// 	this.companyInfo.companyLng = item.location.lng
			// 	this.companyInfo.companyLat = item.location.lat
			// },
			//地址搜索
			// querySearchAsync(queryString, cd) {
			// 	if (!queryString) {
			// 		cd([])
			// 		return
			// 	}
			// 	let data = {
			// 		key: "ZBABZ-ZWECU-UQTVV-4LYDR-COK3F-5SF75", //申请的密钥
			// 		keyword: queryString, //搜索内容
			// 		output: 'jsonp',
			// 	};
			// 	let url =
			// 		"https://apis.map.qq.com/ws/place/v1/suggestion"
			// 	axios.get(url, {
			// 		params: data,
			// 		adapter: jsonp
			// 	}).then(res => {
			// 		if (res.data.status == 0) {
			// 			let arr = res.data.data
			// 			arr.map(item => {
			// 				item.value = item.title
			// 			})
			// 			cd(arr)
			// 		}
			// 	}).catch(err => {
			// 		console.log(err)
			// 	})
			// },
			//去我的收藏
			goMyCollect(name) {
				this.$router.push({
					name: name,
				})
			},
			//去我的团队
			goMyTeam() {
				this.$router.push({
					name: 'myTeam'
				})
			},
			goJilu(type) {
				this.$router.push({
					name: 'jilu',
					query: {
						type: type
					}
				})
			},
			// 面试记录
			goMyRecord() {
				this.$router.push({
					name: 'record'
				})
			},
			//我的招聘
			goMyPostPush(type) {
				this.$router.push({
					name: 'myPostPush',
					query: {
						tabIndex: type
					}
				})
			},
			//获取岗位
			getlist() {
				let data = {
					status: '',
					page: 1,
					limit: 9,
					companyId: localStorage.getItem('companyId')
				}
				this.$Request.get('/app/postPush/getMyPostPush', {
					params: data
				}).then(res => {
					if (res.code == 0) {
						res.data.records.forEach(ret => {
							ret.showpeop = false
							if (ret.status == 1) {
								ret.statusName = '待审核'
							} else if (ret.status == 2) {
								ret.statusName = '招聘中'
							} else if (ret.status == 3) {
								ret.statusName = '已拒绝'
							} else if (ret.status == 4) {
								ret.statusName = '已取消'
							} else if (ret.status == 5) {
								ret.statusName = '已关闭'
							} else if (ret.status == 6) {
								ret.statusName = '已关闭'
							}
						})
						this.postPushList = res.data.records
					}
				})

			},
			//去钱包页面
			// goMoney() {
			// 	this.$router.push({
			// 		name: 'money'
			// 	})
			// },
			//招聘刷新
			refreshJob() {
				this.$Request.post("/app/postPush/refreshPostPush").then(res => {
					if (res.code == 0) {
						ElMessage({
							message: '刷新成功!',
							type: 'success',
							duration: 1500,
							offset: this.screenHeight / 2
						})
					} else {
						if (this.isUserVip) {
							ElMessage({
								message: res.msg,
								type: 'info',
								duration: 1500,
								offset: this.screenHeight / 2
							})
						} else {
							ElMessageBox.confirm(
								'今日可刷新次数已使用完，开通会员可享更多刷新次数以及其他特权',
								'温馨提示', {
									confirmButtonText: '确定',
									cancelButtonText: '取消',
									type: 'warning',
								}
							).then(res => {

							}).catch(() => {

							})
						}

					}
				})

			},
			//时间对象转：2023-11-21格式
			getFormDate(formData) {
				let time = new Date(formData)
				return time.getFullYear() + '-' + (time.getMonth() + 1) + '-' + time.getDate();
			},
			//企业认证
			saveCompany() {
				let formRef = this.$refs.formResume
				let form = JSON.parse(JSON.stringify(this.companyInfo))
				formRef.validate((valid) => {
					if (valid) {
						this.loading = true
						form.companyPeopleDevelop = form.companyPeopleDevelop.join(',');
						form.companyScope = form.companyScope.join(',');
						form.photos = form.photos.map(item => item.url).join(',');
						form.welfare = form.welfare.join(',');
						form.workTime = form.workTime.join('-');
						this.$Request.post("/app/company/updateCompany", form, {
							type: 'json'
						}).then(res => {
							if (res.code == 0) {
								ElMessage({
									message: '编辑成功!',
									type: 'success',
									duration: 1500,
									offset: this.screenHeight / 2
								})
								this.loading = false
								this.userInfoEdit = false
								this.getCompanyInfo()
							} else {
								this.loading = false
								ElMessageBox.alert(res.msg, '提示', {
									confirmButtonText: '确认'
								})
								this.getCompanyInfo()
							}
						});
						// if (this.companyInfo.companyId) { //修改
						// } 
						// else { //保存
						// 	this.$Request.post("/app/company/insertCompany", form, {
						// 		type: 'json'
						// 	}).then(res => {
						// 		if (res.code == 0) {
						// 			ElMessage({
						// 				message: '认证提交成功!',
						// 				type: 'success',
						// 				duration: 1500,
						// 				offset: this.screenHeight / 2
						// 			})
						// 			this.loading = false
						// 			this.userInfoEdit = false
						// 			this.getCompanyInfo()
						// 		} else {
						// 			this.loading = false
						// 			ElMessageBox.alert(res.msg, '提示', {
						// 				confirmButtonText: '确认'
						// 			})
						// 			this.getCompanyInfo()
						// 		}
						// 	});
						// }

					} else {
						console.log('error submit!')
						return false
					}
				})
			},
			//上传营业执照
			handleAvatarSuccessC(res) {
				this.companyInfo.companyCertification = res.data
			},
			//上传公司logo
			handleAvatarSuccessL(res) {
				this.companyInfo.companyLogo = res.data
			},
			//获取公司规模
			getComList() {
				let data = {
					type: '公司规模 '
				}
				this.$Request.get("/app/dict/list", {
					params: data
				}).then(res => {
					if (res.code == 0) {
						this.comList = res.data
					}
				})
			},
			//拿出详细地址
			extractText(inputString, searchString) {
				const index = inputString.indexOf(searchString);
				if (index !== -1) {
					return inputString.substring(index + searchString.length);
				} else {
					return null; // 或者可以返回一个默认值或者抛出一个错误  
				}
			},
			//获取企业信息
			getCompanyInfo() {
				this.$Request.get("/app/company/selectCompanyByUserId").then(res => {
					if (res.code == 0 && res.data) {
						res.data.companyScope = res.data.companyScope? res.data.companyScope.split(',') : []
						res.data.photos = res.data.photos
							? res.data.photos.split(',').map((url, index) => ({
								name: `image_${index}`,
								url
							}))
							: []


						res.data.companyPeopleDevelop = res.data.companyPeopleDevelop? res.data.companyPeopleDevelop.split(',') : [];
						res.data.welfare = res.data.welfare?res.data.welfare.split(',') : [];
						res.data.workTime = res.data.workTime?res.data.workTime.split('-') : [];
						// res.data.companyContent = res.data.companyContent.split(',')
						this.companyInfo = res.data
						this.companyInfos = res.data
						// if (res.data.province && res.data.city && res.data.district) {
						// 	this.companyInfo.companyAddress1 = [res.data.province, res.data.city, res
						// 		.data.district
						// 	]
						// }
						// let address = this.companyInfo.companyAddress
						// let reg = /.+?(省|市|自治区|自治州|县|区)/g
						// let cityarr = address.match(reg)
						// if (cityarr.length >= 3) {
						// 	this.companyInfo.companyAddress1 = [cityarr[0], cityarr[1], cityarr[2]]
						// } else {
						// 	this.companyInfo.companyAddress1 = cityarr[0] + '' + cityarr[1]
						// }
						// let str = this.companyInfo.companyAddress1.join('')
						// this.companyInfo.companyAddress = this.extractText(address, str)
					}
				})
			},
			//文案推广
			tuiguang() {
				ElMessageBox.confirm(
					this.tuiguangTxt + this.url,
					'文案推广', {
						confirmButtonText: '一键复制',
						cancelButtonText: '取消',
						type: 'warning',
					}
				).then(() => {
					navigator.clipboard.writeText(this.tuiguangTxt + this.url)
						.then(() => {
							ElMessage({
								type: 'success',
								message: '复制成功',
								duration: 1500,
								offset: this.screenHeight / 2
							})
							this.dialogShare = false
						})
						.catch(() => {
							ElMessage({
								type: 'info',
								message: '复制失败',
								duration: 1500,
								offset: this.screenHeight / 2
							})

						})
				}).catch(() => {

				})
			},
			//生成海报
			async shareImg() {
				let imgUrl = await this.createPoster();
				const a = document.createElement('a');
				a.href = imgUrl;
				a.download = 'share.png'; // 你可以设置一个下载的文件名  
				a.click(); // 自动点击下载  
				// console.log(imgUrl, '生成的图片')

			},
			//使用canvas创建分享海报
			createPoster() {
				return new Promise((resolve, reject) => {
					const canvas = this.$refs.poster;
					const canvasWidth = canvas.getBoundingClientRect().width;
					const canvasHeight = canvas.getBoundingClientRect().height;
					const ctx = canvas.getContext('2d');
					ctx.fillStyle = '#ffffff';
					ctx.fillRect(0, 0, canvasWidth, canvasHeight);
					//获取文字的y坐标
					let txtY = 500 + ((canvasHeight - 620) / 2) + 60
					//获取二维码的x坐标
					let txtX = 20
					//绘制文字
					ctx.fillStyle = 'black'; // 设置字体颜色  
					ctx.font = '50px';
					ctx.fillText('长按识别图中二维码', txtX, txtY); // 在指定的位置绘制文字
					let imgUrl = this.backgroundImage; //背景图
					// 绘制背景图片  
					let imgBg = new Image();
					imgBg.crossOrigin = "Anonymous"
					imgBg.src = imgUrl; // 请替换为你的图片地址
					imgBg.onload = () => {
						ctx.drawImage(imgBg, 0, 0, canvasWidth, 500);
						//获取二维码的y坐标
						let qrY = 500 + ((canvasHeight - 620) / 2)
						//获取二维码的x坐标
						let qrX = 375 - 20 - 120
						// 绘制二维码
						let imgQr = new Image()
						imgQr.crossOrigin = "Anonymous"
						imgQr.src = ROOTPATH4 + '/app/invite/mpCreateQr?invitationCode=' + this.invitationCode
						imgQr.onload = () => {
							ctx.drawImage(imgQr, qrX, qrY, 120, 120)
							// //canvas画布转成图片
							let image = canvas.toDataURL('image/png');
							//返回图片
							resolve(image)
						}
					}
				})
			},
			//打开分享弹框
			openShar() {
				this.getBackImageList()
				this.getYaoNum()
				this.getInviteMoney()
				//文案推广
				this.$Request.get('/app/common/type/255').then(res => {
					if (res.code === 0) {
						if (res.data && res.data.value) {
							this.tuiguangTxt = res.data.value;
						}
					}
				});
				//用户端域名
				// this.$Request.get('/app/common/type/19').then(ress => {
				// 	if (ress.code === 0) {
				// 		if (ress.data && ress.data.value) {
				// 			this.url = ress.data.value + '/?invitation=' + this.invitationCode;
				// 		}
				// 	}
				// });
				this.url = ROOTPATH4 + 'index?inviterCode=' + this.invitationCode;
				this.dialogShare = true
			},
			replaceStringPart(original, replacement) {
				// 使用正则表达式查找并替换第一个匹配的部分  
				let replaced = original.replace(replacement, ROOTPATH4)
				return replaced;
			},
			//获取邀请背景图
			getBackImageList() {
				this.$Request.get('/app/banner/selectBannerList?state=-1&classify=6').then(res => {
					if (res.code === 0) {
						this.backgroundImage = this.replaceStringPart(res.data[0].imageUrl,
							'https://zp.xianmaxiong.com/');
					}
				});
			},
			//获取我邀请的人数
			getYaoNum() {
				this.$Request.get('/app/invite/selectInviteCount').then(res => {
					if (res.code === 0) {
						this.peopleNum = res.data
					}
				});
			},
			//获取邀请收益
			getInviteMoney() {
				this.$Request.get('/app/common/type/269').then(res => {
					if (res.code === 0) {
						this.numPeople = res.data.value
					}
				});
			},
			//打开行业选择弹框
			// openIndustry(type) {
			// 	this.type = type
			// 	this.industryArr = []
			// 	this.getIndustryList()
			// },
			// 添加行业
			// addIndustry(ite) {
			// 	if (ite.select == false) {
			// 		if (this.industryArr.length == 3) {
			// 			ElMessage({
			// 				message: '最多添加三条',
			// 				type: 'info',
			// 				duration: 1500,
			// 				offset: this.screenHeight / 2
			// 			})
			// 			return
			// 		}
			// 		this.industryArr.push(ite.industryName)
			// 	} else {
			// 		console.log('ccccccccccc')
			// 		this.industryArr.splice(this.industryArr.indexOf(ite.industryName), 1)
			// 	}
			// 	ite.select = !ite.select
			// },
			/**
			 * 获取行业数据
			 */
			// getIndustryList() {
			// 	this.$Request.get('/app/industry/getIndustryList').then(res => {
			// 		if (res.code == 0) {
			// 			let arr = JSON.parse(JSON.stringify(res.data))
			// 			arr.map(item => {
			// 				item.childrenList.map((ite, ind) => {
			// 					ite.select = false
			// 					if (ind < 6) {
			// 						this.industryArrList.push(ite)
			// 					}
			// 				})
			// 			})
			// 			this.industryList = arr
			// 			this.industryDialog = true
			// 		} else {
			// 			ElMessage({
			// 				message: res.msg,
			// 				type: 'error',
			// 				duration: 1500,
			// 				offset: this.screenHeight / 2
			// 			})
			// 		}
			// 	})
			// },
		},
	}
</script>
<style lang="scss" scoped>
	@import url("index.scss");
	:deep(.el-upload-list--picture-card .el-upload-list__item){
		width: 100px;
		height: 100px;
	}
	.avatar-uploader-icon {
		color: var(--el-border-color);
		font-size: 25px;
		width: 100px;
		height: 100px;
		border-radius: 6px;
		background: #f5f7fa;
	}
	:deep(.el-upload--picture-card){
		border: none !important;
		width: initial !important;
	}
</style>