Browse Source

新注册

xuchunyang 8 years ago
parent
commit
be96b6da0f
2 changed files with 94 additions and 47 deletions
  1. 24 23
      app/html/reg.html
  2. 70 24
      app/js/register.js

+ 24 - 23
app/html/reg.html

11
	</head>
11
	</head>
12
12
13
	<body>
13
	<body>
14
		<div class="closebtn mui-action-back">
15
			<span class="mui-icon mui-icon-closeempty closeicon"></span>
16
			<!--<div class="closeicon"></div>-->
17
		</div>
14
		<header class="mui-bar mui-bar-nav toptitbox">
15
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left topback"></a>
16
		    <h1 class="mui-title toptit">注册</h1>
17
		</header>
18
		<div class="mui-content">
18
		<div class="mui-content">
19
			<div class="logobox">
20
				<a class="logolink">
21
					<img class="logoimg" src="../images/logo.png" />
22
				</a>
23
			</div>
24
		    <form class="mui-input-group frmbox" id="frmbox">
25
		        <div class="mui-input-row frm-input">
26
		            <input type="tel" class="mui-input-clear frmtype" placeholder="请输入您的手机号" id="username">
19
		    <form class="mui-input-group frmboxNew">
20
		    	<div class="mui-input-row frm-input">
21
		            <input type="text" class="mui-input-clear frmtype" placeholder="请输入真实姓名" id="name">
27
		        </div>
22
		        </div>
28
		        <div class="mui-input-row frm-input">
23
		        <div class="mui-input-row frm-input">
29
					<input type="number" class="frmtype" placeholder="请输入验证码" id="set-code">
30
					<span class="forgetword forgetword2" id="obtain-code">获取验证码</span>
31
					<span class="forgetword" id="getcodeoff" style="display:none;"></span>
24
		            <input type="tel" class="mui-input-clear frmtype" placeholder="请输入手机号" id="username">
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="set-code">
29
		        	</div>
30
					<div class="mui-col-xs-4">
31
						<input type="button" class="frmtype getCode" value="获取验证码" id="obtain-code">
32
						<input type="button" class="frmtype getCode" value="" style="display: none;" id="getcodeoff">
33
					</div>
34
				</div>
35
				<div class="mui-input-row frm-input">
36
					<input id='setpassword' type="password" class="frmtype" placeholder="请设置登录密码">
32
				</div>
37
				</div>
33
		    </form>
38
		    </form>
34
		    
39
		    
35
		    <div class="mui-content-padded frmbox">
40
		    <div class="mui-content-padded frmboxNew" style="margin-top: -4px">
36
		    	<div class="protocolbox">
41
		    	<div class="protocolbox">
37
			    	<label checked="true"> 
42
			    	<label checked="true"> 
38
			    		<span class="mui-icon iconfont icon-squarecheck iconagreecheck"></span>	
39
	                     <!--<em><img class="agreeicon" src="../images/agreenicon.png"/></em> -->
40
	                    <input type="checkbox" name="checkbox" checked="true" style="display:none;">已同意<a href="" class="protocollink" target="_blank" id="protocollink">科袖网用户协议</a>
43
			    		<span class="mui-icon iconfont icon-yuanxingxuanzhongfill"></span>	
44
	                    <input type="checkbox" name="checkbox" checked="true" style="display:none;">我已阅读并同意<a class="protocollink" id="protocollink">科袖网用户协议</a>
41
	               </label>
45
	               </label>
42
		    	</div>
46
		    	</div>
43
			
44
		    	<button id='reg' class="mui-btn mui-btn-block frmbtn frmactive2" >注&nbsp;册</button>
45
				<button id='login' class="mui-btn mui-btn-block mui-btn-outlined frmbtn">返回登录</button>
46
				
47
				<button class="mui-btn mui-btn-block frmbtn frmactive2" id='reg' disabled>注&nbsp;册</button>
47
			</div>
48
			</div>
48
			
49
			
49
		</div>
50
		</div>

+ 70 - 24
app/js/register.js

