sunshibo hace 4 días
padre
commit
9ecad02d28
Se han modificado 1 ficheros con 28 adiciones y 70 borrados
  1. 28 70
      HBuilderProjects/shareAiConsult.html

+ 28 - 70
HBuilderProjects/shareAiConsult.html

@@ -192,6 +192,7 @@
     }
     }
 
 
     .fab-dock__slot {
     .fab-dock__slot {
+      position: relative;
       width: 100%;
       width: 100%;
       max-width: 280px;
       max-width: 280px;
       height: 48px;
       height: 48px;
@@ -229,6 +230,10 @@
 
 
     #launch-btn {
     #launch-btn {
       display: none;
       display: none;
+      position: absolute;
+      left: 0;
+      top: 0;
+      z-index: 2;
       width: 100%;
       width: 100%;
       height: 48px;
       height: 48px;
       min-height: 48px;
       min-height: 48px;
@@ -237,21 +242,9 @@
       opacity: 1;
       opacity: 1;
     }
     }
 
 
+    /* 与 secondShareGoods 一致:微信就绪后显示开放标签;openApp 保持可见作兜底 */
     body.is-wechat.wx-jssdk-ready #launch-btn {
     body.is-wechat.wx-jssdk-ready #launch-btn {
       display: block;
       display: block;
-      pointer-events: auto;
-    }
-
-    body.is-wechat.wx-jssdk-ready #openApp {
-      display: none !important;
-    }
-
-    body.is-wechat.wx-launch-fallback #launch-btn {
-      display: none !important;
-    }
-
-    body.is-wechat.wx-launch-fallback #openApp {
-      display: flex !important;
     }
     }
 
 
     .fab-wrap .fab {
     .fab-wrap .fab {
@@ -390,6 +383,7 @@
       var wxConfigSignRetriedBaseUrl = false;
       var wxConfigSignRetriedBaseUrl = false;
       var wxInitLastError = "";
       var wxInitLastError = "";
       var wxJssdkInitPromise = null;
       var wxJssdkInitPromise = null;
+      var wxOpenTagBroken = false;
 
 
       function escHtml(s) {
       function escHtml(s) {
         return String(s || "")
         return String(s || "")
@@ -1007,15 +1001,16 @@
           wx.config(wxConfigParams);
           wx.config(wxConfigParams);
           wx.ready(function () {
           wx.ready(function () {
             weChatJssdkConfigured = true;
             weChatJssdkConfigured = true;
-            document.body.classList.remove("wx-launch-fallback");
-            document.body.classList.add("wx-jssdk-ready");
+            if (!wxOpenTagBroken) {
+              document.body.classList.add("wx-jssdk-ready");
+            }
             refreshWxLaunchTagAttrs();
             refreshWxLaunchTagAttrs();
             console.log("[wx.config] ready, htmlUrl=", htmlUrl);
             console.log("[wx.config] ready, htmlUrl=", htmlUrl);
             resolve(true);
             resolve(true);
           });
           });
           wx.error(function (err) {
           wx.error(function (err) {
             weChatJssdkConfigured = false;
             weChatJssdkConfigured = false;
-            enableWxLaunchFallback();
+            document.body.classList.remove("wx-jssdk-ready");
             wxJssdkInitPromise = null;
             wxJssdkInitPromise = null;
             var errMsg = getWxErrMsg(err);
             var errMsg = getWxErrMsg(err);
             setWxInitError(formatWxConfigErrorTip(err, htmlUrl));
             setWxInitError(formatWxConfigErrorTip(err, htmlUrl));
@@ -1038,8 +1033,8 @@
         });
         });
       }
       }
 
 
-      function enableWxLaunchFallback() {
-        document.body.classList.add("wx-launch-fallback");
+      function disableWxLaunchTagUi() {
+        wxOpenTagBroken = true;
         document.body.classList.remove("wx-jssdk-ready");
         document.body.classList.remove("wx-jssdk-ready");
       }
       }
 
 
@@ -1069,45 +1064,16 @@
               : detail && detail.errmsg
               : detail && detail.errmsg
                 ? String(detail.errmsg)
                 ? String(detail.errmsg)
                 : "";
                 : "";
-          console.warn(
-            "[wx-open-launch-app]",
-            detail,
-            "extinfo=",
-            tag.getAttribute("extinfo")
-          );
-
-          if (/launch:fail_check/i.test(errMsg)) {
-            enableWxLaunchFallback();
-            showAppOpenFailTip(
-              "请用微信分享卡片进入,或确认已安装最新版「U店在哪」"
-            );
-            return;
-          }
-
-          if (
-            /launch:fail/i.test(errMsg) &&
-            !tag._wxLaunchBareRetried &&
-            tag.getAttribute("extinfo") !== buildWeChatLaunchExtinfo(true)
-          ) {
-            tag._wxLaunchBareRetried = true;
-            refreshWxLaunchTagAttrs(true);
-            showFabToast("请再点一次「和U宝继续聊」");
-            return;
-          }
-
+          console.warn("[wx-open-launch-app]", detail);
           if (/launch:fail/i.test(errMsg) && !getWxShareEntryFrom()) {
           if (/launch:fail/i.test(errMsg) && !getWxShareEntryFrom()) {
+            showAppOpenFailTip("请前往应用商店下载U店在哪app");
+          } else {
             showAppOpenFailTip(
             showAppOpenFailTip(
-              "当前环境无法直接打开 App,请使用 App「分享到微信」后点分享卡片进入"
+              errMsg
+                ? "未能打开 App:" + errMsg
+                : "未能打开 App,请确认已安装最新版「U店在哪」"
             );
             );
-            return;
           }
           }
-
-          enableWxLaunchFallback();
-          showAppOpenFailTip(
-            errMsg
-              ? "未能打开 App:" + errMsg
-              : "未能打开 App,请确认已安装最新版「U店在哪」"
-          );
         });
         });
       }
       }
 
 
