<template>
	<view style="padding: 0 32upx;">
		 <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"
		  />
		  <van-field
		     :value="contacts_address"
		     placeholder="请输入您的联系地址"
		     label="联系地址"
			 @change="changaddress"
		   />
		<view>
				<uploadImage @getImg="getImg" />
				 <view>须上传营业执照和手持身份证照</view>
		</view>
		<view class="submitRemin" @click="goapply">申请代理</view>
		   
	</view>
</template>

<script>
	import uploadImage from '@/component/uploadImage.vue'
	import baseUrl from '@/common/new_file.js'
	export default {
		components: {
			uploadImage
		},
		data(){
			return{
				name:'',
				imageList:[],
				contacts_name:'',	
				contacts_phone:'',	
				contacts_number:'',	
				contacts_address:'',
			}
		},
		methods: {
			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;
			},
			goapply() {
				console.log(this.contacts_name)
				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.contacts_address == '') {
					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: 0,
						licence_image: licence_image
					},
					success: (res) => {
						if(res.data.code == 1000) {
							this.$msg("申请成功");
							setTimeout(() => {
							      uni.navigateBack();
							    }, 1000);
						}
					}
				})
			},
			getImg(e) {
				console.log(e);
				this.imageList = e;
			}
		}
	}
</script>

<style>
	.deepHeight {
		height: 108upx;
		width: 108upx;
	}
</style>
