Sfoglia il codice sorgente

注册,登录修改,新加我的账号信息

happy 8 anni fa
parent
commit
e910918e8a
8 ha cambiato i file con 539 aggiunte e 507 eliminazioni
  1. 8 7
      app/html/myaccount.html
  2. 56 55
      app/js/fillinfo.js
  3. 16 10
      app/js/index.js
  4. 134 135
      app/js/login.js
  5. 69 27
      app/js/myaccount.js
  6. 31 53
      app/js/public/base.js
  7. 74 70
      app/js/register-setpass.js
  8. 151 150
      app/js/register.js

+ 8 - 7
app/html/myaccount.html

@ -6,6 +6,9 @@
6 6
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
7 7
		<link href="../css/mui.min.css" rel="stylesheet" />
8 8
		<link href="../css/app.css" rel="stylesheet" />
9
		<script src="../js/public/mui.min.js"></script>
10
		<script src="../js/public/base.js"></script>
11
		<script src="../js/myaccount.js"></script>
9 12
	</head>
10 13
	
11 14
	<body>
@ -34,11 +37,11 @@
34 37
				<div class="maincon personinfo2">
35 38
					<div class="headbox2" >
36 39
					    <a class="mui-pull-left proinfor">
37
		                    <img class="mui-pull-left headimg2" src="../images/default-photo.jpg">
40
		                    <img class="mui-pull-left headimg2" src="../images/default-photo.jpg" id="userImg">
38 41
		                    <div class="mui-pull-left infobasic" style="display:none;" id="loginYes">
39
		                        <span class="listtit">专家姓名<img class="smallicon authicon" src="../images/authicon.png"/></span>	
40
		                        <p class="listtit2"><span>职称</span><span>职务</span></p>
41
		                    	<p class="listtit3"><span>所在部门</span><span>所属机构</span> | <span>所在地</span></p>
42
		                        <span class="listtit"><span id="userName"></span><img class="smallicon authicon" src="../images/authicon.png"/></span>	
43
		                        <p class="listtit2"><span id="userTitle"></span><span id="userPosition"></span></p>
44
		                    	<p class="listtit3"><span id="userDepartment"></span><span id="userMechanism"></span> | <span id="userCity"></span></p>
42 45
		                    </div>
43 46
		                    <div id="loginNo" style="display:none;"><span id="goreg">注册</span>/<span id="gologin">登录</span> </div>
44 47
		                </a>
@ -102,9 +105,7 @@
102 105
				</ul>
103 106
		    </div>
104 107
		</div>
105
		<script src="../js/public/mui.min.js"></script>
106
		<script src="../js/public/base.js"></script>
107
		<script src="../js/myaccount.js"></script>
108
		
108 109
	</body>
109 110
110 111
</html>

+ 56 - 55
app/js/fillinfo.js

