heyang 3 anni fa
parent
commit
4ef7460740

+ 5 - 2
microserviceUserH5/static/css/springFestivalActivity.css

@@ -405,7 +405,7 @@ ul, li {
 .rule-list{
   width: 4.76rem;
   position: absolute;
-  bottom: 1.1rem;
+  bottom: 0.9rem;
   left: 50%;
   transform: translateX(-50%);
   font-size: 0.26rem;
@@ -612,11 +612,14 @@ ul, li {
 }
 
 .toast-center-center {
-  min-width: 100px;
+  position: fixed;
+  min-width: 220px;
   top: 50%;
   left: 50%;
   text-align: center;
   transform: translateX(-50%);
+  color: #FFFFFF;
+  border-radius: 0.1rem;
 }
 
 @media (max-width: 480px) and (min-width: 241px) {

+ 84 - 38
microserviceUserH5/vcloud/springFestivalActivity.html

@@ -139,6 +139,7 @@
 			isMiniprogram = false,
 			isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
 		let activityState = 0,
+		    luckDraw = 0,
 		    surplus = 0,
 			receive = 0,
 			notReceive = 0;
@@ -189,6 +190,10 @@
 									</div>`
 						}
 						activityState = res.data.activityState;
+						if(activityState === 2){
+				            $('.share-wrap').eq(0).css('display', 'none');
+						}
+						luckDraw = res.data.luckDraw;
 						surplus = res.data.surplus;
 						notReceive = res.data.notReceive;
 						$('.rest-times-number').eq(0).text(surplus);
@@ -271,10 +276,26 @@
 		},false);
 		//点击抽奖
 		$('.once')[0].addEventListener('click',() => {
-			handleAward(1)
+			if(activityState === 0){
+				stopManyClick(() =>{
+					toastr.error('该活动暂未开启,请稍安勿躁');
+				})
+			}else if(activityState === 2 && luckDraw === 0){
+				toastr.error('活动已结束,期待下次的见面');
+			}else{
+				handleAward(1)
+			}
 		},false);
 		$('.five-times')[0].addEventListener('click',() => {
-			handleAward(5)
+			if(activityState === 0){
+				stopManyClick(() =>{
+					toastr.error('该活动暂未开启,请稍安勿躁');
+				})
+			}else if(activityState === 2 && luckDraw === 0){
+				toastr.error('活动已结束,期待下次的见面');
+			}else{
+				handleAward(5)
+			}
 		},false);
 		//点击再抽
 		$('.left-btn')[0].addEventListener('click',() => {
@@ -358,42 +379,38 @@
 		},false);
 		//点击分享按钮
 		$('.share-wrap')[0].addEventListener('click',() => {
-			if (isMiniprogram) { // 小程序
-				wx.miniProgram.navigateTo({
-					url: '/pages/home/home'
-				})
-			} else { // 不是小程序
-				$.ajax({
-					url: baseUrl + '/api/public/v4/actFissionAward/getActDetail',
-					type: 'get',
-					headers: {
-						'Authorization': id //id
-					},
-					contentType: "application/json",
-					dataType: 'json',
-					cache: false,
-					success: (res) => {
-						if (res.status === 0) {
-						    init();
-							var shareInfo = res.data;
-							if (isAndroid) {
-								window.native.share(shareInfo.title, shareInfo.content, shareInfo.gotoUrl, shareInfo.shareImg)
-							} else if (isIOS) {
-								window.webkit.messageHandlers.share.postMessage({
-									title: shareInfo.title,
-									content: shareInfo.content,
-									gotoUrl: shareInfo.gotoUrl,
-									shareImg: shareInfo.shareImg
-								});
-							}
-						} else {
-							stopManyClick(() =>{
-								toastr.error(res.msg)
-							})
+			$.ajax({
+				url: baseUrl + '/api/public/v4/actFissionAward/getActDetail',
+				type: 'get',
+				headers: {
+					'Authorization': id //id
+				},
+				contentType: "application/json",
+				dataType: 'json',
+				cache: false,
+				success: (res) => {
+					if (res.status === 0) {
+						init();
+						var shareInfo = res.data;
+						if (isMiniprogram) { // 小程序
+							copyUrl(shareInfo.gotoUrl);
+						} else if (isAndroid) {
+							window.native.share(shareInfo.title, shareInfo.content, shareInfo.gotoUrl, shareInfo.shareImg);
+						} else if (isIOS) {
+							window.webkit.messageHandlers.share.postMessage({
+								title: shareInfo.title,
+								content: shareInfo.content,
+								gotoUrl: shareInfo.gotoUrl,
+								shareImg: shareInfo.shareImg
+							});
 						}
-					},
-				})
-			}
+					} else {
+						stopManyClick(() =>{
+							toastr.error(res.msg)
+						})
+					}
+				},
+			})
 			$.ajax({
 				url: baseUrl + '/api/user/v1/activity/addBuff',
 				type: 'get',
@@ -407,7 +424,6 @@
 					console.log(res)
 				},
 			})
-			
 		},false);
 		//点击购买星耀获取云机按钮
 		$('.no-times-btn')[0].addEventListener('click',() => {
@@ -535,6 +551,36 @@
 				},
 			})
 		}
+		//复制
+		function copyUrl(url) {
+			stopManyClick(() => {
+				var oInput = document.createElement('input'); //创建一个input
+				oInput.setAttribute("readonly", "readonly");//设置只读,否则移动端使用复制功能时可能会造成软件盘弹出
+				oInput.value = url;
+				$('.ipt')[0].appendChild(oInput);//将input插入到body
+				// oInput.select(); // 选择对象 ios不支持
+				selectText(oInput, 0, oInput.value.length);
+				document.execCommand("Copy"); // 执行浏览器复制命令
+				toastr.error('复制分享链接成功!');
+				oInput.style.display = 'none'; // 将input隐藏
+				oInput.blur();
+				oInput.remove(); // 将input销毁
+			})
+		}
+		// input自带的select()方法在苹果端无法进行选择,所以需要自己去写一个类似的方法
+		// 选择文本。createTextRange(setSelectionRange)是input方法
+		function selectText(textbox, startIndex, stopIndex) {
+			if (textbox.createTextRange) {//ie
+				const range = textbox.createTextRange();
+				range.collapse(true);
+				range.moveStart('character', startIndex);//起始光标
+				range.moveEnd('character', stopIndex - startIndex);//结束光标
+				range.select();//不兼容苹果
+			} else {//firefox/chrome
+				textbox.setSelectionRange(startIndex, stopIndex);
+				textbox.focus();
+			}
+		}
 		//埋点
 		function operate(accessType){
 			$.ajax({