Przeglądaj źródła

Merge branch 'dev-5.2' of http://192.168.32.253:3000/Software/android-cloud-H5 into dev-5.2

heyang 3 lat temu
rodzic
commit
ce6ae31a1b

+ 1 - 1
androidscloudH5/gzhDownload.html

@@ -86,7 +86,7 @@
 
   function clickDown() {
     if (isAndroid) {
-      window.location.href = window.location.protocol === 'https:' ? 'https://file.phone.androidscloud.com:8121/document/newFile/download/1/${uploadKey}/LowLevelMultipartUpload_17835766588148940877' : 'http://110.53.221.195:8210/document/newFile/download/1/${uploadKey}/LowLevelMultipartUpload_17835766588148940877'
+      window.location.href = window.location.protocol === 'https:' ? 'https://file.phone.androidscloud.com:8121/document/newFile/download/1/${uploadKey}/LowLevelMultipartUpload_18131560837339955244' : 'http://110.53.221.195:8210/document/newFile/download/1/347905r86eb745a1sc38/LowLevelMultipartUpload_18131560837339955244'
     }
     if (isiOS) {
       window.location.href = window.location.href = 'https://www.pgyer.com/gemini6'

+ 7 - 1
screenAndroid/WXdraw.js

@@ -102,10 +102,16 @@ function doConnect() {
               tt.miniProgram.switchTab({
                 url: '/pages/home/home'
               })
-            } else {
+            } else if (window.__wxjs_environment === 'miniprogram') {
               wx.miniProgram.switchTab({
                 url: '/pages/home/home'
               })
+            } else {
+              document.addEventListener('UniAppJSBridgeReady', function () {
+                uni.navigateTo({
+                  url: '/pages/index/index'
+                });
+              })
             }
           });
         } else {

+ 108 - 87
screenAndroid/WXtrialInterface.html

@@ -45,19 +45,19 @@
         background: rgba(0, 0, 0, 0.5);
       display: none;
     }
