<template>
	<view class="page">
		<view class="feedback-top">
			请如实填写公司信息，当公司信息核对之后，我们会在5个工作日内联系您
		</view>
		<!-- 反馈内容 -->
		<view class="feedback-data">
			<view class="titleall-box">
				<view class="titleall-left">
					<view class="titleall-left-line"></view>填写公司信息
				</view>
			</view>
			<view class="feedback-type">
				<view class="title">
					<text>公司名称</text>
				</view>
				<view class="more">
					<view class="contact-way">
						<input type="text" v-model="form.name" placeholder="请输入公司名称">
					</view>
				</view>
			</view>
			<view class="feedback-line"></view>
			<view class="feedback-type">
				<view class="title">
					<text>统一社会信用代码</text>
				</view>
				<view class="more">
					<view class="contact-way">
						<input type="text" v-model="form.credit" placeholder="请输入统一社会信用代码">
					</view>
				</view>
			</view>
			<view class="feedback-line"></view>
			<view class="feedback-type">
				<view class="title">
					<text>联系人</text>
				</view>
				<view class="more">
					<view class="contact-way">
						<input type="text" v-model="form.contact" placeholder="请输入联系人姓名">
					</view>
				</view>
			</view>
			<view class="feedback-line"></view>
			<view class="feedback-type">
				<view class="title">
					<text>联系电话</text>
				</view>
				<view class="more">
					<view class="contact-way">
						<input type="text" v-model="form.phone" placeholder="请输入联系电话">
					</view>
				</view>
			</view>
			<view class="feedback-line"></view>
			<view class="feedback-data-title">招工简介</view>
			<view class="content">
				<textarea value="" v-model="form.synopsis" placeholder="请描述公司的主营业务及您需要的工种类型详情" />
			</view>
			<view class="feedback-data-title">岗位展示（图片/视频）</view>
			<view class="voucher-img">
				<robby-image-upload v-model="form.post" :server-url="BASE_URL+'/api/file/Uploader/1'" fileKeyName="file"
					@add="addImage" :enable-del="true" limit="9"></robby-image-upload>
			</view>
			<view class="feedback-line"></view>
			<view class="feedback-data-title">上传营业执照</view>
			<view class="voucher-img">
				<robby-image-upload v-model="form.business" :server-url="BASE_URL+'/api/file/Uploader/1'" fileKeyName="file"
					@add="addImagebusiness" :enable-del="true" limit="3"></robby-image-upload>
			</view>
		</view>
		<view class="my-phone">
			<view>客服电话：654564</view>
			<view>彭州市人社局监督电话：541516</view>
			<view>备案号：6556121212</view>
		</view>
		<!-- 提交 -->
		<view class="submit-btn" @click="submit">
			<text>提交</text>
		</view>
	</view>
</template>

<script>
	import BASE_URL from '@/common/config.js'
	import robbyImageUpload from '@/components/robby-image-upload/robby-image-upload.vue'
	export default {
		components: {
			robbyImageUpload
		},
		data() {
			return {
				BASE_URL,
				TypeIndex: 0,
				imageData: [],
				form: {
					id: undefined,
					name: undefined,
					credit: undefined,
					contact: undefined,
					phone: undefined,
					synopsis: undefined,
					post: [],
					business: []
				}
			};
		},
		onLoad() {
			// this.API.GetRresOne().then(res => {
			// 	if (res.code == 200 && res.data != null) {
			// 		this.form = res.data;
			// 		this.form.post = res.data.post.filter(res => {
			// 			if (res.url == null) {
			// 				return false;
			// 			}
			// 			return true;
			// 		});
			// 		this.form.business = res.data.business.filter(res => {
			// 			if (res.url == null) {
			// 				return false;
			// 			}
			// 			return true;
			// 		});
			// 	} else {

			// 	}
			// });
		},
		methods: {
			addImage(e) {
				this.form.post = e.allImages.filter(res => {
					if (!res.url) {
						return false;
					}
					return true;
				});
			},
			addImagebusiness(e){
				this.form.business = e.allImages.filter(res => {
					if (!res.url) {
						return false;
					}
					return true;
				});
			},
			submit() {
				console.log(this.form);
				this.API.CreateRres(this.form).then(res => {
					if (res.code == 200) {
						uni.showToast({
							title: '申请招工成功，请等待客服联系！',
							icon: 'none'
						});
					}
				});
			},
			/**
			 * 反馈类型
			 * @param {Object} val
			 */
			FeedbackTypeCh(val) {
				console.log(val);
				this.TypeIndex = val.detail.value;
			}
		}
	}
</script>

<style scoped lang="scss">
	@import 'Feedback.scss';
</style>