@ -1,66 +1,67 @@
1 1
//注册完成个人信息
2
mui.init();
3
mui.plusReady(function(){
4
	/*定义全局变量*/
2
mui.ready(function() {
3
	
4
    /*定义全局变量*/
5 5
	var userName = document.getElementById("userName");
6 6
	var userMechanism = document.getElementById("userMechanism");
7 7
	var userDepartment = document.getElementById("userDepartment");
8 8
	var userPosition = document.getElementById("userPosition");
9 9
	var userTitle = document.getElementById("userTitle");
10 10
	var goIndex = document.getElementById("goIndex");
11
	var self=plus.webview.currentWebview();
12
	
13
	/*校验提交按钮显示状态*/
14
	mui('.basicinfo').on('keyup',"#userName,#userMechanism",function() {
15
		hideButtn();
16
	});
17 11
	
18
	/*提交个人信息*/
19
	goIndex.addEventListener('tap', function() {
20
		goVal();
21
	});
22
	
23
	function hideButtn(){
24
		if(userName.value==""||userMechanism.value==""){
25
			goIndex.classList.remove('frmactiveok');
26
			goIndex.disabled="disabled";
27
		}else{
28
			goIndex.classList.add('frmactiveok');
29
			goIndex.disabled="";
12
	mui.plusReady(function() {
13
		
14
		var self = plus.webview.currentWebview();
15
		
16
		/*校验提交按钮显示状态*/
17
		mui('.basicinfo').on('keyup', "#userName,#userMechanism", function() {
18
			hideButtn();
19
		});
20

21
		/*提交个人信息*/
22
		goIndex.addEventListener('tap', function() {
23
			goVal();
24
		});
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
			}
30 34
		}
31
	}
32
	
33
	function goVal(){
34
		var $data = {};
35
		$data.name = userName.value;				
36
		$data.orgName = userMechanism.value;
37
		$data.title = userTitle.value;
38
		$data.department = userDepartment.value;
39
		$data.address = userPosition.value;
40
		$data.id = self.userid;
41
		mui.ajax(baseUrl + '/ajax/professor', {
42
			data:$data,
43
			dataType: 'json', //数据格式类型
44
			type: 'POST', //http请求类型
45
			timeout: 10000, //超时设置
46
			success: function(data) {
47
				console.log(data.success);
48
				if(data.success) {
49
					mui.openWindow({
50
		      			url:'../index.html',
51
		      			id:'../index.html',
52
						show:{
53
							aniShow:"slide-in-right"
54
						}
55
		      		});	
56
				}else{
57
					plus.nativeUI.toast("提交失败,用户ID失效", toastStyle);
35

36
		function goVal() {
37
			var $data = {};
38
			$data.name = userName.value;
39
			$data.orgName = userMechanism.value;
40
			$data.title = userTitle.value;
41
			$data.department = userDepartment.value;
42
			$data.address = userPosition.value;
43
			$data.id = self.userid;
44
			mui.ajax(baseUrl + '/ajax/professor', {
45
				data: $data,
46
				dataType: 'json', //数据格式类型
47
				type: 'POST', //http请求类型
48
				timeout: 10000, //超时设置
49
				success: function(data) {
50
					console.log(data.success);
51
					if(data.success) {
52
						goHome();
53
						var myaccountClose = plus.webview.getWebviewById("html/myaccount.html");
54
						plus.webview.close(myaccountClose);
55
					} else {
56
						plus.nativeUI.toast("提交失败,用户ID失效", toastStyle);
57
					}
58
				},
59
				error: function() {
60
					plus.nativeUI.toast("服务器链接超时", toastStyle);
58 61
				}
59
			},
60
			error: function() {
61
				plus.nativeUI.toast("服务器链接超时", toastStyle);
62
			}
63
		})
64
	}
65
	
62
			})
63
		}
64

65
	});
66

66 67
});

+ 16 - 10
app/js/index.js

@ -1,14 +1,20 @@
1 1
//首页
2
mui.plusReady(function(){
3
	
2
mui.ready(function() {
4 3
	/*定义全局变量*/
5 4
	var isLogin = document.getElementById("isLogin");
6
	var userId = plus.storage.getItem('userid');
7
	console.log(userId);
8
	/*点击个人中心按钮*/
9
	isLogin.addEventListener('tap', function(){
10
		myAccount();
11
	});
12 5
	
13
	
14
});
6
	mui.plusReady(function() {
7
		
8
		/*点击个人中心按钮*/
9
		isLogin.addEventListener('tap', function() {
10
			mui.openWindow({
11
				url: 'html/myaccount.html',
12
				id: 'html/myaccount.html',
13
				show: {
14
					aniShow: "slide-in-right"
15
				}
16
			});
17
		});
18

19
	});
20
});

+ 134 - 135
app/js/login.js

@ -1,152 +1,151 @@
1 1
//登录
2
mui.plusReady(function(){
3
	
2
mui.ready(function() {
3

4 4
	/*定义全局变量*/
5 5
	var reg = document.getElementById("reg");
6 6
	var login = document.getElementById("login");
7 7
	var userName = document.getElementById("username");
8 8
	var userPassword = document.getElementById("password");
9
	var phoneCode=false;
10
	
11
	reg.addEventListener("tap",function(){
12
		mui.openWindow({
13
			url:"reg.html",
14
			id:"reg.html",
15
			show:{
16
            	aniShow:"slide-in-right"
17
  			}
9

10
	mui.plusReady(function() {
11
		
12
        /*点击注册按钮*/
13
		reg.addEventListener("tap", function() {
14
			goRegFun();
18 15
		})
19
	})
20
	
21
	/*校验登录按钮显示状态*/
22
	mui('.frmbox').on('keyup',"#username,#password",function() {
23
		hideButtn();
24
	});
25
	
26
	/*登录按钮*/
27
	login.addEventListener('tap',function(){
28
		if(phoneCode){
29
			loginBut();
30
		}else{
31
			userVal();
32
		}
33
	})
34
	
35
	/*校验按钮显示状态*/
36
	function hideButtn(){
37
		if(userName.value==""||userPassword.value==""){
38
			login.classList.remove('frmactiveok');
39
			login.disabled="disabled";
40
		}else{
41
			login.classList.add('frmactiveok');
42
			login.disabled="";
16

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

22
		/*登录按钮*/
23
		login.addEventListener('tap', function() {
24
			userVal()
25
		})
26

27
		/*校验按钮显示状态*/
28
		function hideButtn() {
29
			if(userName.value == "" || userPassword.value == "") {
30
				login.classList.remove('frmactiveok');
31
				login.disabled = "disabled";
32
			} else {
33
				login.classList.add('frmactiveok');
34
				login.disabled = "";
35
			}
43 36
		}
44
	}
45
	
46
	/*校验用户账号*/
47
	function userVal(){
48
		console.log(userName.value);
49
		var gunf=/^\w+@\w+\.((cn)|(com)|(com\.cn))$/;
50
		var hunPhone=/^1[3|4|5|7|8]\d{9}$/;
51
		if(hunPhone.test(userName.value)){
52
			userRegisterOk();
53
		}else if(gunf.test(userName.value)){
54
			userRegisterOk();
55
		}else{
56
			plus.nativeUI.toast("请输入正确的手机或邮箱",toastStyle)
57
			return;
37

38
		/*校验用户账号*/
39
		function userVal() {
40
			console.log(userName.value);
41
			var gunf = /^\w+@\w+\.((cn)|(com)|(com\.cn))$/;
42
			var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
43
			if(hunPhone.test(userName.value)) {
44
				userRegisterOk();
45
			} else if(gunf.test(userName.value)) {
46
				userRegisterOk();
47
			} else {
48
				plus.nativeUI.toast("请输入正确的手机或邮箱", toastStyle)
49
				return;
50
			}
58 51
		}
59
	}
60
	
61
	/*判断账号是否注册*/
62
	function userRegisterOk(){
63
		mui.ajax(baseUrl+'/ajax/isReg?key='+userName.value,{
64
			dataType: 'json', //数据格式类型
65
			type: 'GET', //http请求类型
66
			timeout: 10000, //超时设置
67
			success: function(data) {
68
				console.log(data.data)
69
				if(data.data == true) {
70
					plus.nativeUI.toast("用户不存在请注册用户",toastStyle);
52

53
		/*判断账号是否注册*/
54
		function userRegisterOk() {
55
			mui.ajax(baseUrl + '/ajax/isReg?key=' + userName.value, {
56
				dataType: 'json', //数据格式类型
57
				type: 'GET', //http请求类型
58
				timeout: 10000, //超时设置
59
				success: function(data) {
60
					console.log(data.data)
61
					if(data.data == true) {
62
						plus.nativeUI.toast("用户不存在请注册用户", toastStyle);
63
						return;
64
					} else {
65
						passwordVal()
66
					}
67
				},
68
				error: function() {
69
					plus.nativeUI.toast("服务器链接超时", toastStyle);
71 70
					return;
72
				}else{
73
					passwordVal()
74 71
				}
75
			},
76
			error: function() {
77
				plus.nativeUI.toast("服务器链接超时",toastStyle);
72
			});
73
		}
74

75
		/*校验登录密码*/
76
		function passwordVal() {
77
			if(userPassword.value.length < 6) {
78
				plus.nativeUI.toast("密码不少于6位", toastStyle);
78 79
				return;
80
			} else {
81
				loginBut();
79 82
			}
80
		});
81
	}
82
	
83
	/*校验登录密码*/
84
	function passwordVal(){
85
		if(userPassword.value.length < 6){
86
			plus.nativeUI.toast("密码不少于6位",toastStyle);
87
			return;
88
		}else{
89
			phoneCode=true;
90 83
		}
91
	}	
92
	
93
    /*提交登录*/
94
	function loginBut(){
95
		mui.ajax(baseUrl+'/ajax/login',{
96
			data:{"pw":userPassword.value,"lk":userName.value},
97
			dataType: 'json', //数据格式类型
98
			type: 'POST', //http请求类型
99
			timeout: 10000, //超时设置
100
			success: function(data) {
101
				console.log(data.data)
102
				if(data.data != "null" && data.data != null){
103
					var userId=data.data.id;
104
				    plus.storage.setItem('userid',userId);
105
					firstLogin();
106
				}else{
107
					plus.nativeUI.toast("登录账号和密码不匹配!",toastStyle);
84

85
		/*提交登录*/
86
		function loginBut() {
87
			mui.ajax(baseUrl + '/ajax/login', {
88
				data: {
89
					"pw": userPassword.value,
90
					"lk": userName.value
91
				},
92
				dataType: 'json', //数据格式类型
93
				type: 'POST', //http请求类型
94
				timeout: 10000, //超时设置
95
				success: function(data) {
96
					console.log(data.data)
97
					if(data.data != "null" && data.data != null) {
98
						var userId = data.data.id;
99
						plus.storage.setItem('userid', userId);
100
						firstLogin();
101
					} else {
102
						plus.nativeUI.toast("登录账号和密码不匹配!", toastStyle);
103
						return;
104
					}
105
				},
106
				error: function() {
107
					plus.nativeUI.toast("服务器链接超时", toastStyle);
108 108
					return;
109 109
				}
110
			},
111
			error: function() {
112
				plus.nativeUI.toast("服务器链接超时",toastStyle);
113
				return;
114
			}
115
		});
116
	}	
117
	
118
	
119
	/*判断用户第一次登录,是否填写了个人信息*/
120
	function firstLogin(){
121
		var professorId = plus.storage.getItem('userid');
122
		console.log(professorId);
123
		mui.ajax(baseUrl+"/ajax/professor/"+professorId,{
124
			dataType: 'json', //数据格式类型
125
			type: 'GET', //http请求类型
126
			timeout: 10000, //超时设置
127
			success: function(data) {
128
				console.log(data.data)
129
				if(data.data!=null) {
130
					goHome();
131
				}else{
132
					var productView = mui.preload({
133
					    url:'../html/fillinfo.html',
134
						id:'../html/fillinfo.html',
135
						show:{
136
							aniShow:"slide-in-bottom"
137
						},
138
						extras:{
139
							userid:professorId
140
						}
141
					});
142
					productView.show(); 
110
			});
111
		}
112

113
		/*判断用户第一次登录,是否填写了个人信息*/
114
		function firstLogin() {
115
			var professorId = plus.storage.getItem('userid');
116
			console.log(professorId);
117
			mui.ajax(baseUrl + "/ajax/professor/" + professorId, {
118
				dataType: 'json', //数据格式类型
119
				type: 'GET', //http请求类型
120
				async: false,
121
				timeout: 10000, //超时设置
122
				success: function(data) {
123
					console.log(data.data)
124
					if(data.data != null) {
125
						goHome();
126
						var myaccountClose = plus.webview.getWebviewById("html/myaccount.html");
127
						plus.webview.close(myaccountClose);
128
					} else {
129
						var productView = mui.preload({
130
							url: '../html/fillinfo.html',
131
							id: '../html/fillinfo.html',
132
							show: {
133
								aniShow: "slide-in-right"
134
							},
135
							extras: {
136
								userid: professorId
137
							}
138
						});
139
						productView.show();
140
					}
141
				},
142
				error: function() {
143
					plus.nativeUI.toast("服务器链接超时", toastStyle);
144
					return;
143 145
				}
144
			},
145
			error: function() {
146
				plus.nativeUI.toast("服务器链接超时",toastStyle);
147
				return;
148
			}
149
		});
150
	}
151
	
152
})
146
			});
147
		}
148

149
	});
150

151
});

+ 69 - 27
app/js/myaccount.js

@ -7,32 +7,74 @@ mui.plusReady(function(){
7 7
	var goLogin = document.getElementById("gologin");
8 8
	var goReg = document.getElementById("goreg");
9 9
	var removeId = document.getElementById("removeid");
10
	var userId = plus.storage.getItem('userid');
10 11
	
11
	loginStatus();
12
	console.log('ddd');
13
	
14
	/*点击获取验证码*/
15
	removeId.addEventListener('tap',function(){
16
		plus.storage.removeItem('userid');
17
		goLoginFun();
18
	})
19
	goLogin.addEventListener('tap',function(){
20
		goLoginFun();
21
	})
22
	goReg.addEventListener('tap',function(){
23
		goRegFun();
24
	})
25
	
26
	/*判断登录是否成功*/
27
	function loginStatus(){
28
		var userId = plus.storage.getItem('userid');
29
		console.log(userId);
30
		if(userId && userId != "null" && userId!=null){
31
			loginYes.style.display="block";
32
		}else{
33
			loginNo.style.display="block";
12
	mui.ready(function() {
13
		
14
	   /*判断登录是否成功*/
15
	   loginStatus();
16
	   
17
	   /*用户信息初始化*/
18
	   userInformation()
19
	   
20
       /*退出按钮*/
21
		removeId.addEventListener('tap',function(){
22
			var btn=["退出","取消"];
23
			mui.confirm("是否退出","提示",btn,function(e){
24
				if(e.index==0)
25
				{ 
26
					plus.storage.removeItem("userid");
27
					mui.currentWebview.close();
28
				}
29
			});
30
		})
31
		
32
		goLogin.addEventListener('tap',function(){
33
			goLoginFun();
34
		})
35
		goReg.addEventListener('tap',function(){
36
			goRegFun();
37
			
38
		})
39

40
		
41
		function loginStatus(){
42
			if(userId && userId != "null" && userId!=null){
43
				loginYes.style.display="block";
44
			}else{
45
				loginNo.style.display="block";
46
			}
34 47
		}
35
	}
36
	
37
	
38
})
48
		
49
		function userInformation(){
50
			mui.ajax(baseUrl + "/ajax/professor/editBaseInfo/" + userId, {
51
				dataType: 'json', //数据格式类型
52
				type: 'GET', //http请求类型
53
				timeout: 10000, //超时设置
54
				success: function(data) {
55
					var  $info = data.data || {}	
56
					if(data.success && data.data){
57
						document.getElementById("userName").innerText = $info.name || '';
58
						document.getElementById("userTitle").innerText = $info.title || '';
59
						document.getElementById("userPosition").innerText = $info.office || '';
60
						document.getElementById("userDepartment").innerText = $info.department || '';
61
						document.getElementById("userMechanism").innerText = $info.orgName || '';
62
						document.getElementById("userCity").innerText = $info.address || '';
63
						if($info.hasHeadImage==1){
64
							document.getElementById("userImg").setAttribute("src", "../images/head/" + $info.id + "_m.jpg");
65
						}else{
66
							document.getElementById("userImg").setAttribute("src", "../images/default-photo.jpg");
67
						}
68
						console.log($info.hasHeadImage);
69
					}
70
				},
71
				error: function() {
72
					plus.nativeUI.toast("服务器链接超时", toastStyle);
73
					return;
74
				}
75
			});
76
		}
77
		
78
	});
79

80
});

+ 31 - 53
app/js/public/base.js

@ -1,58 +1,36 @@
1 1
//公共文件
2 2
mui.init();
3
var baseUrl="http://192.168.3.173:8080",
4
    toastStyle={'verticalAlign':'top'}
5
mui.plusReady(function(){
6
	
3
var baseUrl = "http://192.168.3.173:8080",
4
	toastStyle = {
5
		'verticalAlign': 'top'
6
	}
7 7

8
function goHome() {
9
	mui.openWindow({
10
		url: '../index.html',
11
		id: '../index.html',
12
		show: {
13
			aniShow: "slide-in-right"
14
		}
15
	});
16
}
8 17

9
    var userId = plus.storage.getItem('userid');
10
 });   
11
    function myAccount(){
12
		/*var productView = mui.preload({
13
		    url:'html/myaccount.html',
14
			id:'html/myaccount.html',
15
			show:{
16
				aniShow:"slide-in-bottom",
17
			}
18
		});
19
		productView.show(); */
20
		mui.openWindow({
21
  			url:'html/myaccount.html',
22
  			id:'html/myaccount.html',
23
  			show:{
24
            	aniShow:"slide-in-right"
25
  			}
26
      	});	 
27
	}
28
    
29
    function goHome(){
30
		mui.openWindow({
31
  			url:'../index.html',
32
  			id:'../index.html',
33
  			show:{
34
            	aniShow:"slide-in-right"
35
  			}
36
      	});	 
37
	}
38
    
39
    function goLoginFun(){
40
		mui.openWindow({
41
  			url:'../html/login.html',
42
  			id:'../html/login.html',
43
  			show:{
44
            	aniShow:"slide-in-right"
45
  			}
46
      	});	 
47
	}
48
    
49
    function goRegFun(){
50
		mui.openWindow({
51
  			url:'../html/reg.html',
52
  			id:'../html/reg.html',
53
  			show:{
54
            	aniShow:"slide-in-right"
55
  			}
56
      	});	 
57
	}
18
function goLoginFun() {
19
	mui.openWindow({
20
		url: '../html/login.html',
21
		id: '../html/login.html',
22
		show: {
23
			aniShow: "slide-in-right"
24
		}
25
	});
26
}
58 27

28
function goRegFun() {
29
	mui.openWindow({
30
		url: '../html/reg.html',
31
		id: '../html/reg.html',
32
		show: {
33
			aniShow: "slide-in-right"
34
		}
35
	});
36
}

+ 74 - 70
app/js/register-setpass.js

@ -1,78 +1,82 @@
1 1
//注册信息设置密码
2
mui.init();
3
mui.plusReady(function(){
4
	
5
	/*定义全局变量*/
2
mui.ready(function() {
3

4
    /*定义全局变量*/
6 5
	var passWord = document.getElementById("password");
7 6
	var passwordOK = document.getElementById("password2");
8 7
	var registerOk = document.getElementById("registerok");
9
	var self=plus.webview.currentWebview();
10
	
11
	/*校验提交按钮显示状态*/
12
	mui('.frmbox').on('keyup',"#password,#password2",function() {
13
		hideButtn();
14
	});
15
	
16
	/*提交设置密码*/
17
	registerOk.addEventListener('tap', function() {
18
		valOld()
19
	});
20
	
21
	function hideButtn(){
22
		if(passWord.value==""||passwordOK.value==""){
23
			registerOk.classList.remove('frmactiveok');
24
			registerOk.disabled="disabled";
25
		}else{
26
			registerOk.classList.add('frmactiveok');
27
			registerOk.disabled="";
8

9
	mui.plusReady(function() {
10
		
11
        var self = plus.webview.currentWebview();
12
        
13
		/*校验提交按钮显示状态*/
14
		mui('.frmbox').on('keyup', "#password,#password2", function() {
15
			hideButtn();
16
		});
17

18
		/*提交设置密码*/
19
		registerOk.addEventListener('tap', function() {
20
			valOld()
21
		});
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
			}
28 31
		}
29
	}
30
	
31
	function valOld(){
32
		if(passWord.value.length < 6 && passwordOK.value.length<6){
33
			plus.nativeUI.toast("密码不少于6位,请输入正确的密码",toastStyle);
34
			return;
35
		}else if(passwordOK.value != passWord.value){
36
			plus.nativeUI.toast("两次密码不一致",toastStyle);
37
			return;
38
		}else{
39
			completeReg();
32

33
		function valOld() {
34
			if(passWord.value.length < 6 && passwordOK.value.length < 6) {
35
				plus.nativeUI.toast("密码不少于6位,请输入正确的密码", toastStyle);
36
				return;
37
			} else if(passwordOK.value != passWord.value) {
38
				plus.nativeUI.toast("两次密码不一致", toastStyle);
39
				return;
40
			} else {
41
				completeReg();
42
			}
40 43
		}
41
	}
42
	
43
	function completeReg(){
44
		mui.ajax(baseUrl+'/ajax/regmobile',{
45
			data:{
46
				state:self.state,
47
				mobilePhone:self.phoneName,
48
				validateCode:self.setCode,
49
				password:passwordOK.value
50
			},
51
			dataType: 'json', //数据格式类型
52
			type: 'post', //http请求类型
53
			async: false,
54
			timeout: 10000, //超时设置
55
			success: function(data) {
56
				if(data.success) {
57
					var userId=data.data;
58
				    plus.storage.setItem('userid',userId);
59
					plus.nativeUI.toast("已完成注册,请填写个人信息",toastStyle);
60
					mui.openWindow({
61
		      			url:'fillinfo.html',
62
		      			id:'fillinfo.html',
63
		      			extras:{
64
							userid:userId
65
						},
66
						show:{
67
							aniShow:"slide-in-right"
68
						}
69
		      		});	
44

45
		function completeReg() {
46
			mui.ajax(baseUrl + '/ajax/regmobile', {
47
				data: {
48
					state: self.state,
49
					mobilePhone: self.phoneName,
50
					validateCode: self.setCode,
51
					password: passwordOK.value
52
				},
53
				dataType: 'json', //数据格式类型
54
				type: 'post', //http请求类型
55
				async: false,
56
				timeout: 10000, //超时设置
57
				success: function(data) {
58
					if(data.success) {
59
						var userId = data.data;
60
						plus.storage.setItem('userid', userId);
61
						plus.nativeUI.toast("已完成注册,请填写个人信息", toastStyle);
62
						mui.openWindow({
63
							url: 'fillinfo.html',
64
							id: 'fillinfo.html',
65
							extras: {
66
								userid: userId
67
							},
68
							show: {
69
								aniShow: "slide-in-right"
70
							}
71
						});
72
					}
73
				},
74
				error: function() {
75
					plus.nativeUI.toast("服务器链接超时", toastStyle);
70 76
				}
71
			},
72
			error: function() {
73
					plus.nativeUI.toast("服务器链接超时",toastStyle);
74
			}
75
		});	
76
	}
77
	
77
			});
78
		}
79

80
	});
81

78 82
});

+ 151 - 150
app/js/register.js

@ -1,5 +1,5 @@
1 1
//注册信息
2
mui.plusReady(function(){
2
mui.ready(function() {
3 3
	
4 4
	/*定义全局变量*/
5 5
	var phoneName = document.getElementById("username");
@ -7,163 +7,164 @@ mui.plusReady(function(){
7 7
	var obtainCode = document.getElementById("obtain-code");
8 8
	var reg = document.getElementById("reg");
9 9
	var login = document.getElementById("login");
10
	var phoneCode=false;
10
	var phoneCode = false;
11 11
	var state = 0;
12 12
	
13
	/*点击登录页面*/
14
	login.addEventListener('tap',function(){
15
		mui.openWindow({
16
  			url:'setpass.html',
17
  			id:'setpass.html',
18
  			show:{
19
            	aniShow:"slide-in-right"
20
  			}
21
      	});	
22
	})
23
	
24
	/*校验提交按钮显示状态*/
25
	mui('.frmbox').on('keyup',"#username,#set-code",function() {
26
		hideButtn();
27
	});
28
	
29
	/*点击获取验证码*/
30
	obtainCode.addEventListener('tap',function(){
31
		if(phoneCode){
32
			sendAuthentication();	
33
		}else{
34
			phoneVal();
35
		}
36
	})
37
	
38
	/*注册按钮*/
39
	reg.addEventListener('tap',function(){
40
		if(phoneCode){
41
			codeVal();	
42
		}else{
43
			phoneVal();	
13
	mui.plusReady(function() {
14

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

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

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

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

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

54
		/*校验手机号*/
55
		function phoneVal() {
56
			var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
57
			if(hunPhone.test(phoneName.value)) {
58
				isReg();
59
			} else {
60
				plus.nativeUI.toast("请输入正确的手机号码", toastStyle);
61
				return;
62
			}
55 63
		}
56
	}
57
	
58
	/*校验手机号*/
59
	function phoneVal(){
60
		var hunPhone=/^1[3|4|5|7|8]\d{9}$/;
61
		if(hunPhone.test(phoneName.value)){
62
			isReg(); 
63
		}else{
64
			plus.nativeUI.toast("请输入正确的手机号码",toastStyle);
65
			return;
64

65
		/*校验用户名是否注册*/
66
		function isReg() {
67
			mui.ajax(baseUrl + '/ajax/isReg?key=' + phoneName.value, {
68
				dataType: 'json', //数据格式类型
69
				type: 'GET', //http请求类型
70
				timeout: 10000, //超时设置
71
				success: function(data) {
72
					if(data.data == false) {
73
						plus.nativeUI.toast("您的手机已被注册", toastStyle);
74
						return;
75
					} else {
76
						phoneCode = true;
77
					}
78
				},
79
				error: function() {
80
					plus.nativeUI.toast("服务器链接超时", toastStyle);
81
				}
82
			});
66 83
		}
67
	}
68
	
69
	/*校验用户名是否注册*/
70
	function isReg() {
71
		mui.ajax(baseUrl+'/ajax/isReg?key='+phoneName.value,{
72
			dataType: 'json', //数据格式类型
73
			type: 'GET', //http请求类型
74
			timeout: 10000, //超时设置
75
			success: function(data) {
76
				if(data.data == false) {
77
					plus.nativeUI.toast("您的手机已被注册",toastStyle);
84

85
		/*手机发送验证码*/
86
		function sendAuthentication() {
87
			mui.ajax(baseUrl + '/ajax/regmobilephone', {
88
				data: {
89
					mobilePhone: phoneName.value
90
				},
91
				dataType: 'json', //数据格式类型
92
				type: 'GET', //http请求类型
93
				async: false,
94
				timeout: 10000, //超时设置
95
				success: function(data) {
96
					if(data.success) {
97
						state = data.data;
98
						doClick();
99
					}
100
				},
101
				error: function() {
102
					plus.nativeUI.toast("服务器链接超时", toastStyle);
78 103
					return;
79
				}else{
80
					phoneCode=true;
81 104
				}
82
				},
83
			error: function() {
84
				plus.nativeUI.toast("服务器链接超时",toastStyle);
85
			}
86
		});
87
	}
105
			})
106
		}
88 107

89
	/*手机发送验证码*/
90
	function sendAuthentication(){
91
		mui.ajax(baseUrl+'/ajax/regmobilephone',{
92
			data:{mobilePhone:phoneName.value},
93
			dataType: 'json', //数据格式类型
94
			type: 'GET', //http请求类型
95
			async: false,
96
			timeout: 10000, //超时设置
97
			success: function(data) {
98
				if(data.success) {
99
					state=data.data;
100
					doClick();
108
		/*30s后重新获取验证码*/
109
		function doClick() {
110
			var getCodeOff = document.getElementById("getcodeoff");
111
			obtainCode.style.display = "none";
112
			getCodeOff.style.display = "block";
113
			getCodeOff.innerHTML = "30s后重新获取";
114
			var clickTime = new Date().getTime();
115
			var Timer = setInterval(function() {
116
				var nowTime = new Date().getTime();
117
				var second = Math.ceil(30 - (nowTime - clickTime) / 1000);
118
				if(second > 0) {
119
					getCodeOff.innerHTML = second + "s后重新获取";
120
				} else {
121
					clearInterval(Timer);
122
					obtainCode.style.display = "block";
123
					getCodeOff.style.display = "none";
124
					obtainCode.innerHTML = "获取验证码";
101 125
				}
102
			},
103
			error: function() {
104
					plus.nativeUI.toast("服务器链接超时",toastStyle);
105
					return;
106
			}
107
		})
108
	}
109
	
110
	/*30s后重新获取验证码*/
111
	function doClick() {
112
		var getCodeOff = document.getElementById("getcodeoff");
113
		obtainCode.style.display = "none";
114
		getCodeOff.style.display = "block";
115
		getCodeOff.innerHTML = "30s后重新获取";
116
		var clickTime = new Date().getTime();
117
		var Timer = setInterval(function() {
118
			var nowTime = new Date().getTime();
119
			var second = Math.ceil(30 - (nowTime - clickTime) / 1000);
120
			if(second > 0) {
121
				getCodeOff.innerHTML = second + "s后重新获取";
122
			} else {
123
				clearInterval(Timer);
124
			    obtainCode.style.display = "block";
125
				getCodeOff.style.display = "none";
126
				obtainCode.innerHTML = "获取验证码";
127
			}
128
		}, 1000);
129
	}
130
	
131
	/*校验验证码*/
132
	function codeVal(){
133
  		mui.ajax(baseUrl+'/ajax/validCode',{
134
			data:{"state":state,"vc":setCode.value},
135
			dataType: 'json', //数据格式类型
136
			async: false,
137
			type: 'POST', //http请求类型
138
			timeout: 10000, //超时设置
139
			success: function(data) {
140
				console.log(data.success);
141
				if(data.success){
142
					if(data.data){
143
						mui.openWindow({
144
			      			url:'setpass.html',
145
			      			id:'setpass.html',
146
			      			extras:{
147
								phoneName:phoneName.value,
148
								setCode:setCode.value,
149
								state:state
150
							}
151
			      		});	
152
					}else{
153
						plus.nativeUI.toast("验证码不正确",toastStyle);
154
						return;	
126
			}, 1000);
127
		}
128

129
		/*校验验证码*/
130
		function codeVal() {
131
			mui.ajax(baseUrl + '/ajax/validCode', {
132
				data: {
133
					"state": state,
134
					"vc": setCode.value
135
				},
136
				dataType: 'json', //数据格式类型
137
				async: false,
138
				type: 'POST', //http请求类型
139
				timeout: 10000, //超时设置
140
				success: function(data) {
141
					console.log(data.success);
142
					if(data.success) {
143
						if(data.data) {
144
							mui.openWindow({
145
								url: 'setpass.html',
146
								id: 'setpass.html',
147
								extras: {
148
									phoneName: phoneName.value,
149
									setCode: setCode.value,
150
									state: state
151
								}
152
							});
153
						} else {
154
							plus.nativeUI.toast("验证码不正确", toastStyle);
155
							return;
156
						}
157
					} else {
158
						plus.nativeUI.toast("验证超时,请重新获取", toastStyle);
159
						return;
155 160
					}
156
				}else{
157
					plus.nativeUI.toast("验证超时,请重新获取",toastStyle);
158
					return;	
161
				},
162
				error: function() {
163
					plus.nativeUI.toast("服务器链接超时", toastStyle);
164
					return;
159 165
				}
160
			},
161
			error: function() {
162
				plus.nativeUI.toast("服务器链接超时",toastStyle);
163
				return;
164
			}
165
		})
166
    }
167
	
168
	
169
})
166
			})
167
		}
168

169
	});
170
});