-      
-    .try-use-container{
+
+    .try-use-container {
       width: 80%;
       height: 409px;
-        position: absolute;
-        top: 50%;
-        left: 50%;
-        transform: translate(-50%, -50%);
+      position: absolute;
+      top: 50%;
+      left: 50%;
+      transform: translate(-50%, -50%);
       background-color: #FFFFFF;
       border-radius: 0.66em;
     }
 
-    .time-close-wrap{
+    .time-close-wrap {
       width: 5.46em;
       height: 2em;
       line-height: 2em;
@@ -71,18 +71,18 @@
       color: #FFFFFF;
     }
 
-    .bug-wrap{
+    .bug-wrap {
       width: 90%;
       height: 115px;
       background: #FFFFFF;
       border-radius: 10px;
       position: absolute;
-        top: 50%;
-        left: 50%;
-        transform: translate(-50%, -50%);
+      top: 50%;
+      left: 50%;
+      transform: translate(-50%, -50%);
     }
 
-    .bug-title{
+    .bug-title {
       text-align: center;
       margin: 25px 0;
       font-size: 18px;
@@ -90,11 +90,11 @@
       color: #333333;
     }
 
-    .btn-list{
+    .btn-list {
       width: 100%;
       height: 44px;
       line-height: 44px;
-      border-top: 1px solid rgba(238,238,238,1);
+      border-top: 1px solid rgba(238, 238, 238, 1);
       position: absolute;
       bottom: 0;
       left: 0;
@@ -102,20 +102,20 @@
       align-items: center;
     }
 
-    .btn{
+    .btn {
       flex: 1;
       text-align: center;
     }
 
-    .cannel-btn{
+    .cannel-btn {
       font-size: 18px;
       color: #666666;
     }
 
-    .go-bug{
+    .go-bug {
       font-size: 18px;
       color: #3B7FFF;
-      border-left: 1px solid rgba(238,238,238,1);
+      border-left: 1px solid rgba(238, 238, 238, 1);
     }
   </style>
 </head>
@@ -226,6 +226,7 @@
   <script type="text/javascript" src="WXdraw.js"></script>
   <script type="text/javascript" src="jmuxer.js"></script>
   <script type="text/javascript" src="spsParser.js"></script>
+  <script type="text/javascript" src="https://unpkg.com/@dcloudio/uni-webview-js@0.0.2/index.js"></script>
   <script>
     var url = window.location.href;
     url = url.split('/');
@@ -273,7 +274,7 @@
     }
     //云机倒计时
     let validTime = parameters['validTime'] || 10000;
-    if(validTime > 32000) {
+    if (validTime > 32000) {
       validTime = 32000
     }
     let detailTime = validTime * 60 * 1000;
@@ -309,9 +310,7 @@
     var ip = parameters["ip"];
     var cardToken = parameters["cardToken"];
     cardToken = cardToken && decodeURIComponent(cardToken);
-    console.log(decodeURIComponent(cardToken));
     var appletPushAddress = parameters["appletPushAddress"];
-    // "&type=business"
     var socketURL = isWSS ? "wss://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken + "&type=business" : "ws://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken;
 
     var jmuxer = new JMuxer({
@@ -440,17 +439,39 @@
       });
     }
 
+    var hidden, visibilityChange; 
+    if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support 
+      hidden = "hidden";
+      visibilityChange = "visibilitychange";
+    } else if (typeof document.msHidden !== "undefined") {
+      hidden = "msHidden";
+      visibilityChange = "msvisibilitychange";
+    } else if (typeof document.webkitHidden !== "undefined") {
+      hidden = "webkitHidden";
+      visibilityChange = "webkitvisibilitychange";
+    }
+
+    // 处理页面可见属性的改变
     document.addEventListener("visibilitychange", function () {
-      if (document.visibilityState == "visible") {
-        var buffer = RequestIFrame();
-        ws.send(buffer);
-        isVisuable = true;
-      } else {
-        isVisuable = false;
-        isFeed = false;
-        myVideo.pause();
+      console.log(document[hidden]);
+      if (document[hidden]) {
+        if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
+          tt.miniProgram.switchTab({
+            url: '/pages/home/home'
+          })
+        } else if (window.__wxjs_environment === 'miniprogram') {
+          wx.miniProgram.switchTab({
+            url: '/pages/home/home'
+          })
+        } else {
+          document.addEventListener('UniAppJSBridgeReady', function () {
+            uni.navigateTo({
+              url: '/pages/index/index'
+            });
+          })
+        }
       }
-    });
+    }, false);
 
     myVideo.addEventListener('pause', function () {
       isFeed = false;
@@ -970,7 +991,7 @@
             if (res.status === 0) {
               let list = res.data;
               list.map((item) => {
-                if(item.phoneType === parameters['mealType']){
+                if (item.phoneType === parameters['mealType']) {
                   resolve(item)
                 }
               })
@@ -984,12 +1005,12 @@
     //广告信息
     function adInit() {
       sourceType = parameters['sourceType'];
-      if(sourceType == 1) {
+      if (sourceType == 1) {
         getSetmealList().then((res) => {
-          if(res.pushFlowAdvert === 1){
+          if (res.pushFlowAdvert === 1) {
             getAdList(15);
           }
-          if(res.intervalSwitch === 1) {
+          if (res.intervalSwitch === 1) {
             let time = res.intervalAdvertDuration * 60 * 1000;
             setInterval(() => {
               $('.try-use-wrap').eq(0).hide();
@@ -997,19 +1018,19 @@
             }, time);
           }
         })
-      }else if(sourceType == 2) {
+      } else if (sourceType == 2) {
         getConfigByPhoneType().then((res) => {
-          if(res.isDisconnectionTime === 1){
+          if (res.isDisconnectionTime === 1) {
             let time = res.disconnectionTime * 60 * 1000;
             setTimeout(() => {
               disconnectionFlag = true;
               $('.buy-phone-wrap').eq(0).show();
             }, time);
           }
-          if(res.isShowAd === 1){
+          if (res.isShowAd === 1) {
             getAdList(15);
           }
-          if(res.isIntervalPlayAd === 1) {
+          if (res.isIntervalPlayAd === 1) {
             let time = res.intervalPlayAdTime * 60 * 1000;
             setInterval(() => {
               $('.try-use-wrap').eq(0).hide();
@@ -1020,46 +1041,46 @@
       }
     }
     // 广告接口
-    function getAdList(type){
+    function getAdList(type) {
       adType = type;
       $.ajax({
-            url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
-            headers: {
-              'Authorization': form.token
-            },
-            data: JSON.stringify({
-              adPlace: type,
-              os: 0
-            }),
-            type: 'POST',
-            dataType: 'json',
-					  contentType: "application/json;charset=UTF-8",
-            success: function (res) {
-              if (res.status === 0) {
-                let list = res.data;
-                let indexs = Math.floor(Math.random()*list.length);
-                videoTime = list[indexs].forcedTime;
-                // $('#source').src = list[0].adVideoBase.videoUrl;
-                $("#source").attr("src", list[indexs].adVideoBase.videoUrl);//更新url
-                $("#source").attr("autoplay", "true");//直接播放
-                videoTimer = setInterval(() =>{
-                  if(videoTime > 0) {
-                    videoTime--;
-                    $('.time-node').eq(0).text(videoTime + 's');
-                  } else {
-                    clearInterval(videoTimer);
-                    $('.time-node').eq(0).text('');
-                  }
-                },1000)
-                if (adType === 16 && sourceType == 1) { // 间隔广告和试用才上报
-                  report(0);
-                }
-                $('.try-use-wrap').eq(0).show();
+        url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
+        headers: {
+          'Authorization': form.token
+        },
+        data: JSON.stringify({
+          adPlace: type,
+          os: 0
+        }),
+        type: 'POST',
+        dataType: 'json',
+        contentType: "application/json;charset=UTF-8",
+        success: function (res) {
+          if (res.status === 0) {
+            let list = res.data;
+            let indexs = Math.floor(Math.random() * list.length);
+            videoTime = list[indexs].forcedTime;
+            // $('#source').src = list[0].adVideoBase.videoUrl;
+            $("#source").attr("src", list[indexs].adVideoBase.videoUrl);//更新url
+            $("#source").attr("autoplay", "true");//直接播放
+            videoTimer = setInterval(() => {
+              if (videoTime > 0) {
+                videoTime--;
+                $('.time-node').eq(0).text(videoTime + 's');
               } else {
-                $.toast(res.msg, "text");
+                clearInterval(videoTimer);
+                $('.time-node').eq(0).text('');
               }
+            }, 1000)
+            if (adType === 16 && sourceType == 1) { // 间隔广告和试用才上报
+              report(0);
             }
-          })
+            $('.try-use-wrap').eq(0).show();
+          } else {
+            $.toast(res.msg, "text");
+          }
+        }
+      })
     }
     //间隔广告上报
     function report(type) {
@@ -1075,7 +1096,7 @@
         type: 'POST',
         dataType: 'json',
         contentType: "application/json;charset=UTF-8",
-        success: function (res) {}
+        success: function (res) { }
       })
     }
     //关闭广告
@@ -1093,13 +1114,13 @@
         return
       }
       let pointName = '';
-      if(sourceType == 1){
+      if (sourceType == 1) {
         pointName = videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
       } else {
         pointName = videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
       }
       systemBuriedPoint(pointName);
-      if(videoTime == 0) {
+      if (videoTime == 0) {
         if (adType === 16 && sourceType == 1) {
           report(1);
         }
@@ -1111,15 +1132,15 @@
     // 点击去购买
     $('.go-bug')[0].addEventListener('click', () => {
       let pointName = '';
-      if(disconnectionFlag) {
+      if (disconnectionFlag) {
         pointName = '激活码-断线-去购买';
-      } else if(sourceType == 1){
+      } else if (sourceType == 1) {
         pointName = videoTime == 0 ? '免费试用-关闭-去购买' : '免费试用-强制关闭-去购买';
       } else {
         pointName = videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
       }
       systemBuriedPoint(pointName);
-      if(getDate){
+      if (getDate) {
         wx.miniProgram.navigateTo({
           url: '/packageA/order/buy/index'
         })
@@ -1131,7 +1152,7 @@
     })
     // 放弃
     $('.cannel-ad-btn')[0].addEventListener('click', () => {
-      if(sourceType == 1){
+      if (sourceType == 1) {
         systemBuriedPoint('免费试用-强制关闭-放弃');
       } else {
         systemBuriedPoint('激活码-强制关闭-放弃');
@@ -1143,26 +1164,26 @@
     // 继续观看
     $('.looking')[0].addEventListener('click', () => {
       $('.look-wrap').eq(0).hide();
-      if(sourceType == 1){
+      if (sourceType == 1) {
         systemBuriedPoint('免费试用-强制关闭-继续观看');
       } else {
         systemBuriedPoint('激活码-强制关闭-继续观看');
       }
     })
     // 埋点
-    function systemBuriedPoint(pointName){
+    function systemBuriedPoint(pointName) {
       $.ajax({
         url: baseUrl + "/api/public/v1/systemBuriedPoint/stat",
         headers: {
           'Authorization': form.token
         },
         type: 'post',
-        data:JSON.stringify({
-					pointName: pointName
-				}),
-				contentType:"application/json",
+        data: JSON.stringify({
+          pointName: pointName
+        }),
+        contentType: "application/json",
         dataType: 'json',
-        success: function (res) {}
+        success: function (res) { }
       })
     }
     window.onbeforeunload = function () {

+ 7 - 1
screenIos/WXdraw.js

@@ -117,10 +117,16 @@ function doConnect() {
               tt.miniProgram.switchTab({
                 url: '/pages/home/home'
               })
-            } else {
+            } else if (window.__wxjs_environment === 'miniprogram') {
               wx.miniProgram.switchTab({
                 url: '/pages/home/home'
               })
+            } else {
+              document.addEventListener('UniAppJSBridgeReady', function () {
+                uni.navigateTo({
+                  url: '/pages/index/index'
+                });
+              })
             }
           });
         } else {

+ 115 - 82
screenIos/WXtrialInterface.html

@@ -46,19 +46,19 @@
         background: rgba(0, 0, 0, 0.5);
       display: none;
     }
-      
-    .try-use-container{
+
+    .try-use-container {
       width: 80%;
       height: 409px;
-        position: absolute;
-        top: 50%;
-        left: 50%;
-        transform: translate(-50%, -50%);
+      position: absolute;
+      top: 50%;
+      left: 50%;
+      transform: translate(-50%, -50%);
       background-color: #FFFFFF;
       border-radius: 0.66em;
     }
 
-    .time-close-wrap{
+    .time-close-wrap {
       width: 5.46em;
       height: 2em;
       line-height: 2em;
@@ -72,18 +72,18 @@
       color: #FFFFFF;
     }
 
-    .bug-wrap{
+    .bug-wrap {
       width: 90%;
       height: 115px;
       background: #FFFFFF;
       border-radius: 10px;
       position: absolute;
-        top: 50%;
-        left: 50%;
-        transform: translate(-50%, -50%);
+      top: 50%;
+      left: 50%;
+      transform: translate(-50%, -50%);
     }
 
-    .bug-title{
+    .bug-title {
       text-align: center;
       margin: 25px 0;
       font-size: 18px;
@@ -91,11 +91,11 @@
       color: #333333;
     }
 
-    .btn-list{
+    .btn-list {
       width: 100%;
       height: 44px;
       line-height: 44px;
-      border-top: 1px solid rgba(238,238,238,1);
+      border-top: 1px solid rgba(238, 238, 238, 1);
       position: absolute;
       bottom: 0;
       left: 0;
@@ -103,20 +103,20 @@
       align-items: center;
     }
 
-    .btn{
+    .btn {
       flex: 1;
       text-align: center;
     }
 
-    .cannel-btn{
+    .cannel-btn {
       font-size: 18px;
       color: #666666;
     }
 
-    .go-bug{
+    .go-bug {
       font-size: 18px;
       color: #3B7FFF;
-      border-left: 1px solid rgba(238,238,238,1);
+      border-left: 1px solid rgba(238, 238, 238, 1);
     }
   </style>
 </head>
@@ -220,6 +220,7 @@
   <script type="text/javascript" src="webgl.js"></script>
   <script type="text/javascript" src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
   <script type="text/javascript" src="WXdraw.js"></script>
+  <script type="text/javascript" src="https://unpkg.com/@dcloudio/uni-webview-js@0.0.2/index.js"></script>
   <script type="text/javascript">
     $(function () {
       //手指滑动多少距离就认为是滑成功
@@ -342,7 +343,7 @@
     });
     //云机倒计时
     let validTime = parameters['validTime'] || 10000;
-    if(validTime > 32000) {
+    if (validTime > 32000) {
       validTime = 32000;
     }
     let detailTime = validTime * 60 * 1000;
@@ -676,7 +677,7 @@
         tt.miniProgram.switchTab({
           url: '/pages/home/home'
         })
-      } else if(window.__wxjs_environment === 'miniprogram') {
+      } else if (window.__wxjs_environment === 'miniprogram') {
         wx.miniProgram.switchTab({
           url: '/pages/home/home'
         })
@@ -736,7 +737,7 @@
     var decodeWoker = new Worker('decoder.js');
     var myVideo = document.getElementById("playCanvas");
     var logicWidth = 720;
-		var logicHeight = 1280;
+    var logicHeight = 1280;
     decodeWoker.onmessage = function (event) {
       var objData = event.data;
 
@@ -746,7 +747,7 @@
         case 1:
           if (logicWidth != objData.width || logicHeight != objData.height) {
             logicWidth = objData.width;
-						logicHeight = objData.height;
+            logicHeight = objData.height;
           }
           webglPlayer.renderFrame(objData.data, logicWidth, logicHeight, logicWidth * logicHeight, (logicWidth / 2) * (logicHeight / 2));
           $('.weui-mask_transparent').hide()
@@ -809,12 +810,12 @@
               tt.miniProgram.switchTab({
                 url: '/pages/home/home'
               })
-            } else if(window.__wxjs_environment === 'miniprogram') {
+            } else if (window.__wxjs_environment === 'miniprogram') {
               wx.miniProgram.switchTab({
                 url: '/pages/home/home'
               })
             } else {
-              location.href =  `${baseUrl}/cloud/phone/web/#/pages/index/index`
+              location.href = `${baseUrl}/cloud/phone/web/#/pages/index/index`
               // document.addEventListener('UniAppJSBridgeReady', function() {
               //   uni.navigateTo({
               //     url: '/pages/index/index'
@@ -849,7 +850,7 @@
           tt.miniProgram.switchTab({
             url: '/pages/home/home'
           })
-        } else if(window.__wxjs_environment === 'miniprogram') {
+        } else if (window.__wxjs_environment === 'miniprogram') {
           wx.miniProgram.switchTab({
             url: '/pages/home/home'
           })
@@ -905,7 +906,7 @@
             if (res.status === 0) {
               let list = res.data;
               list.map((item) => {
-                if(item.phoneType === parameters['mealType']){
+                if (item.phoneType === parameters['mealType']) {
                   resolve(item)
                 }
               })
@@ -919,12 +920,12 @@
     //广告信息
     function adInit() {
       sourceType = parameters['sourceType'];
-      if(sourceType == 1) {
+      if (sourceType == 1) {
         getSetmealList().then((res) => {
-          if(res.pushFlowAdvert === 1){
+          if (res.pushFlowAdvert === 1) {
             getAdList(15);
           }
-          if(res.intervalSwitch === 1) {
+          if (res.intervalSwitch === 1) {
             let time = res.intervalAdvertDuration * 60 * 1000;
             setInterval(() => {
               $('.try-use-wrap').eq(0).hide();
@@ -932,19 +933,19 @@
             }, time);
           }
         })
-      }else if(sourceType == 2) {
+      } else if (sourceType == 2) {
         getConfigByPhoneType().then((res) => {
-          if(res.isDisconnectionTime === 1){
+          if (res.isDisconnectionTime === 1) {
             let time = res.disconnectionTime * 60 * 1000;
             setTimeout(() => {
               disconnectionFlag = true;
               $('.buy-phone-wrap').eq(0).show();
             }, time);
           }
-          if(res.isShowAd === 1){
+          if (res.isShowAd === 1) {
             getAdList(15);
           }
-          if(res.isIntervalPlayAd === 1) {
+          if (res.isIntervalPlayAd === 1) {
             let time = res.intervalPlayAdTime * 60 * 1000;
             setInterval(() => {
               $('.try-use-wrap').eq(0).hide();
@@ -955,46 +956,46 @@
       }
     }
     // 广告接口
-    function getAdList(type){
+    function getAdList(type) {
       adType = type;
       $.ajax({
-            url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
-            headers: {
-              'Authorization': form.token
-            },
-            data: JSON.stringify({
-              adPlace: type,
-              os: 0
-            }),
-            type: 'POST',
-            dataType: 'json',
-					  contentType: "application/json;charset=UTF-8",
-            success: function (res) {
-              if (res.status === 0) {
-                let list = res.data;
-                let indexs = Math.floor(Math.random()*list.length);
-                videoTime = list[indexs].forcedTime;
-                // $('#source').src = list[0].adVideoBase.videoUrl;
-                $("#source").attr("src", list[indexs].adVideoBase.videoUrl);//更新url
-                $("#source").attr("autoplay", "true");//直接播放
-                videoTimer = setInterval(() =>{
-                  if(videoTime > 0) {
-                    videoTime--;
-                    $('.time-node').eq(0).text(videoTime + 's');
-                  } else {
-                    clearInterval(videoTimer);
-                    $('.time-node').eq(0).text('');
-                  }
-                },1000)
-                if (adType === 16 && sourceType == 1) { // 间隔广告和试用才上报
-                  report(0);
-                }
-                $('.try-use-wrap').eq(0).show();
+        url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
+        headers: {
+          'Authorization': form.token
+        },
+        data: JSON.stringify({
+          adPlace: type,
+          os: 0
+        }),
+        type: 'POST',
+        dataType: 'json',
+        contentType: "application/json;charset=UTF-8",
+        success: function (res) {
+          if (res.status === 0) {
+            let list = res.data;
+            let indexs = Math.floor(Math.random() * list.length);
+            videoTime = list[indexs].forcedTime;
+            // $('#source').src = list[0].adVideoBase.videoUrl;
+            $("#source").attr("src", list[indexs].adVideoBase.videoUrl);//更新url
+            $("#source").attr("autoplay", "true");//直接播放
+            videoTimer = setInterval(() => {
+              if (videoTime > 0) {
+                videoTime--;
+                $('.time-node').eq(0).text(videoTime + 's');
               } else {
-                $.toast(res.msg, "text");
+                clearInterval(videoTimer);
+                $('.time-node').eq(0).text('');
               }
+            }, 1000)
+            if (adType === 16 && sourceType == 1) { // 间隔广告和试用才上报
+              report(0);
             }
-          })
+            $('.try-use-wrap').eq(0).show();
+          } else {
+            $.toast(res.msg, "text");
+          }
+        }
+      })
     }
     //间隔广告上报
     function report(type) {
@@ -1010,7 +1011,7 @@
         type: 'POST',
         dataType: 'json',
         contentType: "application/json;charset=UTF-8",
-        success: function (res) {}
+        success: function (res) { }
       })
     }
     //关闭广告
@@ -1028,13 +1029,13 @@
         return
       }
       let pointName = '';
-      if(sourceType == 1){
+      if (sourceType == 1) {
         pointName = videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
       } else {
         pointName = videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
       }
       systemBuriedPoint(pointName);
-      if(videoTime == 0) {
+      if (videoTime == 0) {
         if (adType === 16 && sourceType == 1) {
           report(1);
         }
@@ -1046,15 +1047,15 @@
     // 点击去购买
     $('.go-bug')[0].addEventListener('click', () => {
       let pointName = '';
-      if(disconnectionFlag) {
+      if (disconnectionFlag) {
         pointName = '激活码-断线-去购买';
-      } else if(sourceType == 1){
+      } else if (sourceType == 1) {
         pointName = videoTime == 0 ? '免费试用-关闭-去购买' : '免费试用-强制关闭-去购买';
       } else {
         pointName = videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
       }
       systemBuriedPoint(pointName);
-      if(getDate){
+      if (getDate) {
         wx.miniProgram.navigateTo({
           url: '/packageA/order/buy/index'
         })
@@ -1066,7 +1067,7 @@
     })
     // 放弃
     $('.cannel-ad-btn')[0].addEventListener('click', () => {
-      if(sourceType == 1){
+      if (sourceType == 1) {
         systemBuriedPoint('免费试用-强制关闭-放弃');
       } else {
         systemBuriedPoint('激活码-强制关闭-放弃');
@@ -1078,7 +1079,7 @@
     // 继续观看
     $('.looking')[0].addEventListener('click', () => {
       $('.look-wrap').eq(0).hide();
-      if(sourceType == 1){
+      if (sourceType == 1) {
         systemBuriedPoint('免费试用-强制关闭-继续观看');
       } else {
         systemBuriedPoint('激活码-强制关闭-继续观看');
@@ -1086,19 +1087,19 @@
     })
 
     // 埋点
-    function systemBuriedPoint(pointName){
+    function systemBuriedPoint(pointName) {
       $.ajax({
         url: baseUrl + "/api/public/v1/systemBuriedPoint/stat",
         headers: {
           'Authorization': form.token
         },
         type: 'post',
-        data:JSON.stringify({
-					pointName: pointName
-				}),
-				contentType:"application/json",
+        data: JSON.stringify({
+          pointName: pointName
+        }),
+        contentType: "application/json",
         dataType: 'json',
-        success: function (res) {}
+        success: function (res) { }
       })
     }
 
@@ -1133,6 +1134,38 @@
         level = 0;
       }
     }
+    var hidden, visibilityChange; 
+    if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support 
+      hidden = "hidden";
+      visibilityChange = "visibilitychange";
+    } else if (typeof document.msHidden !== "undefined") {
+      hidden = "msHidden";
+      visibilityChange = "msvisibilitychange";
+    } else if (typeof document.webkitHidden !== "undefined") {
+      hidden = "webkitHidden";
+      visibilityChange = "webkitvisibilitychange";
+    }
+
+    // 处理页面可见属性的改变
+    document.addEventListener("visibilitychange", function () {
+      if (document[hidden]) {
+        if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
+          tt.miniProgram.switchTab({
+            url: '/pages/home/home'
+          })
+        } else if (window.__wxjs_environment === 'miniprogram') {
+          wx.miniProgram.switchTab({
+            url: '/pages/home/home'
+          })
+        } else {
+          document.addEventListener('UniAppJSBridgeReady', function () {
+            uni.navigateTo({
+              url: '/pages/index/index'
+            });
+          })
+        }
+      }
+    }, false);
     window.onbeforeunload = function () {
       wsss.close();
       decodeWoker.postMessage('close');