<template>
	<view class="content">
		<view class="band">
			<view class="contentItem">
				<text>姓名:</text>
				<input v-model="openForm.userNameChinese" class="user-input" type="text" placeholder="请输入姓名" />
			</view>
			<view class="contentItem">
				<text>英文名:</text>
				<input class="user-input" v-model="openForm.userNameEnglish" maxlength="10" type="text"
					placeholder="请输入英文名" />
			</view>
			<view class="contentItem">
				<text>手机号</text>
				<!-- userTel -->
				<text>{{openForm.userTel}}</text>
			</view>
			<view class="contentItem">
				<text>证件类型</text>
				<!-- <input v-model="openForm.userIdType" class="user-input" maxlength="10" type="text"
					placeholder="请输入证件类型" /> -->
				<picker v-if="erplizeList " @change="bindPickerChange($event,erplizeList)" :value="index"
					:range="erplizeList" range-key="name">
					<view style="background-color: white;">{{ erplizeList[index].name }}</view>
				</picker>
			</view>
			<view class="contentItem">
				<text>证件号</text>
				<input v-model="openForm.userIdNo" class="user-input" maxlength="20" type="text" placeholder="请输入证件号" />
			</view>
			<view class="" style="margin-top: 20rpx;">
				<text>上传计划书</text>
			</view>
			<view class="" style="display: flex;margin-top: 20rpx;" v-if="openForm.fileName">
				<view class="" style="width: 20px;height: 30px;">
					<image class="imagegh" src="../../static/myteam/Pdf.png" mode=""></image>
				</view>
				<text style="margin-left: 10rpx;" @click="exportTo">{{openForm.fileName}}</text>
			</view>
			<view class="uploadpdf" @click="uploadFile()">
				<view class="uploadimg">
					<view class="" style="width: 50px;">
						<image class="image" src="../../static/myteam/Group1646.png"></image>
					</view>
					<p>点击添加计划书</p>
				</view>
				<view class="footer-text">
					<text>(请上传pdf文件)</text>
				</view>
			</view>
		</view>
		<view class="footer">
			<button class="user-button" @click="onsubmit()" :loading="loading" :disabled="loading">保存</button>
		</view>
	</view>
</template>

<script>
	import {
		uploadFilepdf
	} from '@/util/uploaderFile'
	import api from "@/api/api";
	export default {
		data() {
			return {
				dataForm: {
					loginId: "1",
					targetType: "5",
					targetId: "1",
					targetNo: "7",
					targetUseFor: "12",
					targetSeq: "0"
				},
				openForm: {
					signupId: '',
					userTel: '183****9247',
					userIdType: '1'
				},
				index: 0,
				loading: false,
				fileList: [],
				fileForm: {},
				erplizeList: null,
			}
		},
		onLoad(option) {
			this.openForm.signupId = option.userSignupId
			this.getquerySignUpInfo()
		},
		onShow() {
			this.geterpInitialize()
		},

		methods: {
			async getquerySignUpInfo() {
				let UserSignUpInfoQueryRequestVO = {
					userSignUpId:this.openForm.signupId
				}
				let res = await api.querySignUpInfo(UserSignUpInfoQueryRequestVO)
				 this.openForm = res.data
				 this.openForm.signupId = res.data.id
			},
			exportTo(){
				console.log(this.openForm.planBookPdfUrl, 4451)
				uni.navigateTo({
					url: '/pages/personalCenter/accountoperation/phonebinding?fileUrl='+ encodeURIComponent(this.openForm.planBookPdfUrl)
				})
			},
			// 获取证件类型
			async geterpInitialize() {
				let res = await api.erpInitialize()
				this.erplizeList = res.data.idTypes
				console.log(this.erplizeList, 444)
			},
			bindPickerChange(e, storage) {
				this.openForm.userIdType = storage[e.detail.value].id
				this.index = e.detail.value;
			},
			onsubmit() {
				this.loading = true
				let requestVo = this.openForm
				// header:{
				// 	'content-type': 'application/json',
				// },
				api.uploadSignUpUserInfo(requestVo).then(res => {
					if(res['success']){
						// 
						uni.showToast({
							title: res['message'],
							duration: 2000,
							icon: 'none'		
						});
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
						//this.getquerySignUpInfo()
					}
					this.loading = false
				})
			},
			// 上传文件方法
			uploadFile(event) {
				let that = this;
				uploadFilepdf(this.dataForm)
					.then(res => {
						console.log(res, 54854)
						// that.headUrl = res[0].url
						// this.fileForm = {
						// 	name: res.name,
						// 	filePath: res.data.filePath
						// }
						this.openForm.fileName = res.name
						this.openForm.planBookPdfUrl = res.data.filePath
					})
			},
		}
	}
</script>

<style lang="scss">
	.content {
		width: 100vw;
	}

	.signfile {
		display: flex;

	}

	.imagegh {
		width: 30rpx;
		height: 30rpx;
	}

	.user-input {
		text-align: right;
	}



	.uploadimg {
		height: 160px;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;

		.image {
			width: 50px;
			height: 43px;
		}
	}

	.user-textarea {
		border: 1px solid #C7C7C7;
		width: 540rpx;
		height: 270rpx;
		border-radius: 10rpx;
	}

	.band {
		margin: 0 20rpx;
		font-size: 26rpx;
	}

	.footer-text {
		text-align: center;
		margin-top: 10rpx;
		font-size: 20rpx;
		color: #666666;
	}

	.uploadpdf {
		width: 274px;
		height: 160px;
		background: #F8F8F8;
		border-radius: 2px 2px 2px 2px;
		opacity: 1;
		border: 1px solid #E3E3E3;
		margin: 10px auto;
	}

	.headportrait {
		width: 260rpx;
		height: 260rpx;
		border: 1rpx solid aqua;
		border-radius: 50%;
	}

	.contentItem {
		margin-top: 20rpx;
		display: flex;
		justify-content: space-between;
		border-bottom: 2rpx solid #E4E4E4;
		padding: 10rpx;
	}

	.footer {
		width: 500rpx;
		height: 80rpx;
		opacity: 1;
		margin: 80rpx auto;
	}

	.user-button {
		color: #FFFFFF;
		background: #20269B;
		border-radius: 80px;
	}
</style>
