<template>
	<view style="padding: 0 32upx;">
		 <van-field
		    :value="hotel_name"
		    placeholder="请输入酒店名称"
		    label="酒店名称"
			@change="hotel_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>须上传营业执照和手持身份证照</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: {
			hotel_name(e) {
				this.hotel_name = e.detail;
			},
			onChange(e) {
			    console.log(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) {
				console.log(e);
				this.imageList = e;
			},
			submitRemin() {
				console.log(this.contacts_name)
				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(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>
	
</style>
