
<template>
	<view class="content">
	     <view class="header-box">
			 <image src="/static/tips.png" mode="aspectFill"></image>
			  <text>温馨提示：请填写以下信息，填写后信息不可修改</text>
		 </view>
		<form @submit="formSubmit" style="width: 100%"> 
	     <view class="self-title-box">
			 <image src="/static/rect-icon.png" mode="aspectFill"></image>
			 <text>登记信息</text>
		 </view>
		<view class="info-box">
			<view class="info-title-box">
				<image src="/static/require-icon.png" mode="aspectFill"></image>
				<text>姓名</text>
			</view>
			<view class="info-value-box">
				<input type="text" placeholder="请输入姓名" name="selfName">
			</view>		
		</view>
		
		<view class="info-box" style="height: 150rpx;">
			<view class="info-title-box">
				<image src="/static/require-icon.png" mode="aspectFill"></image>
				<text>性别</text>
			</view>
			<view class="info-gender-box">
				<radio-group @change="radioCheck" class="padding-left-2">
					<label class="radio margin-right-10"><radio value="0" :checked="userSex==='0'" color="#00A1B4" class="form-radio"/>男</label>
					<label class="radio"><radio value="1" :checked="userSex==='1'"  color="#00A1B4" class="form-radio"/>女</label>
				</radio-group>
			</view>		
		</view>
		<view class="info-box" style="height: 390rpx;">
			<view class="info-title-box">
				<image src="/static/require-icon.png" mode="aspectFill"></image>
				<text>所在城市</text>
			</view>
			<view class="info-value-box" style="margin: 2% auto;">
			   			<view class="uni-input picker-box">
							<pickerAddress @change="changeCity" style="width: 100%;color: #888;">
								{{txt}}
								<image src="/static/right-arrow.png" mode="aspectFill"></image>
							</pickerAddress>
						</view>
					<view class="textarea-box">
					     <textarea  auto-height placeholder="请输入详细地址" />
					 </view>
			</view>		
		</view>
		<view class="info-box">
			<view class="info-title-box">
				<image src="/static/require-icon.png" mode="aspectFill"></image>
				<text>行业</text>
			</view>
			<view class="info-value-box">
				  <picker @change="bindPickerChange($event,'trade')"  :range="tradeArray" class="select-box" name="trade">
				        <view class="uni-input">{{tradeValue}}</view>
				  </picker>
			</view>		
		</view>
		
		<view class="info-box">
			<view class="info-title-box">
				<image src="/static/require-icon.png" mode="aspectFill"></image>
				<text>职业</text>
			</view>
			<view class="info-value-box">
				  <picker @change="bindPickerChange($event,'profession')"  :range="professionArray" class="select-box" name="profession">
				        <view class="uni-input">{{professionValue}}</view>
				  </picker>
			</view>		
		</view>
		
		<view class="info-box">
			<view class="info-title-box">
				<image src="/static/require-icon.png" mode="aspectFill"></image>
				<text>参观目的</text>
			</view>
			<view class="info-value-box">
				  <picker @change="bindPickerChange($event,'ends')" :range="endsArray" class="select-box" name="ends">
				        <view class="uni-input">{{endsValue}}</view>
				  </picker>
			</view>		
		</view>
		
		<view class="info-box"  style="border-bottom: none;">
			<view class="info-title-box">
				<text>您目前从事的家具品牌</text>
			</view>
			<view class="info-value-box">
				<input type="text" placeholder="请输入您目前从事的家具品牌">
			</view>		
		</view>
		
		<view style="width: 100%;">
			<button type="primary" class="submit-bth" formType="submit">提交</button>
		</view>
	</form>	
	</view>
</template>