2
mui.ready(function() {
2
mui.ready(function() {
3
	
3
	
4
	/*定义全局变量*/
4
	/*定义全局变量*/
5
	var name = document.getElementById("name");
5
	var phoneName = document.getElementById("username");
6
	var phoneName = document.getElementById("username");
6
	var setCode = document.getElementById("set-code");
7
	var setCode = document.getElementById("set-code");
7
	var obtainCode = document.getElementById("obtain-code");
8
	var obtainCode = document.getElementById("obtain-code");
9
	var setpassword = document.getElementById("setpassword");
8
	var reg = document.getElementById("reg");
10
	var reg = document.getElementById("reg");
9
	var login = document.getElementById("login");
10
	var protocollink = document.getElementById("protocollink");
11
	var protocollink = document.getElementById("protocollink");
11
	var phoneCode = false;
12
	var phoneCode = false;
12
	var state = 0;
13
	var state = 0;
13
	
14
	
14
	mui.plusReady(function() {
15
	mui.plusReady(function() {
15

16

16
		/*点击登录页面*/
17
		login.addEventListener('tap', function() {
18
			goLoginFun();
19
		})
20

21
		/*校验提交按钮显示状态*/
17
		/*校验提交按钮显示状态*/
22
		mui('.frmbox').on('keyup', "#username,#set-code", function() {
23
			hideButtn(phoneName,setCode,reg,"frmactiveok");
18
		mui('.frmboxNew').on('keyup', "#name,#username,#set-code,#setpassword", function() {
19
			if(name.value == "" || phoneName.value == "" || setCode.value == "" || setpassword.value == "") {
20
				reg.classList.remove("frmactiveok");
21
				reg.disabled = "disabled";
22
			} else {
23
				reg.classList.add("frmactiveok");
24
				reg.disabled = "";
25
			}
24
		});
26
		});
25

27

26
		/*点击获取验证码*/
28
		/*点击获取验证码*/
43
				}
45
				}
44
			});
46
			});
45
		});
47
		});
46
	
48
		
49
		/*校验真实姓名和密码*/
50
		function valOld() {
51
			var nameval = /^\w{0,20}$/;
52
			if(nameval.test(name.value)) {
53
				plus.nativeUI.toast("姓名最长为10个汉字或20个英文字符", toastStyle);
54
				return;
55
			} else if(setpassword.value.length < 6){
56
				plus.nativeUI.toast("密码由6-24个字符组成,区分大小写", toastStyle);
57
				return;
58
			}else{
59
				completeReg();
60
			}
61
		}
62
		
47
		/*校验手机号*/
63
		/*校验手机号*/
