Sfoglia il codice sorgente

新增邀请用户加入科袖

xuchunyang 8 anni fa
parent
commit
1eb551cb5e
2 ha cambiato i file con 225 aggiunte e 6 eliminazioni
  1. 16 6
      ekexiu/Invitation.html
  2. 209 0
      js/invite-friends.js

+ 16 - 6
ekexiu/Invitation.html

@ -19,6 +19,7 @@ body{background: url(../images/frmPageBg.jpg) no-repeat;background-size: 100% 10
19 19
.protocollink{ color: #FF9900;}
20 20
.checkBg{background: url(../images/checkApp.png) 0 center no-repeat;padding-left:18px;line-height: 24px; background-size:auto 60%}
21 21
.canPoint{background:#ff9900;color:#FFFFFF;}/*按钮可点击状态*/
22
.canPoint2{background:#ccc;color:#FFFFFF;}/*按钮可点击状态*/
22 23
.canPoint:hover{color:#FFFFFF;box-shadow: 0px 0px 16px rgba(255,255,255,0.4) inset;}
23 24
/*logo盒子的相关*/
24 25
.logobox{ padding:6% 6% 3% 6%; margin:20% auto 6% ; }
@ -26,6 +27,8 @@ body{background: url(../images/frmPageBg.jpg) no-repeat;background-size: 100% 10
26 27
.logoimg{ width: 100%; margin: auto; text-align:center;}
27 28
.inviteTit{text-align: center; font-size: 18px;line-height: 40px;margin-top:30px;}
28 29
.inviteTit span{font-size:20px;line-height: 44px; padding:0 6px; color:#FF9900}
30
.bomb-box{background-color:rgba(000,000,000,0.5); padding:5px 15px; border-radius:50px; font-size: 12px; color: #fff; text-align:center; position: absolute; display: inline; left:50%; top:25%}
31

29 32
</style>
30 33
</head>
31 34
<body>
@ -41,23 +44,30 @@ body{background: url(../images/frmPageBg.jpg) no-repeat;background-size: 100% 10
41 44
	
42 45
	<form class="form-inline" role="form" style="width: 90%;margin:auto">
43 46
		<div class="form-group">
44
		    <input type="phone" class="form-control" placeholder="请输入您的手机号码">
47
		    <input type="phone" class="form-control" placeholder="请输入您的手机号码" id="userphone" autocomplete="off">
45 48
		    <div class="input-group" style="margin:6px 0;">
46
		      <input class="form-control" style="width: 97%;" type="text" placeholder="请输入验证码">
47
		      <div class="input-group-addon canPoint">获取验证码</div>
49
		      <input class="form-control" style="width: 97%;" type="text" placeholder="请输入验证码" id="code" autocomplete="off">
50
		      <div class="input-group-addon canPoint" id="obtain-code" >获取验证码</div>
51
		      <div class="input-group-addon canPoint2" id="getcodeoff" style="display: none;"></div>
48 52
		    </div>
49
		    <input type="password" class="form-control" placeholder="请设置您的登录密码">
53
		    <input type="password" class="form-control" placeholder="请设置您的登录密码" id="password" autocomplete="off">
50 54
		</div>
51 55
	  <div class="checkbox" style="padding:0">
52 56
	    <label style="font-size:13px;color:#efefef;">
53 57
	        <div class="checkBg">
54
	        	已同意 <a href="../privacyApp.html" class="protocollink" target="_blank">科袖网用户协议</a>
58
	        	已同意 <a href="privacyApp.html" class="protocollink" target="_blank">科袖网用户协议</a>
55 59
	        </div>
56 60
	      	
57 61
	    </label>
58 62
	  </div>
59
	  <button type="button" class="btn btn-lg btn-block canPoint">注册</button>
63
	  <button type="button" class="btn btn-lg btn-block canPoint" id="regbtn" disabled="disabled">注册</button>
60 64
	</form>
61 65
</div>
66

67
<div class="bomb-box" style="display: none;">请输出内容sasdfasdfasdf</div>
68
<script type="text/javascript" src="../js/jquery-1.11.1.js" ></script>
69
<script type="text/javascript" src="../js/common.js" ></script>
70
<script type="text/javascript" src="../js/invite-friends.js" ></script>
71

62 72
</body>
63 73
</html>

+ 209 - 0
js/invite-friends.js

@ -0,0 +1,209 @@
1
/*邀请好友*/
2
$(function(){
3
	
4
	var phoneCode = false;
5
	var ifCode = false;
6
	var ifpassword = false;
7
	var state;
8
	var inviterId = GetQueryString("professorId");
9
	var username = GetQueryString("professorName");
10
	//var inviterId="6E199CFA7B034D69A7029731B6E77D4A";
11
	//var username="特朗普";
12
	
13
	$(".inviteTit span").text(username);
14
	/*控制提示框样式*/
15
	function bombox(textt){
16
		$(".bomb-box").fadeIn("slow");
17
		$(".bomb-box").text(textt);
18
		var bombwidth = $(".bomb-box").width();
19
	    $(".bomb-box").css({"marginLeft": -(bombwidth+25)/2 + "px"});
20
		setInterval (function(){
21
			$(".bomb-box").fadeOut("slow");
22
		},4000);
23
	}
24
	
25
	/*校验提交按钮显示状态*/
26
	$('.form-group').on('keyup', "#userphone,#code,#password", function() {
27
		if($("#userphone").val() == "" || $("#code").val() == "" || $("#password").val() == "") {
28
			$("#regbtn").attr("disabled",true);
29
		} else {
30
			$("#regbtn").attr("disabled",false);
31
		}
32
	});
33
	
34
	/*注册按钮*/
35
	$("#regbtn").on('click',function() {
36
		codeVal();
37
		if(ifpassword && ifCode){
38
			completeReg();
39
		}
40
	});
41
		
42
	/*点击获取验证码*/
43
	$('#obtain-code').on('click',function() {
44
		phoneVal();
45
	});
46
	
47
	/*校验手机号*/
48
	function phoneVal() {
49
		var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
50
		if(hunPhone.test($("#userphone").val())) {
51
			isReg();
52
		} else {
53
			bombox("请输入正确的手机号码");
54
			return;
55
		}
56
	}
57
	
58
	/*校验用户名是否注册*/
59
	function isReg() {
60
		$.ajax({
61
			url:"/ajax/isReg?key=" + $("#userphone").val(),
62
			dataType: 'json', //数据格式类型
63
			type: 'GET', //http请求类型
64
			timeout: 10000, //超时设置
65
			success: function(data) {
66
				if(data.data == false) {
67
					bombox("您的手机已被注册");
68
					return;
69
				} else {
70
					phoneCode = true;
71
					if(phoneCode){
72
						sendAuthentication();
73
					}
74
				}
75
			},
76
			error: function() {
77
				bombox("服务器链接超时");
78
				return;
79
			}
80
		});
81
	}
82
	
83
	/*手机发送验证码*/
84
	function sendAuthentication() {
85
		$.ajax({
86
			url:"/ajax/regmobilephone",
87
			data: {
88
				mobilePhone: $("#userphone").val()
89
			},
90
			dataType: 'json', //数据格式类型
91
			type: 'GET', //http请求类型
92
			async: false,
93
			timeout: 10000, //超时设置
94
			success: function(data) {
95
				console.log(data);
96
				if(data.success) {
97
					state = data.data;
98
					doClick();
99
				}
100
			},
101
			error: function() {
102
				bombox("服务器链接超时");
103
				return;
104
			}
105
		})
106
	}
107
	
108
	/*30s后重新获取验证码*/
109
	function doClick() {
110
		$("#obtain-code").hide();
111
		$("#getcodeoff").show();
112
		$("#getcodeoff").text("30s后重新获取");
113
		var clickTime = new Date().getTime();
114
		var Timer = setInterval(function() {
115
			var nowTime = new Date().getTime();
116
			var second = Math.ceil(30 - (nowTime - clickTime) / 1000);
117
			if(second > 0) {
118
				$("#getcodeoff").text(second + "s后重新获取");
119
			} else {
120
				clearInterval(Timer);
121
				$("#obtain-code").show();
122
				$("#getcodeoff").hide();
123
				$("#obtain-code").text("获取验证码");
124
			}
125
		}, 1000);
126
	}
127
	
128
	/*校验验证码*/
129
	function codeVal() {
130
		$.ajax({
131
			url:"/ajax/validCode",
132
			data: {
133
				"state": state,
134
				"vc": $("#code").val()
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==false) {
144
						bombox("验证码不正确");
145
						return;
146
					}else{
147
						passwordVal();
148
						ifCode =true;
149
						return;
150
					}
151
				}else{
152
					console.log(data.msg);
153
					if(data.msg=="验证超时"){
154
						bombox("验证码超时");
155
						return;
156
					}else{
157
						bombox("请填写正确的手机号,验证码");
158
						return;
159
					}
160
					
161
				}
162
			},
163
			error: function() {
164
				bombox("服务器链接超时");
165
				return;
166
			}
167
		})
168
	}
169
	
170
    /*校验注册密码*/
171
	function passwordVal() {
172
		var passwordv = $("#password").val();
173
	    if(passwordv.length < 6) {
174
			bombox("请输入由6-24 个字符组成,区分大小写");
175
			return;
176
		}else{
177
			ifpassword = true;
178
			return;
179
		}
180
	}
181
	
182
	//注册提交
183
	function completeReg() {
184
		$.ajax({
185
			url:"/ajax/regmobile",
186
			data: {
187
				state: state,
188
				mobilePhone: $("#userphone").val(),
189
				validateCode: $("#code").val(),
190
				password: $("#password").val(),
191
				inviterId:inviterId
192
			},
193
			dataType: 'json', //数据格式类型
194
			type: 'post', //http请求类型
195
			async: false,
196
			success: function(data) {
197
				if(data.success) {
198
					bombox("注册成功");
199
					location.href="invitSucceed.html";
200
				}
201
			},
202
			error: function() {
203
				bombox("服务器链接超时");
204
			}
205
		});
206
	}
207
		
208
	
209
});