소스 검색

Merge branch 'main' into feature/v1.0.33

lianbingjie 1 년 전
부모
커밋
f8640e6075
1개의 변경된 파일58개의 추가작업 그리고 48개의 파일을 삭제
  1. 58 48
      apps/mobile/src/utils/callFn/checkUpdate.js

+ 58 - 48
apps/mobile/src/utils/callFn/checkUpdate.js

@@ -28,57 +28,67 @@ function compareVersion (curVersion, upVersion) {
  */
 export function checkAppUpdate () {
   if (envs.inApp) {
-    try {
-      if(!mySysIsIos() && (localStorage.checkUpdate==undefined || Date.parse(new Date())/1000-parseInt(localStorage.checkUpdate)>604800) && compareVersion(JyObj.getVersion(),"3.0.4")) {
-        var appVersion = JyObj.getVersion();
-        var appToken = JyObj.getUserToken();
-        var appChannel = getChannel();
-        var appAndroidVersion = androidVersion();
-        $.post("/jyapp/free/checkUpdate",{from:"server-mainSearch",token:appToken,version:appVersion,phonetype:getPhoneType(),channel:appChannel,system:appAndroidVersion},function(r){
-          if(r.isNeedUpdate == 0){
-            return;
-          }
-          // ActiveTipFlag = false;
-          if(compareVersion('3.0.0',appVersion) && appChannel != "huawei" && appChannel != "vivo" && appAndroidVersion != "" && appAndroidVersion < 11){
-            try {
-              JyObj.doUpdateApp();
-            } catch(e) {}
-          }else{
-            var updateHtml = '<div id="app-version-update-tip" style="z-index:999999;position:fixed;top:0px;bottom:0px;right:0px;left:0px;background-color: rgba(0,0,0,.5)">'
-              +'<div style="position: fixed;display: inline-block;background-color:#fff;border-radius: 10px;width: 300px;padding-top: 15px;left: 50%;margin-left: -150px;top: 50%;margin-top:-83px;">'
-              +'<div style="padding: 0px 15px 10px 15px;border-bottom: 1px solid #d3d3d3;text-align:center;">'
-              +'<div style="font-size: 16px;font-weight: 400;color: #000;">发现最新版本</div>'
-              +'<div style="font-size: 14px;margin: 10px 0px;font-weight: 400;color: #000;">监测到新版本<font id="app-new-version">'+r.version+'</font> (当前版本:<font id="app-old-version">'+appVersion+'</font>)</div>'
-              +'<div style="font-size: 12px;line-height: 20px;">如更新失败,请到剑鱼官网(jianyu360.cn)以及应用市场进行下载更新!</div>'
-              +'</div>';
-            if(r.isNeedUpdate == 2){
-              updateHtml +='<div style="font-weight: 400;height:50px;line-height:50px;color:#157efb;font-size:16px;text-align:center;" id="app-version-update">更新</div>';
-              $("body").css("background-color","rgba(0,0,0,.5)").empty();
-              JyObj.hiddenBottom("0");
-              history.pushState({},"gotoupdate","/gotoupdate");
+    if (envs.inIOS) {
+      // IOS 原有逻辑
+      try {
+        afterPageInit()
+      } catch (e) {
+        console.warn(e);
+      }
+    } else {
+      // 安卓原有逻辑
+      try {
+        if((localStorage.checkUpdate==undefined || Date.parse(new Date())/1000-parseInt(localStorage.checkUpdate)>604800) && compareVersion(JyObj.getVersion(),"3.0.4")) {
+          var appVersion = JyObj.getVersion();
+          var appToken = JyObj.getUserToken();
+          var appChannel = getChannel();
+          var appAndroidVersion = androidVersion();
+          $.post("/jyapp/free/checkUpdate",{from:"server-mainSearch",token:appToken,version:appVersion,phonetype:getPhoneType(),channel:appChannel,system:appAndroidVersion},function(r){
+            if(r.isNeedUpdate == 0){
+              return;
+            }
+            // ActiveTipFlag = false;
+            if(compareVersion('3.0.0',appVersion) && appChannel != "huawei" && appChannel != "vivo" && appAndroidVersion != "" && appAndroidVersion < 11){
+              try {
+                JyObj.doUpdateApp();
+              } catch(e) {}
             }else{
-              $("#myModal-tap").remove();
-              updateHtml +='<div style="font-weight: 400;display: inline-block;width: 50%;height:50px;line-height:50px;color:#157efb;font-size:16px;text-align:center;" id="app-version-noupdate">不更新<a style="height:100%;border-right:1px solid #d3d3d3;float:right;"></a></div><div style="font-weight: 400;display: inline-block;width: 50%;height:50px;line-height:50px;color:#157efb;font-size:16px;text-align:center;" id="app-version-update">更新</div>';
+              var updateHtml = '<div id="app-version-update-tip" style="z-index:999999;position:fixed;top:0px;bottom:0px;right:0px;left:0px;background-color: rgba(0,0,0,.5)">'
+                +'<div style="position: fixed;display: inline-block;background-color:#fff;border-radius: 10px;width: 300px;padding-top: 15px;left: 50%;margin-left: -150px;top: 50%;margin-top:-83px;">'
+                +'<div style="padding: 0px 15px 10px 15px;border-bottom: 1px solid #d3d3d3;text-align:center;">'
+                +'<div style="font-size: 16px;font-weight: 400;color: #000;">发现最新版本</div>'
+                +'<div style="font-size: 14px;margin: 10px 0px;font-weight: 400;color: #000;">监测到新版本<font id="app-new-version">'+r.version+'</font> (当前版本:<font id="app-old-version">'+appVersion+'</font>)</div>'
+                +'<div style="font-size: 12px;line-height: 20px;">如更新失败,请到剑鱼官网(jianyu360.cn)以及应用市场进行下载更新!</div>'
+                +'</div>';
+              if(r.isNeedUpdate == 2){
+                updateHtml +='<div style="font-weight: 400;height:50px;line-height:50px;color:#157efb;font-size:16px;text-align:center;" id="app-version-update">更新</div>';
+                $("body").css("background-color","rgba(0,0,0,.5)").empty();
+                JyObj.hiddenBottom("0");
+                history.pushState({},"gotoupdate","/gotoupdate");
+              }else{
+                $("#myModal-tap").remove();
+                updateHtml +='<div style="font-weight: 400;display: inline-block;width: 50%;height:50px;line-height:50px;color:#157efb;font-size:16px;text-align:center;" id="app-version-noupdate">不更新<a style="height:100%;border-right:1px solid #d3d3d3;float:right;"></a></div><div style="font-weight: 400;display: inline-block;width: 50%;height:50px;line-height:50px;color:#157efb;font-size:16px;text-align:center;" id="app-version-update">更新</div>';
+              }
+              updateHtml +='</div></div>';
+              $("body").append(updateHtml);
+              newVersionUpdateLog("server_tip",r.version);
+              $("#app-version-noupdate").on("click",function(){
+                localStorage.checkUpdate=Date.parse(new Date())/1000;
+                $("#app-version-update-tip").remove();
+                newVersionUpdateLog("server_cancel",r.version);
+              });
+              $("#app-version-update").on("click",function(){
+                localStorage.checkUpdate=Date.parse(new Date())/1000;
+                $("#app-version-update-tip").remove();
+                newVersionUpdateLog("server_update",r.version);
+                window.location.href=r.apkurl;
+              });
             }
-            updateHtml +='</div></div>';
-            $("body").append(updateHtml);
-            newVersionUpdateLog("server_tip",r.version);
-            $("#app-version-noupdate").on("click",function(){
-              localStorage.checkUpdate=Date.parse(new Date())/1000;
-              $("#app-version-update-tip").remove();
-              newVersionUpdateLog("server_cancel",r.version);
-            });
-            $("#app-version-update").on("click",function(){
-              localStorage.checkUpdate=Date.parse(new Date())/1000;
-              $("#app-version-update-tip").remove();
-              newVersionUpdateLog("server_update",r.version);
-              window.location.href=r.apkurl;
-            });
-          }
-        });
+          });
+        }
+      } catch (error) {
+        console.log(error)
       }
-    } catch (error) {
-      console.log(error)
     }
   }
 }