48
		function phoneVal() {
64
		function phoneVal() {
49
			var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
65
			var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
63
				timeout: 10000, //超时设置
79
				timeout: 10000, //超时设置
64
				success: function(data) {
80
				success: function(data) {
65
					if(data.data == false) {
81
					if(data.data == false) {
66
						plus.nativeUI.toast("您的手机已被注册", toastStyle);
82
						plus.nativeUI.toast("该账号已存在,请直接登录", toastStyle);
67
						return;
83
						return;
68
					} else {
84
					} else {
69
						phoneCode = true;
85
						phoneCode = true;
81

97

82
		/*手机发送验证码*/
98
		/*手机发送验证码*/
83
		function sendAuthentication() {
99
		function sendAuthentication() {
100
			console.log("send code")
84
			mui.ajax(baseUrl + '/ajax/regmobilephone', {
101
			mui.ajax(baseUrl + '/ajax/regmobilephone', {
85
				data: {
102
				data: {
86
					mobilePhone: phoneName.value
103
					mobilePhone: phoneName.value
90
				async: false,
107
				async: false,
91
				timeout: 10000, //超时设置
108
				timeout: 10000, //超时设置
92
				success: function(data) {
109
				success: function(data) {
110
					console.log(JSON.stringify(data))
93
					if(data.success) {
111
					if(data.success) {
94
						state = data.data;
112
						state = data.data;
95
						doClick();
113
						doClick();
107
			var getCodeOff = document.getElementById("getcodeoff");
125
			var getCodeOff = document.getElementById("getcodeoff");
108
			obtainCode.style.display = "none";
126
			obtainCode.style.display = "none";
109
			getCodeOff.style.display = "block";
127
			getCodeOff.style.display = "block";
110
			getCodeOff.innerHTML = "30s后重新获取";
128
			getCodeOff.value = "30s后重新获取";
111
			var clickTime = new Date().getTime();
129
			var clickTime = new Date().getTime();
112
			var Timer = setInterval(function() {
130
			var Timer = setInterval(function() {
113
				var nowTime = new Date().getTime();
131
				var nowTime = new Date().getTime();
114
				var second = Math.ceil(30 - (nowTime - clickTime) / 1000);
132
				var second = Math.ceil(30 - (nowTime - clickTime) / 1000);
115
				if(second > 0) {
133
				if(second > 0) {
116
					getCodeOff.innerHTML = second + "s后重新获取";
134
					getCodeOff.value = second + "s后重新获取";
117
				} else {
135
				} else {
118
					clearInterval(Timer);
136
					clearInterval(Timer);
119
					obtainCode.style.display = "block";
137
					obtainCode.style.display = "block";
120
					getCodeOff.style.display = "none";
138
					getCodeOff.style.display = "none";
121
					obtainCode.innerHTML = "获取验证码";
139
					obtainCode.value = "获取验证码";
122
				}
140
				}
123
			}, 1000);
141
			}, 1000);
124
		}
142
		}
138
					console.log(data.success);
156
					console.log(data.success);
139
					if(data.success) {
157
					if(data.success) {
140
						if(data.data) {
158
						if(data.data) {
141
							mui.openWindow({
142
								url: 'setpass.html',
143
								id: 'setpass.html',
144
								extras: {
145
									phoneName: phoneName.value,
146
									setCode: setCode.value,
147
									state: state
148
								}
149
							});
159
							valOld();
150
						}else{
160
						}else{
151
							plus.nativeUI.toast("验证码不正确", toastStyle);
161
							plus.nativeUI.toast("验证码错误,请检查后重试", toastStyle);
152
							return;
162
							return;
153
						}
163
						}
154
					}else{
164
					}else{
155
						console.log(data.msg);
165
						console.log(data.msg);
156
						if(data.msg=="验证超时"){
166
						if(data.msg=="验证超时"){
157
							plus.nativeUI.toast("验证码超时", toastStyle);
167
							plus.nativeUI.toast("验证码已过期,请重新获取", toastStyle);
158
							return;
168
							return;
159
						}else{
169
						}else{
160
							plus.nativeUI.toast("请填写正确的手机号,验证码", toastStyle);
170
							plus.nativeUI.toast("请填写正确的手机号,验证码", toastStyle);
170
			})
180
			})
171
		}
181
		}
172

182

183
		//注册提交
184
		function completeReg() {
185
			mui.ajax(baseUrl + '/ajax/mobileReg', {
186
				data: {
187
					state: state,
188
					mobilePhone: phoneName.value,
189
					validateCode: setCode.value,
190
					password: setpassword.value,
191
					name:name.value
192
				},
193
				dataType: 'json', //数据格式类型
194
				type: 'post', //http请求类型
195
				//async: false,
196
				success: function(data) {
197
					if(data.success) {
198
						var userId = data.data;
199
						plus.storage.setItem('userid', userId);
200
						plus.nativeUI.toast("已完成注册,请填写个人信息", toastStyle);
201
						mui.openWindow({
202
							url: 'fillinfo.html',
203
							id: 'fillinfo.html',
204
							extras: {
205
								userid: userId
206
							},
207
							show: {
208
								aniShow: "slide-in-right"
209
							}
210
						});
211
					}
212
				},
213
				error: function() {
214
					plus.nativeUI.toast("服务器链接超时", toastStyle);
215
				}
216
			});
217
		}
218
		
173
	});
219
	});
174
});
220
});