<%@ page language="java" pageEncoding="utf-8"%>
<%@ page language="java" import="com.fadu.web.util.Constant" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<% 
	String token = (String)session.getAttribute(Constant.Session.TOKEN) ;
	String openid = (String)session.getAttribute(Constant.Session.DWLSD_OPENID);
	String preUrl = (String)session.getAttribute(Constant.Request.PREURL);
%>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="wap-font-scale" content="no">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
    <title>多问</title>
    <script type="text/javascript" src="${contextPath}/static/js/flexible.min.js"></script>    
    <link rel="stylesheet" type="text/css" href="${contextPath}/static/weixin/sb/css/sprite.css">
    <link rel="stylesheet" type="text/css" href="${contextPath}/static/weixin/sb/css/common.css">
    <link rel="stylesheet" type="text/css" href="${contextPath}/static/weixin/sb/css/main.css">
</head>
<body class="bg-white">
	<div class="page">
		<header class="pad-lr-30 ub ub-ac ub-pj form-header">
			<a href="javascript:history.back(-1);" class="icon icon-jump"></a>
			<a href="${contextPath}/wx/toLogin" class="fs-14 fc-blue">登录</a>
		</header>
		<div class="mar-t-20 register-center">
			<form class="pad-l-30 login-form">
				<div class="pad-t-25 pad-b-15 pad-r-30 pos-relate br-bottom1 ub ub-ac">
					<label class="fc-dgrey">手机号：</label>
					<input type="tel" name="phone" class="pad-lr-10 ub-f1 form-control">
					<a href="javascript:void(0)" class="fc-blue get-code" id="getValidCode">获取验证码</a>
					<a href="javascript:void(0)" class="fc-blue get-code hide" id="djs">重获(60秒)</a>					
				</div>
				<div class="pad-t-25 pad-b-15 pad-r-30 pos-relate br-bottom1 ub ub-ac">
					<label class="fc-dgrey">验证码：</label>
					<input type="tel" name="code" class="pad-lr-10 ub-f1 form-control">
				</div>
				<div class="pad-t-25 pad-b-15 pad-r-30 pos-relate br-bottom1 ub ub-ac">
					<label class="fc-dgrey">密码：</label>
					<input type="password" name="password" class="pad-lr-10 ub-f1 form-control">
					<span class="icon icon-unsee btn-password"></span>
				</div>
				<div class="pad-t-25 pad-b-15 pad-r-30 pos-relate br-bottom1 ub ub-ac ub-pj">
					<label class="fc-dgrey">身份：</label>
					<div class="ub-f1 text-right identity-select">
						<div>
							<span class="fc-blue lawyer" value="">请选择</span>
							<span class="icon icon-left5 icon-down-blue"></span>
						</div>
						<select>
							<option value="0">正式律师</option>
							<option value="1">实习律师</option>
						</select>
					</div>
				</div>
				<div class="pad-t-25 pad-b-15 pad-r-30 pos-relate br-bottom1 ub ub-ac">
					<label class="fc-dgrey">姓名：</label>
					<input type="text" name="realName" class="pad-lr-10 ub-f1 form-control">
				</div>
				<div class="pad-t-25 pad-b-15 pad-r-30 pos-relate br-bottom1 ub ub-ac">
					<label class="fc-dgrey">律所：</label>
					<input type="text" name="office" class="pad-lr-10 ub-f1 form-control">
				</div>
				<div class="pad-t-25 pad-b-15 pad-r-30 pos-relate br-bottom1 ub ub-ac">
					<label class="fc-dgrey">执业证号：</label>
					<input type="text" name="certNum" class="pad-lr-10 ub-f1 form-control">
				</div>
			</form>
			<div class="pad-l-30 mar-t-20 fs-12 fc-xlgrey clear">
				<div class="pull-left radio-box">
					<span class="radio icon icon-radio1 icon-top1 on" data-radio="read" data-value="0"></span>
					<span class="mar-l-10 fs-12 fc-xxxxlgrey">已阅读并同意</span>
				</div>
				<a href="#" class="pull-left fc-blue btn-toxy" >《协议与帮助》</a>
				<input type="hidden" name="read" data-type="read">
			</div>
			<a href="#" class="mar-lr-30 mar-tb-35 btn-blue block fs-20 btn-register">注册</a>
		</div>
		<div class="pad-lr-30 fs-12 fc-xxxxlgrey text-center register-bottom">
			<p class="line-height24">提示：无法注册请致电客服：<a href="tel:020-29030607" class="fc-blue">020-29030607</a></p>
		</div>
	</div>    
  	<script type="text/javascript" src="${contextPath}/static/js/jquery-1.12.0.min.js"></script>
  	<script type="text/javascript" src="${contextPath}/static/weixin/common/js/toast.js"></script>
  	<script type="text/javascript" src="${contextPath}/static/weixin/sb/js/main.js"></script>
 	<script type="text/javascript" src="${contextPath}/static/weixin/cd/js/util.js"></script>
 	
 	<script type="text/javascript">
	 	$(document).ready(function() {
	 		// 选择诉讼阶段
			$('.online-letter-step').click(function(event) {
				var $layout = $('.modal-layout1[data-target=online-letter-step]'); 
				var $item = $layout.find('.modal-radio-list li');
				$layout.removeClass('hide').find('.modal-wrapper1').addClass('animated');
				$item.on('click',function(){
					var _this = $(this);
					var txt = _this.text();
					var val_Type=_this.attr("attr-val");
					$layout.addClass('hide');
					$layout.find('.modal-wrapper1').removeClass('animated');
					$('.online-letter-step').val(txt);
					$('.online-letter-step').attr("attr-val",val_Type);
					$item.off('click');
				});
			});
			$('.modal-layout1').click(function(event) {
				var _this = $(this);
				_this.addClass('hide');
				_this.find('.modal-wrapper1').removeClass('animated')
				_this.find('.guarantee-modal-list').slideToggle('600');
			});
			
			//注册
			$('.identity-select select').change(function(){
				var _this = $(this);
				var _text = _this.find('option:selected').text();
				$('.lawyer').text(_text);
				$('.lawyer').attr('value', _text);
			});
			$('.btn-register').click(function(){
				var phone = $('input[name="phone"]').val();
				var code = $('input[name="code"]').val();
				var password = $('input[name="password"]').val();
				var idenity = $('.lawyer').attr('value');
				var realName = $('input[name="realName"]').val();
				var office = $('input[name="office"]').val();
				var certNum = $('input[name="certNum"]').val();
				var text = /\S{6,16}/;
				if (phone == '' || phone == 'undefined') {
					toast1.alert('请填写手机号');
					return false;
				}
				if (code == '' || code == 'undefined') {
					toast1.alert('请填写验证码');
					return false;
				}
				if (password == '' || password == 'undefined') {
					toast1.alert('请填写密码');
					return false;
				}
				if (!text.test(password)) {
					toast1.alert('密码应为6-16位');
					return false;
				}
				if (idenity == '' || idenity == 'undefined') {
					toast1.alert('请填写身份');
					return false;
				}
				if (realName == '' || realName == 'undefined') {
					toast1.alert('请填写姓名');
					return false;
				}
				if (office == '' || office == 'undefined') {
					toast1.alert('请填写律所');
					return false;
				}
				if (certNum == '' || certNum == 'undefined') {
					toast1.alert('执请填写业证号');
					return false;
				}
				
				var b002Req={
			  		mobile: phone,
			  		password: password,
			  		code: code,
			  		lawyerType : idenity=='正式律师'?0:1,
			  		office : office,
			  		certNum : certNum,
			  		realName : realName,
			  		actionCode:"B002"
				};
		  		var url="${contextPath}/B/android/";
		  		postData(url,JSON.stringify(b002Req),b002Succ,fail);
			});
			
	  		$("#toLogin").click(function(){
				window.location.href="${contextPath}/wx/toLogin";
	  		});
	  		
	  		$("#getValidCode").click(function(){
				var phone = $('input[name="phone"]').val();
				if(!checkPhone(phone)){
					return false;
				}else{
					var b007 = {
						actionCode:"B007",
						mobile:phone,
						type:21				
		  			}
			  		postData("${contextPath}/B/android/", JSON.stringify(b007), b007Succ, fail);
				}
	  		});
	  		$(".btn-toxy").attr("href", "${contextPath}/wx/toCdxy");	  		
	 	});

	 	function b007Succ(data){
	 		if(data){
	 			if(data.success){
	 				$("#djs").removeClass('hide').show();
	 				$("#getValidCode").addClass('hide');
	 				codeTimer($("#djs"));
	 				toast1.alert('验证码发送成功！');
	 			}else{
	 				toast1.alert(data.message);
	 			}			
	 		}else{
	 			toast1.alert('网络异常！');
	 		}
	 	}
	 	function codeTimer(obj,str){
			var time = obj.text().slice(3,-2);
			time = parseInt(time);
			time-=1;
			if(time<10){
				time = "0" + time;
			}
			obj.text("重获("+time+"秒)");
			if(time == 0){
 				$("#getValidCode").removeClass("hide").show();
	  			$("#djs").addClass('hide').html("重获("+60+"秒)");
				return;
			}
			setTimeout(function(){
				codeTimer(obj,obj.text());
			},1000);
		}
	 	
		/*获取验证码按钮*/	 	
	 	function b002Succ(json){
			if(json){
				if(json.success){
					toast1.alert('注册成功');							
					setTimeout(function(){
						window.location.href="${contextPath}/wx/toLogin";
			        },2000);
				}else{
					toast1.alert(json.message);	
				}
			}else{
				toast1.alert("网络异常");	
			}
		}
		function fail(resp){
			console.log(resp);
		}
		
		function checkPhone(phone){ 
			if(phone){
				if(!(/^1[3|4|5|7|8]\d{9}$/.test(phone))){ 
					toast1.alert("手机号码有误，请重填");
					return false; 
				}else{
					return true;
				}
			}else{
				toast1.alert("请输入手机号码");
				return false;
			}
		}
		
		//toast
		var toast1 = new toast({
	        pos:'center'
	    });	
	</script>
</body>
</html>