浏览代码

注册添加图形验证码

luyanan 7 年之前
父节点
当前提交
45556338fe
共有 2 个文件被更改,包括 43 次插入8 次删除
  1. 8 0
      app/html/reg.html
  2. 35 8
      app/js/register.js

+ 8 - 0
app/html/reg.html

23
		        <div class="mui-input-row frm-input">
23
		        <div class="mui-input-row frm-input">
24
		            <input type="tel" class="mui-input-clear frmtype" placeholder="请输入手机号码" id="username">
24
		            <input type="tel" class="mui-input-clear frmtype" placeholder="请输入手机号码" id="username">
25
		        </div>
25
		        </div>
26
		        <div class="mui-row mui-input-row frm-input">
27
		        	<div class="mui-col-xs-8">
28
		        		<input type="tel" class="frmtype" placeholder="请输入图形验证码" id="imgCode">
29
		        	</div>
30
					<div class="mui-col-xs-4">
31
						<img src="http://www.ekexiu.com/ajax/PictureVC" alt="" id="changImage" width="100%" height="48"/>
32
					</div>
33
				</div>
26
		        <div class="mui-row mui-input-row frm-input">
34
		        <div class="mui-row mui-input-row frm-input">
27
		        	<div class="mui-col-xs-8">
35
		        	<div class="mui-col-xs-8">
28
		        		<input type="tel" class="frmtype" placeholder="请输入验证码" id="set-code">
36
		        		<input type="tel" class="frmtype" placeholder="请输入验证码" id="set-code">

+ 35 - 8
app/js/register.js

9
	var setpassword = document.getElementById("setpassword");
9
	var setpassword = document.getElementById("setpassword");
10
	var reg = document.getElementById("reg");
10
	var reg = document.getElementById("reg");
11
	var protocollink = document.getElementById("protocollink");
11
	var protocollink = document.getElementById("protocollink");
12
	var imgCode = document.getElementById("imgCode");
13
	var changImage = document.getElementById("changImage")
12
	var phoneCode = false;
14
	var phoneCode = false;
13
	var state = 0;
15
	var state = 0;
14
	
16
	
15
	mui.plusReady(function() {
17
	mui.plusReady(function() {
16

18

17
		/*校验提交按钮显示状态*/
19
		/*校验提交按钮显示状态*/
18
		mui('.frmboxNew').on('keyup', "#name,#username,#set-code,#setpassword", function() {
19
			if(name.value == "" || phoneName.value == "" || setCode.value == "" || setpassword.value == "") {
20
		mui('.frmboxNew').on('keyup', "#name,#username,#imgCode,#set-code,#setpassword", function() {
21
			if(name.value == "" || phoneName.value == "" || imgCode.value == "" || setCode.value == "" || setpassword.value == "") {
20
				reg.classList.remove("frmactiveok");
22
				reg.classList.remove("frmactiveok");
21
				reg.disabled = "disabled";
23
				reg.disabled = "disabled";
22
			} else {
24
			} else {
51
				plus.nativeUI.toast("请输入正确的手机号码", toastStyle);
53
				plus.nativeUI.toast("请输入正确的手机号码", toastStyle);
52
				return;
54
				return;
53
			}
55
			}
56
			if(imgCode.value.length==0) {
57
				plus.nativeUI.toast("请输入图形验证码", toastStyle);
58
				return;
59
			}else if(imgCode.value.length==4){
60
				
61
			}else{
62
				plus.nativeUI.toast("图形验证码4位", toastStyle);
63
				return;
64
			}
54
			if(!oNum.test(setCode.value)) {
65
			if(!oNum.test(setCode.value)) {
55
				plus.nativeUI.toast("验证码为4位数字", toastStyle);
66
				plus.nativeUI.toast("验证码为4位数字", toastStyle);
56
				return;
67
				return;
59
				plus.nativeUI.toast("密码由6-24个字符组成,区分大小写", toastStyle);
70
				plus.nativeUI.toast("密码由6-24个字符组成,区分大小写", toastStyle);
60
				return;
71
				return;
61
			}
72
			}
62
			isReg(1);
73
//			isReg(1);
74
			isReg();
63
		})
75
		})
64
		
76
		
65
		/*用户协议*/
77
		/*用户协议*/
73
			});
85
			});
74
		});
86
		});
75
		
87
		
88
		changImage.addEventListener("tap",function(){
89
			this.setAttribute("src","http://www.ekexiu.com/ajax/PictureVC?"+new Date().getTime());
90
		})
76
		/*校验手机号*/
91
		/*校验手机号*/
77
		function phoneVal() {
92
		function phoneVal() {
78
			var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
93
			var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
96
						plus.nativeUI.toast("该账号已存在,请直接登录", toastStyle);
111
						plus.nativeUI.toast("该账号已存在,请直接登录", toastStyle);
97
						return;
112
						return;
98
					} else {
113
					} else {
99
						if(oArg==1){	
114
						if(oArg==1){
100
							codeVal();
115
							codeVal();
101
						}else{	
116
						}else{	
102
							phoneCode = true;
117
							phoneCode = true;
115

130

116
		/*手机发送验证码*/ 
131
		/*手机发送验证码*/ 
117
		function sendAuthentication() {
132
		function sendAuthentication() {
118
			console.log("send code")
119
			mui.ajax(baseUrl + '/ajax/regmobilephone_onlyphone', {
133
			console.log(phoneName.value)
134
			console.log(imgCode.value)
135
			mui.ajax(baseUrl + '/ajax/regmobilephone', {
120
				data: {
136
				data: {
121
					mobilePhone: phoneName.value
137
					mobilePhone: phoneName.value,
138
					vcode: imgCode.value
122
				},
139
				},
123
				dataType: 'json', //数据格式类型
140
				dataType: 'json', //数据格式类型
124
				type: 'GET', //http请求类型
141
				type: 'GET', //http请求类型
129
					if(data.success) {
146
					if(data.success) {
130
						state = data.data;
147
						state = data.data;
131
						doClick();
148
						doClick();
149
					}else{
150
						if(data.code==20001) {
151
							plus.nativeUI.toast("请输入正确的图形验证码", toastStyle);
152
							changImage.setAttribute("src","http://www.ekexiu.com/ajax/PictureVC?"+new Date().getTime());
153
						}
132
					}
154
					}
133
				},
155
				},
134
				error: function() {
156
				error: function() {
158
				}
180
				}
159
			}, 1000);
181
			}, 1000);
160
		}
182
		}
161

162
		/*校验验证码*/
183
		/*校验验证码*/
163
		function codeVal() {
184
		function codeVal() {
164
			mui.ajax(baseUrl + '/ajax/validCode', {
185
			mui.ajax(baseUrl + '/ajax/validCode', {
227
								aniShow: "slide-in-right"
248
								aniShow: "slide-in-right"
228
							}
249
							}
229
						});
250
						});
251
					}else{
252
						if(data.code==-1){
253
							plus.nativeUI.toast("验证码已过期,请重新获取", toastStyle);
254
						}else if(data.code==-2 || data.code==-3 ||data.code==0){
255
							plus.nativeUI.toast("验证码错误,请检查后重试", toastStyle);
256
						}
230
					}
257
					}
231
				},
258
				},
232
				error: function() {
259
				error: function() {