Browse Source

注册,登录,忘记密码,首页

happy 8 years ago
parent
commit
3472b61993
10 changed files with 278 additions and 67 deletions
  1. 11 12
      app/html/findpwd-phone.html
  2. 1 1
      app/index.html
  3. 1 11
      app/js/fillinfo.js
  4. 159 0
      app/js/findpwd1.js
  5. 28 0
      app/js/index.js
  6. 14 3
      app/js/login.js
  7. 4 1
      app/js/myaccount.js
  8. 11 0
      app/js/public/base.js
  9. 32 13
      app/js/register-setpass.js
  10. 17 26
      app/js/register.js

+ 11 - 12
app/html/findpwd-phone.html

@ -16,27 +16,26 @@
16 16
		</header>
17 17
		<div class="mui-content">
18 18
			<div class="setfindbox">
19
			    <form class="mui-input-group frmbox">
19
			    <form class="mui-input-group frmbox" id="ddd">
20 20
			        <div class="mui-input-row frm-input">
21
			            <input type="tel" class="mui-input-clear frmtype" placeholder="请输入已验证的手机号">
21
			            <input type="tel" class="mui-input-clear frmtype" placeholder="请输入已验证的手机号" id="userPhone">
22 22
			        </div>
23
			        <div class="mui-input-row frm-input">
24
						<input type="number" class="mui-input-clear frmtype" placeholder="请输入验证码">
25
						<a class="forgetword">获取验证码</a>
23
			        <div class="mui-input-row frm-input" id="frm-input">
24
						<input type="number" class="mui-input-clear frmtype" placeholder="请输入验证码" id="userCode">
25
						<a class="forgetword" id="obtain-code">获取验证码</a>
26
					    <a class="forgetword" id="getcodeoff" style="display:none;"></a>
26 27
					</div>
27 28
			    </form>
28 29
			    
29
			    <div class="mui-content-padded frmbox">
30
					<button class="mui-btn mui-btn-block frmbtn nexstepbtn">下一步</button>
31
					<span class="nextstep">通过邮箱找回密码<em></em></span>
30
			    <div class="mui-content-padded frmbox" >
31
					<button class="mui-btn mui-btn-block frmbtn frmactive2" id="nextPage" disabled="disabled">下一步</button>
32
					<!--<span class="nextstep">通过邮箱找回密码<em></em></span>-->
32 33
				</div>
33 34
			</div>
34 35
		</div>
35
		
36 36
		<script src="../js/public/mui.min.js"></script>
37
		<script type="text/javascript">
38
			mui.init()
39
		</script>
37
		<script src="../js/public/base.js"></script>
38
		<script src="../js/findpwd1.js"></script>
40 39
	</body>
41 40
42 41
</html>

+ 1 - 1
app/index.html

@ -131,7 +131,7 @@
131 131
        	<div class="maintitbox">
132 132
        		<h4 class="maintit">热门专家</h4>
133 133
        	</div>
134
	        <ul class="mui-table-view protable">
134
	        <ul class="mui-table-view protable" id="indexlist">
135 135
	            <li class="mui-table-view-cell mui-media">
136 136
	                <a class="proinfor" href="html/proinforbrow.html">
137 137
	                    <img class="mui-media-object mui-pull-left headimg" src="images/default-photo.jpg">

+ 1 - 11
app/js/fillinfo.js

