<template>
	<view style="padding: 0 40upx;">
		 <van-field
		    :value="hotel_name"
		    placeholder="请输入酒店名称"
		    label="酒店名称"
			style="padding: 0;"
			@change="changehotel_name"
		  />
		<van-field
		   :value="contacts_address"
		   placeholder="请输入酒店地址"
		   label="酒店地址"
		    @change="changaddress"
		 />
		 <van-field
		    :value="contacts_name"
		    placeholder="请输入负责人姓名"
		    label="负责人"
			@change="onChange"
		  />
		  <van-field
		     :value="contacts_phone"
		     placeholder="请输入负责人手机号码"
		     label="手机号码"
			  @change="changenumber"
		   />
		 <van-field
		    :value="contacts_number"
		    placeholder="请输入负责人身份证号码"
		    label="身份证号码"
			@change="changIdcard"
		  />
		<view>
				 <uploadImage  @getImg="getImg"  />
				 <view style="padding: 15upx 0;">须上传营业执照和手持身份证照</view>
		</view>
		<view class="submitRemin" @click="submitRemin">申请入驻</view>
		   
	</view>
</template>

<script>
	import uploadImage from '@/component/uploadImage.vue'
	export default {
		components: {
			uploadImage
		},
		data(){
			return{
				imageList:[],
				hotel_name:'',
				contacts_address:'',
				contacts_name:'',
				contacts_phone:'',
				contacts_number:''
			}
		},
		methods: {
			changehotel_name(e) {
				this.hotel_name = e.detail;
			},
			onChange(e) {
				this.contacts_name = e.detail;
			},
			changenumber(e){
				this.contacts_phone = e.detail;
			},
			changIdcard(e) {
				this.contacts_number = e.detail;
			},
			changaddress(e) {
				this.contacts_address = e.detail;
			},
			getImg(e) {
				this.imageList = e;
			},

			submitRemin() {
				let reg_card =  /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
				let reg_phone = /^1[3456789]\d{9}$/;
				if(this.hotel_name == '') {
					this.$msg("请输入酒店名称");
					return;
				}
				else if(this.contacts_address == '') {
					this.$msg("请输入地址");
					return;
				}
				else if(this.contacts_name == '') {
					this.$msg("请输入姓名");
					return;
				}else if(this.contacts_phone == '') {
					this.$msg("请输入电话号码");
					return;
					
				}else if( !reg_phone.test(this.contacts_phone)) {
						this.$msg("请输入正确手机号")
						return;
				}else if(this.contacts_number == '') {
					this.$msg("请输入身份证号码");
					return;
				}else if( !reg_card.test(this.contacts_number)) {
						this.$msg("请输入正确身份证号码")
						return;
				}else if(this.imageList.length == 0) {
					this.$msg("请上传图片");
					return;
				}
				let licence_image = this.imageList.join(',');
				this.request({
					url: '/v2/member/application',
					method:'post',
					data: {
						contacts_name: this.contacts_name,	
						contacts_phone: this.contacts_phone,		
						contacts_number	: this.contacts_number,	
						contacts_address: this.contacts_address,
					    join_type: 1,
						licence_image: licence_image
					},
					success: (res) => {
						if(res.data.code == 1000) {
							this.$msg("申请成功");
							setTimeout(() => {
							      uni.navigateBack();
							    }, 1000);
						}
					}
				})
			},
		}
	}
</script>

<style>
	.van-cell {
		padding-left: 0!important;
	}
</style>