<script>
	var md5 = require("../../../common/md5.js");
	import pickerAddress from '../../../components/wangding-pickerAddress/wangding-pickerAddress.vue';
	var graceChecker = require("../../../common/graceChecker.js");
	export default {
		components: {
			pickerAddress
		},
		data() {
			return {
				title: 'Hello',
				detailObj:{},
				shareContent:'',
				shareCode:'',
				storeImg:'',
				isAuthPhone:getApp().globalData.user_phone,
				userSex:'1',
				txt: '请选择',
				tradeValue:'请选择',
				tradeArray: ['品牌营销', '家具销售', '室内设计', '家装建材','生产制造'],
				professionValue:'请选择',
				professionArray:['室内设计师','高层管理','品牌方销售','个体经销商','工程师','家具设计师','生产技术员','品牌方设计师'],
				endsValue:'请选择',
				endsArray:['学习与交流','了解科尔卡诺','商业洽谈','寻找新的合作','意向加盟'],
			}
		},
		onLoad(option) {
			//this.getDetailInfo(option.detailId);
		},
		onShow() {
		},
		onShareAppMessage() {
			  return {
			      title: '分销小助手',
			      path:'/pages/index/index?scene=' + getApp().globalData.user_id
			    }
		},
		methods: {
			goRuleList(){
			 		uni.navigateTo({
			 		url: '/pages/index/ruleList/index',
			 		success: res => {},
			 		fail: () => {},
			 		complete: () => {}
			 	});
			 },
			 radioCheck(e){
			 	console.log(e.target.value)
			 	this.userSex = e.target.value;
			 	//this.gender = e.target.value == '0' ? '男' : '女';
			 },
			 changeCity(data) {
				 this.txt = data.data.join('')
				 console.log(data.data.join(''))
			  },
			 bindPickerChange(e,type) {
				         console.log(e.target.value,type)
						 let that = this;
						  switch (type){
						  	case 'trade':
							 that.tradeValue =  that.tradeArray[e.target.value]
						  		break;
						  	case 'profession':
							console.log(that.professionValue)
						  	 that.professionValue =  that.professionArray[e.target.value]
						  		break;
							case 'ends':
							 that.endsValue =  that.endsArray[e.target.value]
								break;	
						  }
			             
			          },
			  formSubmit(e) {
			  	//将下列代码加入到对应的检查位置
			  	//定义表单规则
			  	var rule = [
			  		{
			  			name: "selfName",
			  			checkType: "notnull",
			  			errorMsg: "姓名不能为空"
			  		},
					{
						name: "trade",
						checkType: "notnull",
						errorMsg: "行业不能为空"
					},
					{
						name: "profession",
						checkType: "notnull",
						errorMsg: "职业不能为空"
					},
					{
						name: "ends",
						checkType: "notnull",
						errorMsg: "参观目的不能为空"
					},
			  	];
			  	//进行表单检查
			  	var formData = e.detail.value;
				console.log(formData)
			  	var checkRes = graceChecker.check(formData, rule);
			  	if (checkRes) {
					this.txt === '请选择' ? 
					uni.showToast({
						title: '请选择地区',
						icon: "none"
					}):
					this.submitRequest();
			  	} else {
			  		uni.showToast({
			  			title: graceChecker.error,
			  			icon: "none"
			  		});
			  	}
			  },
			submitRequest(){
				this.goCustomCardPage('0')
			},  
			goCustomCardPage(type){
				type === '1' ? 
				uni.redirectTo({
					url: '/pages/index/successPage/index?types='+'custom', //游客成功页面
					success: res => {},
					fail: () => {},
					complete: () => {}
				}):
				uni.redirectTo({
					url: '/pages/index/failPage/index', //失败页面
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}  
		}
	}
</script>

<style>
	.content {
		width: 100%;
		/* height: 100%; */
		display: flex;
		flex-direction: column;
		align-items: center;
		/* justify-content: center; */
	}
	.header-box {
		width: 85%;
		height:80rpx;
		border: .5px dotted #00A1B4;
		border-radius: 50rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 24rpx;
		color:#00A1B4 ;
		/* font-family: PingFangSC-Regular; */
		margin-top: 2%;
	}
	.header-box image {
		width: 36rpx;
		height: 36rpx;
		margin-right: 1%;
	}
	.self-title-box {
		width: 90%;
		display: flex;
		align-items: center;
		font-size: 32rpx;
		letter-spacing: 2rpx;
		color:#3C3C3C ;
		/* font-family: SimHei; */
		margin: 4% auto;
		font-weight: bold;
		height: 50rpx;
		line-height: 50rpx;

	}
	.self-title-box image {
		width: 6rpx;
		height: 32rpx;
		margin-right: 2%;
	}
	.info-box {
		width: 90%;
		margin: 3% auto;
		height: 180rpx;
		border-bottom: 1px solid #f7f7f7;
	}
	.info-title-box {
		width: 100%;
		display: flex;
		align-items: center;
		font-size: 28rpx;
		height: 50rpx;
		line-height: 50rpx;

	}
	.info-title-box image{
		width: 15rpx;
		height: 15rpx;
		margin-right: 2%;
	}
	.info-value-box input {
		height: 88rpx;
		background: #f7f7f7;
		font-size: 28rpx;
		padding-left: 4%;
		margin: 2% auto;
	}
	.select-box {
		height: 88rpx;
		background: #f7f7f7;
		font-size: 28rpx;
		padding-left: 4%;
		margin: 2% auto;
		color: #888;
		line-height: 88rpx;
	}
	.info-gender-box {
		margin: 3% auto;
		font-size: 28rpx;
	}
	.form-radio {
			 transform: scale(0.6);
	}
	.padding-left-2 {
		padding-left: 2%;
	}
	.margin-right-10 {
		margin-right: 10%;
	}
	.border-line-box {
		width: 100%;
		height: 20rpx;
		background: #f7f7f7;
	}
	.picker-box{
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 60rpx;
		line-height: 60rpx;
		background: #f7f7f7;
		height: 88rpx;
		line-height: 88rpx;
		background: #f7f7f7;
		font-size: 28rpx;
		padding-left: 4%;
	}
	.uni-input image {
		width: 40rpx;
		height: 40rpx;
		margin-right: 2%;
		float: right;
		margin-top: 22rpx;
	}
	.textarea-box {
		background: #f7f7f7;
		min-height: 120rpx;
		font-size: 28rpx;
		margin: 5% auto;
		padding: 4%;
		margin-bottom: 8%;
	}
	.submit-bth {
		width: 80%;
		height: 80rpx;
		line-height: 80rpx;
		background: #00A1B4!important;
		-webkit-box-shadow: 0 2rpx 16rpx 0 rgba(60,120,109,0.20);
		box-shadow: 0 2rpx 16rpx 0 rgba(60,120,109,0.20);
		border-radius: 50rpx;
		margin-bottom: 10%;
		font-size: 30rpx;
	}
</style>