@ -15,7 +15,7 @@ mui.ready(function() {
15 15
		
16 16
		/*校验提交按钮显示状态*/
17 17
		mui('.basicinfo').on('keyup', "#userName,#userMechanism", function() {
18
			hideButtn();
18
			hideButtn(userName,userMechanism,goIndex,"frmactiveok");
19 19
		});
20 20

21 21
		/*提交个人信息*/
@ -23,16 +23,6 @@ mui.ready(function() {
23 23
			goVal();
24 24
		});
25 25

26
		function hideButtn() {
27
			if(userName.value == "" || userMechanism.value == "") {
28
				goIndex.classList.remove('frmactiveok');
29
				goIndex.disabled = "disabled";
30
			} else {
31
				goIndex.classList.add('frmactiveok');
32
				goIndex.disabled = "";
33
			}
34
		}
35

36 26
		function goVal() {
37 27
			var $data = {};
38 28
			$data.name = userName.value;

+ 159 - 0
app/js/findpwd1.js

@ -0,0 +1,159 @@
1
//手机找回密码
2
mui.ready(function() {
3
	
4
	/*定义全局变量*/
5
	var userPhone = document.getElementById("userPhone");
6
	var userCode = document.getElementById("userCode");
7
	var nextPage = document.getElementById("nextPage");
8
	var obtainCode = document.getElementById("obtain-code");
9
	var phoneCode = false;
10
	var state = "";
11
	var num;
12
	
13
	mui.plusReady(function(){
14
		
15
		/*校验提交按钮显示状态*/
16
		mui('.frmbox').on('keyup', "#userPhone,#userCode", function() {
17
			hideButtn(userPhone,userCode,nextPage,"frmactiveok");
18
		});
19
		
20
		/*下一步按钮*/
21
		nextPage.addEventListener('tap', function() {
22
			codeVal();
23
		})
24
		
25
		/*点击获取验证码*/
26
		obtainCode.addEventListener('tap', function() {
27
			phoneVal();
28
		})
29
		
30
		/*校验手机号*/
31
		function phoneVal() {
32
			var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
33
			if(hunPhone.test(userPhone.value)) {
34
				isReg();
35
			} else {
36
				plus.nativeUI.toast("请输入正确的手机号码", toastStyle);
37
				return;
38
			}
39
		}
40
		
41
		/*校验用户名是否注册*/
42
		function isReg() {
43
			mui.ajax(baseUrl + '/ajax/isReg?key=' + userPhone.value, {
44
				dataType: 'json', //数据格式类型
45
				type: 'GET', //http请求类型
46
				async: false,
47
				success: function(data) {
48
					console.log(data.data);
49
					if(data.data == false) {
50
						phoneCode = true;
51
						if(phoneCode){
52
							sendAuthentication();
53
						}
54
					} else {
55
						plus.nativeUI.toast("该手机号码未注册账户,请先注册", toastStyle);
56
						return;
57
					}
58
				},
59
				error: function() {
60
					plus.nativeUI.toast("服务器链接超时", toastStyle);
61
				}
62
			});
63
		}
64
		
65
		/*手机发送验证码*/
66
		function sendAuthentication() {
67
			mui.ajax(baseUrl + '/ajax/vcWithRP', {
68
				data: {
69
					mobilePhone: userPhone.value
70
				},
71
				dataType: 'json', //数据格式类型
72
				type: 'GET', //http请求类型
73
				async: false,
74
				success: function(data) {
75
					if(data.success) {
76
						state = data.data;
77
						doClick();
78
						return;
79
					}
80
				},
81
				error: function() {
82
					plus.nativeUI.toast("服务器链接超时", toastStyle);
83
					return;
84
				}
85
			})
86
		}
87

88
		/*30s后重新获取验证码*/
89
		function doClick() {
90
			var getCodeOff = document.getElementById("getcodeoff");
91
			obtainCode.style.display = "none";
92
			getCodeOff.style.display = "block";
93
			getCodeOff.innerHTML = "30s后重新获取";
94
			var clickTime = new Date().getTime();
95
			var Timer = setInterval(function() {
96
				var nowTime = new Date().getTime();
97
				var second = Math.ceil(30 - (nowTime - clickTime) / 1000);
98
				if(second > 0) {
99
					getCodeOff.innerHTML = second + "s后重新获取";
100
				} else {
101
					clearInterval(Timer);
102
					obtainCode.style.display = "block";
103
					getCodeOff.style.display = "none";
104
					obtainCode.innerHTML = "获取验证码";
105
				}
106
			}, 1000);
107
		}
108

109
		/*校验验证码*/
110
		function codeVal() {
111
			mui.ajax(baseUrl + '/ajax/validCode', {
112
				data: {
113
					"state": state,
114
					"vc": userCode.value
115
				},
116
				dataType: 'json', //数据格式类型
117
				async: false,
118
				type: 'POST', //http请求类型
119
				success: function(data) {
120
					console.log(data.success);
121
					console.log(data.data);
122
					if(data.success) {
123
						if(data.data) {
124
							mui.openWindow({
125
								url: 'setpass.html',
126
								id: 'setpass.html',
127
								extras: {
128
									phoneName: userPhone.value,
129
									setCode: userCode.value,
130
									state: state,
131
									num:1
132
								}
133
							});
134
						}else{
135
							plus.nativeUI.toast("验证码不正确", toastStyle);
136
							return;
137
						}
138
					}else{
139
						console.log(data.msg);
140
					    if(data.msg=="验证超时"){
141
							plus.nativeUI.toast("验证码超时", toastStyle);
142
							return;
143
						}else{
144
							plus.nativeUI.toast("请填写正确的手机号,验证码", toastStyle);
145
							return;
146
						}
147
					}
148
				},
149
				error: function() {
150
					plus.nativeUI.toast("服务器链接超时", toastStyle);
151
					return;
152
				}
153
			})
154
		}
155

156
	
157
	});
158
	
159
});

+ 28 - 0
app/js/index.js

@ -2,6 +2,7 @@
2 2
mui.ready(function() {
3 3
	/*定义全局变量*/
4 4
	var isLogin = document.getElementById("isLogin");
5
	var indexlist = document.getElementById("indexlist");
5 6
	
6 7
	mui.plusReady(function() {
7 8
		
@ -15,6 +16,33 @@ mui.ready(function() {
15 16
				}
16 17
			});
17 18
		});
19
		
20
		mui.ajax(baseUrl + '/ajax/professor/qa', {
21
			dataType: 'json', //数据格式类型
22
			type: 'GET', //http请求类型
23
			success: function($data) {
24
				var str = JSON.stringify($data.data)
25
				console.log(str);
26
				var finallist='';
27
				if($data.success){
28
					for(var i = 0 ; i < $data.data.pageSize; i++){
29
					   //创建HTML标签  
30
					   finallist +='<li class="mui-table-view-cell mui-media"><a class="proinfor" ';
31
					   finallist +='<img class="mui-media-object mui-pull-left headimg" src="images/default-photo.jpg">';
32
					   finallist +='<div class="mui-media-body">';
33
					   finallist +='<span class="listtit">'+$data.data.data[i].name+'<img class="smallicon authicon" src="images/authicon.png"/></span>';
34
					   finallist +='<p class="listtit2"><span>'+ $data.data.data[i].title +'</span>,<span>职务</span>,<span>'+ $data.data.data[i].orgName +'</span> | <span>所在地</span></p>';
35
					   finallist +='<p class="mui-ellipsis listtit3"><span>'+ $data.data.data[i].industry +'</span>、<span>研究方向标题B</span></p>';
36
					   finallist +='<p class="mui-ellipsis listtit3"><span>设备资源名称A</span>、<span>设备资源名称B</span>、<span>设备资源名称B</span></p>';
37
					   finallist +='</div></a></li>';
38
					}
39
			    }
40
				indexlist.innerHTML=finallist;
41
			},
42
			error: function() {
43
				plus.nativeUI.toast("服务器链接超时", toastStyle);
44
			}
45
		});
18 46

19 47
	});
20 48
});

