luyanan 8 年 前
コミット
3079c905f9
共有6 個のファイルを変更した275 個の追加16 個の削除を含む
  1. 1 0
      app/css/app.css
  2. 10 12
      app/html/reg.html
  3. 3 4
      app/html/setpass.html
  4. 3 0
      app/js/public/base.js
  5. 80 0
      app/js/register-setpass.js
  6. 178 0
      app/js/register.js

+ 1 - 0
app/css/app.css

@ -59,6 +59,7 @@ body{ color: #666666; font-size:14px;}
59 59
/*.frmbtn:hover{border:1px solid #FF9900; color:#FFFFFF;background-color:#FF9900;}*/
60 60
.frmbox{ border:none; width: 90%; height: 100%; }
61 61
.frmactive{color:#fff;background-color:#FF9900;}
62
.frmactive2{color:#fff;background-color:#ccc; border:1px solid #ccc;}
62 63

63 64
.exitbtn{ border:none; margin: 0; color:#FF0000; border-radius: 0;}
64 65
/*///////////////common公共样式///////////////////////*/

+ 10 - 12
app/html/reg.html

@ -20,13 +20,14 @@
20 20
					<img class="logoimg" src="../images/logo.png" />
21 21
				</a>
22 22
			</div>
23
		    <form class="mui-input-group frmbox">
23
		    <form class="mui-input-group frmbox" id="frmbox">
24 24
		        <div class="mui-input-row frm-input">
25
		            <input type="text" class="mui-input-clear frmtype" placeholder="请输入您的手机号">
25
		            <input type="tel" class="mui-input-clear frmtype" placeholder="请输入您的手机号" id="username">
26 26
		        </div>
27 27
		        <div class="mui-input-row frm-input">
28
					<input id='password' type="password" class="mui-input-clear frmtype" placeholder="请输入验证码">
29
					<a class="forgetword">获取验证码</a>
28
					<input type="number" class="mui-input-clear frmtype" placeholder="请输入验证码" id="set-code">
29
					<a class="forgetword" id="obtain-code">获取验证码</a>
30
					<a class="forgetword" id="getcodeoff" style="display:none;"></a>
30 31
				</div>
31 32
		    </form>
32 33
		    
@ -39,20 +40,17 @@
39 40
	                     <input type="checkbox" name="checkbox" checked="true" style="display:none;">已同意<a href="" class="protocollink" target="_blank">科袖网用户协议</a>
40 41
	               </label>
41 42
		    	</div>
42
					
43
					
44
				
45
		    	<button id='reg' class="mui-btn mui-btn-block frmbtn frmactive">注&nbsp;册</button>
43
			
44
		    	<button id='reg' class="mui-btn mui-btn-block frmbtn frmactive" style="display:none;">注&nbsp;册</button>
45
		    	<button class="mui-btn mui-btn-block frmbtn frmactive2">注&nbsp;册</button>
46 46
				<button id='login' class="mui-btn mui-btn-block mui-btn-outlined frmbtn">返回登录</button>
47 47
				
48 48
			</div>
49 49
			
50 50
		</div>
51
		
52 51
		<script src="../js/public/mui.min.js"></script>
53
		<script type="text/javascript">
54
			mui.init()
55
		</script>
52
		<script src="../js/public/base.js"></script>
53
		<script src="../js/register.js"></script>
56 54
	</body>
57 55
58 56
</html>

+ 3 - 4
app/html/setpass.html

@ -28,14 +28,13 @@
28 28
			    </form>
29 29
			    
30 30
			    <div class="mui-content-padded frmbox">
31
					<button class="mui-btn mui-btn-block frmbtn frmactive">完&nbsp;成</button>
31
					<button class="mui-btn mui-btn-block frmbtn frmactive" id="registerok">完&nbsp;成</button>
32 32
				</div>
33 33
			</div>
34 34
		</div>
35 35
		<script src="../js/public/mui.min.js"></script>
36
		<script type="text/javascript">
37
			mui.init()
38
		</script>
36
		<script src="../js/public/base.js"></script>
37
		<script src="../js/register-setpass.js"></script>
39 38
	</body>
40 39
41 40
</html>

+ 3 - 0
app/js/public/base.js

@ -0,0 +1,3 @@
1
//公共文件
2
var baseUrl="http://192.168.3.173:8080",
3
    toastStyle={'verticalAlign':'top'}

+ 80 - 0
app/js/register-setpass.js

@ -0,0 +1,80 @@
1
//注册信息设置密码
2
mui.init();
3
mui.plusReady(function(){
4
	
5
	/*定义全局变量*/
6
	var passWord = document.getElementById("password");
7
	var passwordOK = document.getElementById("password2");
8
	var registerOk = document.getElementById("registerok");
9
	var oldPass = false;
10
	var isPass = false;
11
	var self=plus.webview.currentWebview();
12
	
13
	/*校验第一个密码*/
14
	passWord.addEventListener('blur', function() {
15
		valOld();
16
	});
17
	
18
	/*校验确认密码*/
19
	passwordOK.addEventListener('blur', function() {
20
		valNew();
21
	});
22
	
23
	//完成注册
24
	registerOk.addEventListener('tap', function() {
25
		completeReg();
26
	});
27
    
28
	function valOld(){
29
		if(passWord.value.length==0){
30
			plus.nativeUI.toast("密码不能为空",toastStyle);
31
			oldPass = false;
32
		}else if(passWord.value.length < 6){
33
			plus.nativeUI.toast("密码不少于6位,请输入正确的密码",toastStyle);
34
		}else{
35
			oldPass = true;
36
		}
37
	}
38
	
39
	function valNew(){
40
		if(passwordOK.value.length==0){
41
			plus.nativeUI.toast("密码不能为空",toastStyle);
42
			isPass = false;
43
		}else if(passwordOK.value.length<6){
44
			plus.nativeUI.toast("密码长度过短,至少六位",toastStyle);
45
			isPass = false;
46
		}else if(passwordOK.value != passWord.value){
47
			plus.nativeUI.toast("两次密码不一致",toastStyle);
48
			isPass = false;
49
		}else{
50
			isPass = true;
51
		}
52
	}
53
	
54
	function completeReg(){
55
		if(oldPass&&isPass){
56
			mui.ajax(baseUrl+'/ajax/regmobile',{
57
				data:{state:self.state,mobilePhone:self.phoneName,validateCode:self.setCode,password:passwordOK.value},
58
				dataType: 'json', //数据格式类型
59
				type: 'post', //http请求类型
60
				async: false,
61
				timeout: 10000, //超时设置
62
				success: function(data) {
63
						console.log(data)
64
					if(data.success) {
65
						state=data.data;
66
						console.log(state)
67
						plus.nativeUI.toast("注册成功",toastStyle);
68
					}
69
				},
70
				error: function() {
71
						plus.nativeUI.toast("服务器链接超时",toastStyle);
72
				}
73
			});	
74
		}else{
75
			valOld();
76
			valNew();
77
		}
78
	}
79
	
80
})

+ 178 - 0
app/js/register.js

@ -0,0 +1,178 @@
1
//注册信息
2
mui.init();
3
mui.plusReady(function(){
4
	
5
	/*定义全局变量*/
6
	var phoneName = document.getElementById("username");
7
	var setCode = document.getElementById("set-code");
8
	var obtainCode = document.getElementById("obtain-code");
9
	var reg = document.getElementById("reg");
10
	var phoneCode=false;
11
	var codeVal2 = false;
12
	var state = 0;
13
		
14
	phoneName.addEventListener('blur', function() {
15
		phoneVal();
16
	});
17
	
18
	setCode.addEventListener('blur', function() {
19
		codeVal();
20
	});
21

22
	/*点击获取验证码*/
23
	obtainCode.addEventListener('tap',function(){
24
		//console.log(phoneCode)
25
		sendAuthentication();
26
	})
27
	
28
	/*注册按钮*/
29
	reg.addEventListener('tap',function(){
30
		if(phoneCode&&codeVal2){
31
			mui.openWindow({
32
      			url:'setpass.html',
33
      			id:'setpass.html',
34
      			extras:{
35
					phoneName:phoneName.value,
36
					setCode:setCode.value,
37
					state:state
38
				}
39
      		});	
40
		}else{
41
			phoneVal();
42
			codeVal();	
43
		}
44
	})
45
	
46
	/*校验手机号*/
47
	function phoneVal(){
48
		var hunPhone=/^1[3|4|5|7|8]\d{9}$/;
49
		if(phoneName.value.length==0){
50
			plus.nativeUI.toast("手机号不能为空",toastStyle)
51
			document.querySelector('.frmactive').style.display="none";
52
			document.querySelector('.frmactive2').style.display="block";
53
			phoneCode=false;
54
      	}else{
55
			if(hunPhone.test(phoneName.value)){
56
				isReg(); 
57
			}else{
58
				plus.nativeUI.toast("请输入正确的手机号码",toastStyle);
59
				phoneCode=false;
60
			}
61
		}
62
	}
63
	
64
	/*校验用户名是否注册*/
65
	function isReg() {
66
		mui.ajax(baseUrl+'/ajax/isReg?key='+phoneName.value,{
67
			dataType: 'json', //数据格式类型
68
			type: 'GET', //http请求类型
69
			timeout: 10000, //超时设置
70
			success: function(data) {
71
				if(data.data == false) {
72
					//mui.back();
73
					phoneCode=false;
74
					//alert(phoneCode);
75
					plus.nativeUI.toast("您的手机已被注册",toastStyle);
76
				}else{
77
					//plus.nativeUI.toast(phoneCode,toastStyle);
78
					phoneCode=true;
79
					return phoneCode; 
80
				}
81
			},
82
			error: function() {
83
					plus.nativeUI.toast("服务器链接超时",toastStyle);
84
					phoneCode=false;
85
					
86
			}
87
		})
88
	}
89

90
	/*手机发送验证码*/
91
	function sendAuthentication(){
92
		console.log(phoneCode)
93
		if(phoneCode){
94
			mui.ajax(baseUrl+'/ajax/regmobilephone',{
95
				data:{mobilePhone:phoneName.value},
96
				dataType: 'json', //数据格式类型
97
				type: 'GET', //http请求类型
98
				async: false,
99
				timeout: 10000, //超时设置
100
				success: function(data) {
101
					if(data.success) {
102
						state=data.data;
103
						console.log(state)
104
						doClick();
105
					}
106
				},
107
				error: function() {
108
						plus.nativeUI.toast("服务器链接超时",toastStyle);
109
				}
110
			})
111
		}
112
	}
113
	
114
	/*30s后重新获取验证码*/
115
	function doClick() {
116
		var getCodeOff = document.getElementById("getcodeoff");
117
		obtainCode.style.display = "none";
118
		getCodeOff.style.display = "block";
119
		getCodeOff.innerHTML = "30s后重新获取";
120
		var clickTime = new Date().getTime();
121
		var Timer = setInterval(function() {
122
			var nowTime = new Date().getTime();
123
			var second = Math.ceil(30 - (nowTime - clickTime) / 1000);
124
			if(second > 0) {
125
				getCodeOff.innerHTML = second + "s后重新获取";
126
			} else {
127
				clearInterval(Timer);
128
			    obtainCode.style.display = "block";
129
				getCodeOff.style.display = "none";
130
				obtainCode.innerHTML = "获取验证码";
131
			}
132
		}, 1000);
133
	}
134
	
135
	/*校验验证码*/
136
	function codeVal(){
137
		//console.log(state)
138
		if(setCode.value.length==0){
139
			plus.nativeUI.toast("验证码不能为空",toastStyle);
140
			codeVal2 = false;
141
			document.querySelector('.frmactive').style.display="none";
142
			document.querySelector('.frmactive2').style.display="block";
143
      	}else{
144
      		document.querySelector('.frmactive2').style.display="none";
145
		    document.querySelector('.frmactive').style.display="block";
146
      		mui.ajax(baseUrl+'/ajax/validCode',{
147
				data:{"state":state,"vc":setCode.value},
148
				dataType: 'json', //数据格式类型
149
				async: false,
150
				type: 'POST', //http请求类型
151
				timeout: 10000, //超时设置
152
				success: function(data) {
153
					console.log(data.data);
154
					if(data.success){
155
						console.log(data.success);
156
						if(data.data){
157
							//plus.nativeUI.toast("验证码输入正确",toastStyle);
158
							codeVal2 = true;
159
						}else{
160
							plus.nativeUI.toast("验证码不正确",toastStyle);
161
							codeVal2 = false;
162
						}
163
					}else{
164
						plus.nativeUI.toast("验证超时",toastStyle);
165
						codeVal2 = false;
166
						console.log(data.msg);
167
					}
168
				},
169
				error: function() {
170
						plus.nativeUI.toast("服务器链接超时",toastStyle);
171
						codeVal2 = false;
172
				}
173
			})
174
      	}
175
	}
176
	
177
	
178
})