Browse Source

token判断

heyang 3 years ago
parent
commit
3e59d83564
1 changed files with 39 additions and 11 deletions
  1. 39 11
      microserviceUserH5/vcloud/activationCode.html

+ 39 - 11
microserviceUserH5/vcloud/activationCode.html

@@ -47,28 +47,43 @@
 		toastr.options.timeOut = '1500';
 	</script>
 	<script type="text/javascript">
-        // var baseUrl = 'https://per.cs.se.androidscloud.com/'
+        var baseUrl = 'https://per.cs.se.androidscloud.com/'
 	    let timer,flag = true;
 		var url = window.location.href;
 		url = url.split('/')
 		var loc = window.location.search,
 		    n1 = loc.length,//地址的总长度
 		    n2 = loc.indexOf("="),//取得=号的位置
-		    id = loc.substr(n2 + 1, n1 - n2);//从=号后面的内容
-		operate(3);
+		    id = loc.substr(n2 + 1, n1 - n2),//从=号后面的内容
+			u = navigator.userAgent,
+			isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
+			isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
+		if(id !== ''){
+			operate(3);
+		}
 		//点击试玩
 		$('.try-play')[0].addEventListener('click',()=>{
-			var u = navigator.userAgent;
-            var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
-            var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
 			if (isAndroid) {
-                window.native.toGame('com.xjro.yy');
+				//是否有token
+				if(id === ''){
+					window.native.tokenJudge('noToken');
+				}else{
+					window.native.toGame('com.xjro.yy');
+				}
             }else if(isiOS){
-				window.webkit.messageHandlers.getPackageName.postMessage('com.xjro.yy');
+				if(id === ''){
+					window.webkit.messageHandlers.tokenJudge.postMessage('noToken');
+				}else{
+					window.webkit.messageHandlers.getPackageName.postMessage('com.xjro.yy');
+				}
 			}else{
-
+				stopManyClick(() =>{
+					toastr.error('暂不支持当前系统')
+				})
+			}
+			if(id !== ''){
+				operate(5);
 			}
-			operate(5);
 		},false);
 		//埋点
 		function operate(accessType){
@@ -98,8 +113,21 @@
 			$('.mask').show();
 			document.documentElement.style.overflow='hidden';
 		}
-		//激活码
+		//点击领取激活码
 		function getActivationCode(){
+			//是否有token
+			if (isAndroid && id === '') {
+				window.native.tokenJudge('noToken');
+				return 
+            }else if(isiOS && id === ''){
+				window.webkit.messageHandlers.tokenJudge.postMessage('noToken');
+				return
+			}else{
+				stopManyClick(() =>{
+					toastr.error('暂不支持当前系统');
+				})
+				return
+			}
 			$.ajax({
 				url: baseUrl + '/api/public/v1/game/activationCode',
 				type: 'get',