+ 14 - 3
app/js/login.js

@ -6,6 +6,7 @@ mui.ready(function() {
6 6
	var login = document.getElementById("login");
7 7
	var userName = document.getElementById("username");
8 8
	var userPassword = document.getElementById("password");
9
	var forgetPassword = document.getElementById("forgetPassword");
9 10

10 11
	mui.plusReady(function() {
11 12
		
@ -13,12 +14,23 @@ mui.ready(function() {
13 14
		reg.addEventListener("tap", function() {
14 15
			goRegFun();
15 16
		})
17
		
18
		/*点击忘记密码按钮*/
19
		forgetPassword.addEventListener("tap", function() {
20
			mui.openWindow({
21
				url: '../html/findpwd-phone.html',
22
				id: '../html/findpwd-phone.html',
23
				show: {
24
					aniShow: "slide-in-right"
25
				}
26
			});
27
		})
16 28

17 29
		/*校验登录按钮显示状态*/
18 30
		mui('.frmbox').on('keyup', "#username,#password", function() {
19
			hideButtn();
31
			hideButtn(userName,userPassword,login,"frmactiveok");
20 32
		});
21

33
		
22 34
		/*登录按钮*/
23 35
		login.addEventListener('tap', function() {
24 36
			userVal()
@ -37,7 +49,6 @@ mui.ready(function() {
37 49

38 50
		/*校验用户账号*/
39 51
		function userVal() {
40
			console.log(userName.value);
41 52
			var gunf = /^\w+@\w+\.((cn)|(com)|(com\.cn))$/;
42 53
			var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
43 54
			if(hunPhone.test(userName.value)) {

+ 4 - 1
app/js/myaccount.js

@ -29,9 +29,12 @@ mui.plusReady(function(){
29 29
			});
30 30
		})
31 31
		
32
		/*登录按钮*/
32 33
		goLogin.addEventListener('tap',function(){
33 34
			goLoginFun();
34 35
		})
36
		
37
		/*注册按钮*/
35 38
		goReg.addEventListener('tap',function(){
36 39
			goRegFun();
37 40
			
@ -65,7 +68,7 @@ mui.plusReady(function(){
65 68
						}else{
66 69
							document.getElementById("userImg").setAttribute("src", "../images/default-photo.jpg");
67 70
						}
68
						console.log($info.hasHeadImage);
71

69 72
					}
70 73
				},
71 74
				error: function() {

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

@ -33,4 +33,15 @@ function goRegFun() {
33 33
			aniShow: "slide-in-right"
34 34
		}
35 35
	});
36
}
37

38
/*校验下一步按钮显示状态*/
39
function hideButtn(oneName,twoName,threeName,fourName) {
40
	if(oneName.value == "" || twoName.value == "") {
41
		threeName.classList.remove(fourName);
42
		threeName.disabled = "disabled";
43
	} else {
44
		threeName.classList.add(fourName);
45
		threeName.disabled = "";
46
	}
36 47
}

+ 32 - 13
app/js/register-setpass.js

@ -12,7 +12,7 @@ mui.ready(function() {
12 12
        
13 13
		/*校验提交按钮显示状态*/
14 14
		mui('.frmbox').on('keyup', "#password,#password2", function() {
15
			hideButtn();
15
			hideButtn(passWord,passwordOK,registerOk,"frmactiveok");
16 16
		});
17 17

18 18
		/*提交设置密码*/
@ -20,16 +20,6 @@ mui.ready(function() {
20 20
			valOld()
21 21
		});
22 22

23
		function hideButtn() {
24
			if(passWord.value == "" || passwordOK.value == "") {
25
				registerOk.classList.remove('frmactiveok');
26
				registerOk.disabled = "disabled";
27
			} else {
28
				registerOk.classList.add('frmactiveok');
29
				registerOk.disabled = "";
30
			}
31
		}
32

33 23
		function valOld() {
34 24
			if(passWord.value.length < 6 && passwordOK.value.length < 6) {
35 25
				plus.nativeUI.toast("密码不少于6位,请输入正确的密码", toastStyle);
@ -38,10 +28,16 @@ mui.ready(function() {
38 28
				plus.nativeUI.toast("两次密码不一致", toastStyle);
39 29
				return;
40 30
			} else {
41
				completeReg();
31
				if(self.num==1){
32
					completepaw();
33
				}else{
34
					completeReg();	
35
				}
36
				
42 37
			}
43 38
		}
44 39

40
		//注册提交
45 41
		function completeReg() {
46 42
			mui.ajax(baseUrl + '/ajax/regmobile', {
47 43
				data: {
@ -53,7 +49,6 @@ mui.ready(function() {
53 49
				dataType: 'json', //数据格式类型
54 50
				type: 'post', //http请求类型
55 51
				async: false,
56
				timeout: 10000, //超时设置
57 52
				success: function(data) {
58 53
					if(data.success) {
59 54
						var userId = data.data;
@ -76,6 +71,30 @@ mui.ready(function() {
76 71
				}
77 72
			});
78 73
		}
74
		
75
		//找回密码提交
76
		function completepaw() {
77
			mui.ajax(baseUrl + '/ajax/resetPasswordWithMobilePhone', {
78
				data: {
79
					state: self.state,
80
					mobilePhone: self.phoneName,
81
					vc: self.setCode,
82
					pw: passwordOK.value
83
				},
84
				dataType: 'json', //数据格式类型
85
				type: 'post', //http请求类型
86
				async: false,
87
				success: function(data) {
88
					if(data.success&&data.data) {
89
						goLoginFun();
90
						plus.webview.close(self);
91
					}
92
				},
93
				error: function() {
94
					plus.nativeUI.toast("服务器链接超时", toastStyle);
95
				}
96
			});
97
		}
79 98

80 99
	});
81 100


+ 17 - 26
app/js/register.js

@ -19,38 +19,19 @@ mui.ready(function() {
19 19

20 20
		/*校验提交按钮显示状态*/
21 21
		mui('.frmbox').on('keyup', "#username,#set-code", function() {
22
			hideButtn();
22
			hideButtn(phoneName,setCode,reg,"frmactiveok");
23 23
		});
24 24

25 25
		/*点击获取验证码*/
26 26
		obtainCode.addEventListener('tap', function() {
27
			if(phoneCode) {
28
				sendAuthentication();
29
			} else {
30
				phoneVal();
31
			}
27
			phoneVal();
32 28
		})
33 29

34 30
		/*注册按钮*/
35 31
		reg.addEventListener('tap', function() {
36
			if(phoneCode) {
37
				codeVal();
38
			} else {
39
				phoneVal();
40
			}
32
			codeVal();
41 33
		})
42 34

43
		/*校验按钮显示状态*/
44
		function hideButtn() {
45
			if(phoneName.value == "" || setCode.value == "") {
46
				reg.classList.remove('frmactiveok');
47
				reg.disabled = "disabled";
48
			} else {
49
				reg.classList.add('frmactiveok');
50
				reg.disabled = "";
51
			}
52
		}
53

54 35
		/*校验手机号*/
55 36
		function phoneVal() {
56 37
			var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
@ -74,6 +55,9 @@ mui.ready(function() {
74 55
						return;
75 56
					} else {
76 57
						phoneCode = true;
58
						if(phoneCode){
59
							sendAuthentication();
60
						}
77 61
					}
78 62
				},
79 63
				error: function() {
@ -150,13 +134,20 @@ mui.ready(function() {
150 134
									state: state
151 135
								}
152 136
							});
153
						} else {
137
						}else{
154 138
							plus.nativeUI.toast("验证码不正确", toastStyle);
155 139
							return;
156 140
						}
157
					} else {
158
						plus.nativeUI.toast("验证超时,请重新获取", toastStyle);
159
						return;
141
					}else{
142
						console.log(data.msg);
143
						if(data.msg=="验证超时"){
144
							plus.nativeUI.toast("验证码超时", toastStyle);
145
							return;
146
						}else{
147
							plus.nativeUI.toast("请填写正确的手机号,验证码", toastStyle);
148
							return;
149
						}
150
						
160 151
					}
161 152
				},
162 153
				error: function() {