<%@ 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 form-header">
			<a href="javascript:history.back(-1);" class="icon icon-jump"></a>
		</header>
		<div class="login-center">
			<div class="text-center login-logo">
				<img src="${contextPath}/static/weixin/sb/images/logo.png" class="logo">
				<p class="mar-t-20 fc-blue fs-16">律师一站式办公平台</p>
			</div>
			<form class="pad-l-30 login-form">
				<div class="pad-tb-20 pos-relate br-bottom1 ub ub-ac">
					<span class="icon-mobile"></span>
					<input type="tel" name="phone" placeholder="请输入手机号" class="pad-lr-10 ub-f1 form-control">
				</div>
				<div class="mar-t-5 pad-tb-20 pad-r-30 pos-relate br-bottom1 ub ub-ac">
					<span class="icon-password"></span>
					<input type="password" name="password" minlength="6" maxlength="16" placeholder="请输入密码" class="pad-lr-10 ub-f1 form-control">
					<span class="icon icon-unsee btn-password"></span>
				</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>
				<input type="hidden" name="read" data-type="read">
			</div>
			<a href="javascript:void(0);" class="mar-lr-30 mar-t-35 btn-blue block fs-20 btn-login">登录</a>
			<div class="mar-t-20 ub ub-ac ub-pc fs-12 text-center login-link">
				<a id="toRegister" href="javascript:void(0);" class="pos-relate fc-blue">注册多问</a>
				<a id="toFindPasswd" href="javascript:void(0);" class="pos-relate fc-xxxxlgrey">忘记密码</a>
			</div>
		</div>
<!-- 		<div class="pad-lr-30 fs-12 fc-xxxxlgrey login-bottom">
			<p>通知：</p>
			<p class="line-height24">为了打造一个纯粹的律师平台，提供更好的使用体验，多问律师端将于10月31日关闭游客访问模式，只有注册律师才能使用，如有不便请谅解，多问感谢您的支持！</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">
		var baseUrl='<%=com.fadu.app.util.AppConfig.url_duowenapp_b%>';
	 	$(document).ready(function() {
			//登录
	 		$('.btn-login').click(function(){
	 			var phone = $('input[name="phone"]').val();
	 			var password = $('input[name="password"]').val();
	 			var text = /\S{6,16}/;
	 			if (phone == '' || phone == 'undefined') {
	 				toast1.alert('请填写手机号码');
	 				return false;
	 			}
	 			if (password == '' || password == 'undefined') {
	 				toast1.alert('请填写密码');
	 				return false;
	 			}
	 			if (!text.test(password)) {
	 				toast1.alert('密码应为6-16位');
	 				return false;
	 			}
	 			toast1.loadStart('登录中...');
	 			var jsonReq={
		 			name : phone,
			  		password : password,
			  		actionCode:"B001",
			  		dwlsdOpenId:"<%=openid==null?"":openid%>"
		  		};
		  		var url="${contextPath}/wx/login";
		  		postData(url,jsonReq,success,fail);
	 			
	 		});
			
			function success(json){
				if(json){
					if(json.success==true){
						if(json.token){
				 	        toast1.loadFinish('登录成功');							
							setTimeout(function(){
								var loginPreUrl= '<%=preUrl==null?"":preUrl%>';
								if(loginPreUrl && loginPreUrl!=''){
									location.href= '${contextPath}/' + loginPreUrl;
								}else{
									location.href= "${contextPath}/wx/index";
								}
					        },2000);							
						}else{
							toast1.alert("登陆失败！");
						}
					}else{
						toast1.alert(json.message);	
					}
				}else{
					toast1.alert("获取信息失败!!");
				}	
			}
			//顶部圆角按钮操作
			$("#toSearchID").click(function(){
				var url="${contextPath}/web/ssdb/search";
				location.href=url;
			});
			function fail(resp){
				console.log(resp);
			}
			
			$("#toRegister").click(function(){
				location.href="${contextPath}/wx/toRegister";
			});
			
			$("#toFindPasswd").click(function(){
				location.href="${contextPath}/wx/toFindPasswd";
			});  			
		});
	 	
		//toast
		var toast1 = new toast({
	        pos:'center'
	    });		
	</script>
</body>
</html>