@@ -1288,10 +1254,6 @@
 
 
       function tryOpenHBuilderApp() {
       function tryOpenHBuilderApp() {
         if (isWeChatInAppBrowser()) return;
         if (isWeChatInAppBrowser()) return;
-        if (!isWxPcBrowser()) {
-          tryOpenHBuilderAppViaScheme();
-          return;
-        }
         tryFetchWxConfigOnPcClick().then(function () {
         tryFetchWxConfigOnPcClick().then(function () {
           if (isWxConfigOnClickDebug() && !isWxForceDebug() && !isWxPcAutoDebugHost()) {
           if (isWxConfigOnClickDebug() && !isWxForceDebug() && !isWxPcAutoDebugHost()) {
             return;
             return;
@@ -1318,29 +1280,25 @@
         }
         }
 
 
         document.addEventListener("WeixinOpenTagsError", function (e) {
         document.addEventListener("WeixinOpenTagsError", function (e) {
-          enableWxLaunchFallback();
+          disableWxLaunchTagUi();
           console.warn("[WeixinOpenTagsError]", e && e.detail);
           console.warn("[WeixinOpenTagsError]", e && e.detail);
         });
         });
 
 
-        var openBtnWx = document.getElementById("openApp");
-        if (openBtnWx) {
-          if (isWeChatInAppBrowser()) {
+        if (isWeChatInAppBrowser()) {
+          var openBtnWx = document.getElementById("openApp");
+          if (openBtnWx) {
             openBtnWx.addEventListener("click", function () {
             openBtnWx.addEventListener("click", function () {
               if (!weChatJssdkConfigured) {
               if (!weChatJssdkConfigured) {
                 showFabToast(
                 showFabToast(
                   wxInitLastError || "微信 SDK 初始化中,请稍候再点底部按钮"
                   wxInitLastError || "微信 SDK 初始化中,请稍候再点底部按钮"
                 );
                 );
-                initWeChatOpenLaunchApp(true);
-                return;
-              }
-              if (document.body.classList.contains("wx-launch-fallback")) {
-                showAppOpenFailTip(
-                  "请使用 App「分享到微信」后点分享卡片进入,或确认已安装最新版「U店在哪」"
-                );
               }
               }
             });
             });
-          } else {
-            openBtnWx.addEventListener("click", tryOpenHBuilderApp);
+          }
+        } else {
+          var openAppBtn = document.getElementById("openApp");
+          if (openAppBtn) {
+            openAppBtn.addEventListener("click", tryOpenHBuilderApp);
           }
           }
         }
         }