jack 8 vuotta sitten
vanhempi
commit
e1994cd6e9
3 muutettua tiedostoa jossa 94 lisäystä ja 16 poistoa
  1. 15 5
      app/js/backBindOn.js
  2. 27 11
      app/js/backBindUn.js
  3. 52 0
      app/js/weChatlogin.js

+ 15 - 5
app/js/backBindOn.js

@ -40,7 +40,7 @@ mui.plusReady(function() {
40 40
				success: function(data) {
41 41
					console.log(data.data)
42 42
					if(data.data == true) {
43
						plus.nativeUI.toast("用户不存在请注册用户", toastStyle);
43
						plus.nativeUI.toast("该账号不存在,请检查后重试", toastStyle);
44 44
						return;
45 45
					} else {
46 46
						passwordVal()
@ -55,7 +55,7 @@ mui.plusReady(function() {
55 55
		/*校验登录密码*/
56 56
		function passwordVal() {
57 57
			if(oPassword.value.length < 6) {
58
				plus.nativeUI.toast("密码不少于6位", toastStyle);
58
				plus.nativeUI.toast("密码由6-24个字符组成,区分大小写", toastStyle);
59 59
				return;
60 60
			} else {
61 61
				loginBut();
@ -103,9 +103,15 @@ mui.plusReady(function() {
103 103
					console.log(JSON.stringify(data));
104 104
					if(data.success) {
105 105
						plus.storage.setItem('userid', id);
106
						var proAiticle =plus.webview.getWebviewById('professorArticle.html')
107
							mui.fire(proAiticle, "newId");
108
						var consultPage = plus.webview.getWebviewById('consultlist.html');
109
						mui.fire(consultPage, 'logined', {
110
							id: id
111
						});	
106 112
						firstLogin();
107 113
					}else{
108
						if(data.code==2) {
114
						if(data.code==-2) {
109 115
							plus.nativeUI.toast("该账号已绑定微信号", toastStyle);
110 116
							return;
111 117
						}
@ -129,7 +135,7 @@ mui.plusReady(function() {
129 135
				success: function(data) {
130 136
					console.log(JSON.stringify(data))
131 137
					if(data.success) {
132
						if(data.data.authentication < 0){
138
						if(data.data.authentication == undefined || data.data.authentication == null){
133 139
							var productView = mui.preload({
134 140
								url: '../html/fillinfo.html',
135 141
								id: '../html/fillinfo.html',
@ -142,7 +148,11 @@ mui.plusReady(function() {
142 148
							});
143 149
							productView.show();
144 150
						}else{
145
							 goHome();
151
								mui.back();
152
					        var myaccountPage = plus.webview.getWebviewById('html/myaccount.html');
153
							mui.fire(myaccountPage, 'closeUser', {
154
								id: professorId
155
							});
146 156
						}
147 157
					}
148 158
				},

+ 27 - 11
app/js/backBindUn.js

@ -46,20 +46,30 @@ phone.addEventListener("keyup",function(){
46 46
		}
47 47

48 48
		/*校验用户名是否注册*/
49
		function isReg() {
49
		function isReg(arg) {
50
			var oArg=arg;
50 51
			mui.ajax(baseUrl + '/ajax/isReg?key=' + phone.value, {
51 52
				dataType: 'json', //数据格式类型
52 53
				type: 'GET', //http请求类型
53 54
				timeout: 10000, //超时设置
54 55
				success: function(data) {
55 56
					if(data.data == false) {
56
						plus.nativeUI.toast("该账号已存在,请直接登录", toastStyle);
57
						if(oArg==1) {
58
							plus.nativeUI.toast("该账号已存在", toastStyle);
59
						}else{
60
							plus.nativeUI.toast("该账号已存在,请直接登录", toastStyle);
61
						}
57 62
						return;
58 63
					} else {
64
						if(oArg==1){		
65
							codeVal();
66
						}else{							
59 67
						phoneCode = true;
60 68
						if(phoneCode){
61 69
							sendAuthentication();
62 70
						}
71
						}
72
						
63 73
					}
64 74
				},
65 75
				error: function() {
@ -130,7 +140,7 @@ phone.addEventListener("keyup",function(){
130 140
					console.log(JSON.stringify(data));
131 141
					if(data.success) {
132 142
						if(data.data) {
133
							valOld();
143
							completeReg();
134 144
						}else{
135 145
							plus.nativeUI.toast("验证码错误,请检查后重试", toastStyle);
136 146
							return;
@ -153,21 +163,27 @@ phone.addEventListener("keyup",function(){
153 163
				}
154 164
			})
155 165
		}
156
		/*校验真实姓名和密码*/
157
		function valOld() {
166
		binding.addEventListener("tap",function(){
158 167
			var nameval = /^\w{0,20}$/;
168
			var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
169
			var oNum=/^\d{4}$/;
159 170
			if(nameval.test(weiChatName.value)) {
160 171
				plus.nativeUI.toast("姓名最长为10个汉字或20个英文字符", toastStyle);
161 172
				return;
162
			} else if(setpassword.value.length < 6){
173
			} 
174
			if(!hunPhone.test(phone.value)) {
175
				plus.nativeUI.toast("请输入正确的手机号码", toastStyle);
176
				return;
177
			}
178
			if(!oNum.test(oPhoneCode.value)) {
179
				plus.nativeUI.toast("验证码为4位数字", toastStyle);
180
				return;
181
			}
182
			if(setpassword.value.length < 6){
163 183
				plus.nativeUI.toast("密码由6-24个字符组成,区分大小写", toastStyle);
164 184
				return;
165
			}else{
166
				completeReg();
167 185
			}
168
		}
169
		binding.addEventListener("tap",function(){
170
			codeVal();
186
			isReg(1);
171 187
		});
172 188
		//绑定提交
173 189
		function completeReg() {

+ 52 - 0
app/js/weChatlogin.js

@ -58,6 +58,7 @@ mui.plusReady(function() {
58 58
	}
59 59

60 60
	function weChat(weiChatId,weixinName) {
61
		console.log(weiChatId);
61 62
		mui.ajax(baseUrl + "/ajax/oauth/openidLogin", {
62 63
			dataType: 'json', //数据格式类型
63 64
			type: 'POST', //http请求类型
@ -68,6 +69,7 @@ mui.plusReady(function() {
68 69
			},
69 70
			success: function(data) {
70 71
				if(data.success) {
72
					console.log(JSON.stringify(data));
71 73
					if(data.data == null) {
72 74
						mui.openWindow({
73 75
							url: '../html/backBindUn.html',
@ -81,6 +83,16 @@ mui.plusReady(function() {
81 83
							 	openid:weiChatId
82 84
							 }
83 85
						});
86
					}else{
87
						plus.storage.setItem('userid', data.data.id);
88
						console.log(data.data.id)
89
						firstLogin();
90
						var proAiticle =plus.webview.getWebviewById('professorArticle.html')
91
							mui.fire(proAiticle, "newId");
92
							var consultPage = plus.webview.getWebviewById('consultlist.html');
93
						mui.fire(consultPage, 'logined', {
94
							id: data.id
95
						});	
84 96
					}
85 97
				}
86 98
			},
@ -91,4 +103,44 @@ mui.plusReady(function() {
91 103
			}
92 104
		});
93 105
	}
106
	/*判断用户第一次登录,是否填写了个人信息*/
107
		function firstLogin() {
108
			var professorId = plus.storage.getItem('userid');
109
			mui.ajax(baseUrl + "/ajax/professor/" + professorId, {
110
				dataType: 'json', //数据格式类型
111
				type: 'GET', //http请求类型
112
				async: false,
113
				timeout: 10000, //超时设置
114
				success: function(data) {
115
					console.log(JSON.stringify(data))
116
					console.log(data.data.authentication)
117
					if(data.success) {
118
						
119
						if(data.data.authentication == undefined || data.data.authentication == null){
120
							var productView = mui.preload({
121
								url: '../html/fillinfo.html',
122
								id: '../html/fillinfo.html',
123
								show: {
124
									aniShow: "slide-in-right"
125
								},
126
								extras: {
127
									userid: professorId
128
								}
129
							});
130
							productView.show();
131
						}else{
132
							 mui.back();
133
					        var myaccountPage = plus.webview.getWebviewById('html/myaccount.html');
134
							mui.fire(myaccountPage, 'closeUser', {
135
								id: professorId
136
							});
137
						}
138
					}
139
				},
140
				error: function() {
141
					plus.nativeUI.toast("服务器链接超时", toastStyle);
142
					return;
143
				}
144
			});
145
		}
94 146
})