heyang 4 lat temu
rodzic
commit
5ff31e374c

+ 29 - 25
microserviceUserH5/vcloud/invite.html

@@ -77,7 +77,7 @@
 		toastr.options.timeOut = '3000';
 	</script>
 	<script type="text/javascript">
-		let timer2,flag2 = true;
+		let timer,flag = true;
 		var url = window.location.href;
 		url = url.split('/')
 		//   var baseUrl = url[0] + '//' + url[2]
@@ -105,19 +105,15 @@
 				//加载数据
 				$('#passwordCopy').val($('#invitationCode').text());
 				//复制按钮
-				let timer,flag = true;
 				$('.btn-code-copy').on('click', function () {
-					if (flag) {
+					stopManyClick(() =>{
 						var input = document.getElementById("passwordCopy");
 						// 选中文本
 						input.select();
 						// 执行浏览器复制命令
 						document.execCommand("copy");
 						toastr.error('复制成功', 0)
-					}
-					flag = false;
-					if(timer){clearTimeout(timer);}
-					timer = setTimeout(() => {flag = true}, 1000);
+					})
 				});
 				if (res.data.friendList.length > 0) {
 					var str = ''
@@ -144,18 +140,21 @@
 		})
 
 		$("#recv_ipt").bind('input propertychange', function (e) {
-			var ipt_phones = $('#recv_ipt').val();
-			var c = $(this);
-			if (/[^\d]/.test(c.val())) {//替换非数字字符 v1/promote
-				var temp_amount = c.val().replace(/[^\d]/g, '');
-				$(this).val(temp_amount);
-				toastr.error('请输入正确的手机号')
-			}
-			if (ipt_phones.length >= 12) {
-				toastr.error('请输入正确的手机号')
-				var recvstr = ipt_phones.substring(0, 11)
-				$("#recv_ipt").val(recvstr);
-			}
+			stopManyClick(() =>{
+				var ipt_phones = $('#recv_ipt').val();
+			    var c = $(this);
+				if (/[^\d]/.test(c.val())) {//替换非数字字符 v1/promote
+					var temp_amount = c.val().replace(/[^\d]/g, '');
+					$(this).val(temp_amount);
+					toastr.error('请输入正确的手机号')
+				}
+				if (ipt_phones.length >= 12) {
+					toastr.error('请输入正确的手机号')
+					var recvstr = ipt_phones.substring(0, 11)
+					$("#recv_ipt").val(recvstr);
+				}
+			})
+			
 		});
 		function handleShow() {
 			$('.dialog').animate({top: '2.4rem'},"fast");
@@ -213,7 +212,7 @@
 					dataType: 'json',
 					cache: false,
 					success: function (res) {
-						if (flag2) {
+						stopManyClick(() =>{
 							//加载数据
 							var copyBefore = JSON.stringify(res.data.url);
 							var copyUrl = copyBefore.split('"');
@@ -224,11 +223,7 @@
 							// 执行浏览器复制命令
 							document.execCommand("copy");
 							toastr.error('复制成功')
-						}
-						flag2 = false;
-						if(timer2){clearTimeout(timer2);}
-						timer2 = setTimeout(() => {flag2 = true}, 1000);
-						
+						})
 					}
 				})
 			}
@@ -309,6 +304,15 @@
 			})
 		}
 		getInvitationRecently()
+		//防止提示一秒内重复显示
+		function stopManyClick(fn) {
+			if (flag) {
+				fn();
+			}
+			flag = false;
+			if(timer){clearTimeout(timer);}
+			timer = setTimeout(() => {flag = true}, 1000);
+		}
 	</script>
 </body>
 

+ 22 - 10
microserviceUserH5/vcloud/register.html

@@ -67,12 +67,16 @@
 			if (/[^\d]/.test(c.val())) {//替换非数字字符
 				var temp_amount = c.val().replace(/[^\d]/g, '');
 				$(this).val(temp_amount);
-				toastr.error('请填写正确的手机号')
+				stopManyClick(() =>{
+					toastr.error('请填写正确的手机号')
+				})
 			}
 			if (ipt_phones.length >= 12) {
-				toastr.error('请填写正确的手机号')
 				var recvstr = ipt_phones.substring(0, 11)
 				$("#recv_ipt").val(recvstr);
+				stopManyClick(() =>{
+					toastr.error('请填写正确的手机号')
+				})
 			}
 		});
 
@@ -130,12 +134,7 @@
 
 		getUserInfo();
 		function handleClick() {
-			if (flag) {
-				result();
-			}
-			flag = false;
-			if(timer){clearTimeout(timer);}
-			timer = setTimeout(() => {flag = true}, 2000);
+			stopManyClick(result);
 		}
 		function result() {
 			var time = new Date().getTime()
@@ -152,9 +151,13 @@
 			var downLoaderCount = Number(localStorage.getItem('downLoaderCount'))
 			downLoaderCount ? localStorage.setItem('downLoaderCount', downLoaderCount + 1) : localStorage.setItem('downLoaderCount', 1)
 			if (!ipt_phone) {
-				toastr.error('请填写正确的手机号')
+				stopManyClick(() =>{
+				    toastr.error('请填写正确的手机号')
+			    })
 			} else if (!res) {
-				toastr.error('请填写正确的手机号')
+				stopManyClick(() =>{
+				    toastr.error('请填写正确的手机号')
+			    })
 			} else {
 				data.newPhone = ipt_phone
 				$.ajax({
@@ -252,6 +255,15 @@
 		}
 
 		visit()
+		//防止提示一秒内重复显示
+		function stopManyClick(fn) {
+			if (flag) {
+				fn();
+			}
+			flag = false;
+			if(timer){clearTimeout(timer);}
+			timer = setTimeout(() => {flag = true}, 1000);
+		}
 	</script>
 </body>
 <style>