<template>
	<view>
		<navbar titlenav=""></navbar>
		<view class="box">
			<view style="line-height: 60rpx;">
				<view style="font-size: 18px;font-weight: 600;display: flex;justify-content: space-between">
					<view class="">
						请先完善公司信息
					</view>
					<view class="" style="font-size: 16px;font-weight: 500;">
						跳过
					</view>
				</view>
				<view class="">
					信息安全保护中，请放心填写
				</view>
			</view>
			<view class="" style="margin-top: 40rpx;">
				<u--form labelPosition="left" labelWidth="100" :model="formData" :rules="rules" ref="uForm">
					<u-form-item label="公司名称" prop="userInfo.name" borderBottom>
						<u--input v-model="formData.name" placeholder="请输入公司名称"></u--input>
					</u-form-item>
					<u-form-item label="企业规模" prop="userInfo.name" borderBottom labelPosition="top">
						<view>
							<view v-for="(item, index) in radios" :key="index" style="margin: 20rpx 20rpx 0 0;display: inline-block;">
								<u-tag :text="item.lable" :plain="!item.checked" type="warning" :name="index"
									@click="radioClick">
								</u-tag>
							</view>
						</view>
					</u-form-item>
					<u-form-item label="法人姓名" prop="userInfo.name" borderBottom>
						<u--input v-model="formData.name" placeholder="请输入姓名"></u--input>
					</u-form-item>
					<u-form-item label="营业执照" prop="userInfo.name" labelPosition="top">
						<view style="margin-top: 20rpx;">
							<u-upload :previewFullImage="true" width='140' height='80' :fileList="fileListcardImg"
								@afterRead="afterRead" @delete="deletePic" name="cardImg" multiple :maxCount="1"
								>
								<!-- 	<image :src="zmImg" mode="widthFix" style="width: 140px;height: 80px;">
								</image> -->
							</u-upload>
						</view>
						
					</u-form-item>
				</u--form>
			</view>
			<view class="wada" style="height: 300rpx;">
				
			</view>
			<view style="position: fixed;bottom: 0;left: 0;width: 100%;padding: 40rpx;">
				<view class=""  style="margin-bottom: 40rpx;">
					<u-button text="上一步" type="success" @click="back()" shape="circle"
						></u-button>
				</view>
				<u-button text="下一步" type="success" @click="toNext('/pages/workNext/index3')" shape="circle"></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fileListcardImg: [],
				fileListcardImgB: [],
				formData: {
					time: null,
					name: null,
				},
				rules: {
					'name': {
						type: 'string',
						required: true,
						message: '请填写姓名',
						trigger: ['blur', 'change']
					},
				},
				radios: [{
						lable: '10-50人',
						checked: false
					},
					{
						lable: '50-200人',
						checked: false
					},
					{
						lable: '200-1000人',
						checked: false
					},{
						lable: '10-50人',
						checked: false
					},
					{
						lable: '50-200人',
						checked: false
					},
					{
						lable: '200-1000人',
						checked: false
					},{
						lable: '10-50人',
						checked: false
					},
					{
						lable: '50-200人',
						checked: false
					},
					{
						lable: '200-1000人',
						checked: false
					}
				],
			};
		},
		onLoad() {

		},
		methods: {
			// 企业规模
			radioClick(name) {
				this.radios.map((item, index) => {
					item.checked = index === name ? true : false
				})
			},
			back() {
				uni.navigateBack()
			},
			toNext(url) {
				uni.navigateTo({
					url: url
				})
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilesPromise(lists[i].url)
					result.url = this.baseurl + result.fileName
					this.form[`${event.name}`] = result.fileName;
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		margin: 40rpx;
	}

	.flexbetween {
		display: flex;
		justify-content: space-between;
	}
</style>