sunshibo 4 дней назад
Родитель
Сommit
7babdd7b1d
1 измененных файлов с 68 добавлено и 20 удалено
  1. 68 20
      HBuilderProjects/shareAiConsult.html

+ 68 - 20
HBuilderProjects/shareAiConsult.html

@@ -192,7 +192,6 @@
     }
     }
 
 
     .fab-dock__slot {
     .fab-dock__slot {
-      position: relative;
       width: 100%;
       width: 100%;
       max-width: 280px;
       max-width: 280px;
       height: 48px;
       height: 48px;
@@ -230,10 +229,6 @@
 
 
     #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;
@@ -242,11 +237,22 @@
       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;
     }
     }
 
 
+    body.is-wechat.wx-jssdk-ready #openApp {
+      display: none !important;
+    }
+
+    body.is-wechat.wx-open-tag-broken #launch-btn {
+      display: none !important;
+    }
+
+    body.is-wechat.wx-open-tag-broken #openApp {
+      display: flex !important;
+    }
+
     .fab-wrap .fab {
     .fab-wrap .fab {
       pointer-events: auto;
       pointer-events: auto;
     }
     }
@@ -385,6 +391,12 @@
       var wxJssdkInitPromise = null;
       var wxJssdkInitPromise = null;
       var wxOpenTagBroken = false;
       var wxOpenTagBroken = false;
 
 
+      function markWxOpenTagBroken() {
+        wxOpenTagBroken = true;
+        document.body.classList.add("wx-open-tag-broken");
+        document.body.classList.remove("wx-jssdk-ready");
+      }
+
       function escHtml(s) {
       function escHtml(s) {
         return String(s || "")
         return String(s || "")
           .replace(/&/g, "&")
           .replace(/&/g, "&")
@@ -1001,7 +1013,11 @@
           wx.config(wxConfigParams);
           wx.config(wxConfigParams);
           wx.ready(function () {
           wx.ready(function () {
             weChatJssdkConfigured = true;
             weChatJssdkConfigured = true;
-            if (!wxOpenTagBroken) {
+            if (wxOpenTagBroken) {
+              document.body.classList.add("wx-open-tag-broken");
+              document.body.classList.remove("wx-jssdk-ready");
+            } else {
+              document.body.classList.remove("wx-open-tag-broken");
               document.body.classList.add("wx-jssdk-ready");
               document.body.classList.add("wx-jssdk-ready");
             }
             }
             refreshWxLaunchTagAttrs();
             refreshWxLaunchTagAttrs();
@@ -1033,11 +1049,6 @@
         });
         });
       }
       }
 
 
-      function disableWxLaunchTagUi() {
-        wxOpenTagBroken = true;
-        document.body.classList.remove("wx-jssdk-ready");
-      }
-
       function refreshWxLaunchTagAttrs(useBarePathOnly) {
       function refreshWxLaunchTagAttrs(useBarePathOnly) {
         var tag = document.getElementById("launch-btn");
         var tag = document.getElementById("launch-btn");
         if (!tag) return;
         if (!tag) return;
@@ -1064,16 +1075,42 @@
               : detail && detail.errmsg
               : detail && detail.errmsg
                 ? String(detail.errmsg)
                 ? String(detail.errmsg)
                 : "";
                 : "";
-          console.warn("[wx-open-launch-app]", detail);
-          if (/launch:fail/i.test(errMsg) && !getWxShareEntryFrom()) {
-            showAppOpenFailTip("请前往应用商店下载U店在哪app");
-          } else {
+          console.warn(
+            "[wx-open-launch-app]",
+            detail,
+            "extinfo=",
+            tag.getAttribute("extinfo")
+          );
+
+          if (/launch:fail_check/i.test(errMsg)) {
+            markWxOpenTagBroken();
             showAppOpenFailTip(
             showAppOpenFailTip(
-              errMsg
-                ? "未能打开 App:" + errMsg
-                : "未能打开 App,请确认已安装最新版「U店在哪」"
+              "请用微信分享卡片进入,或确认已安装最新版「U店在哪」"
             );
             );
+            return;
+          }
+
+          if (
+            /launch:fail/i.test(errMsg) &&
+            !tag._wxLaunchBareRetried &&
+            tag.getAttribute("extinfo") !== buildWeChatLaunchExtinfo(true)
+          ) {
+            tag._wxLaunchBareRetried = true;
+            refreshWxLaunchTagAttrs(true);
+            showFabToast("请再点一次「和U宝继续聊」");
+            return;
           }
           }
+
+          if (/launch:fail/i.test(errMsg) && !getWxShareEntryFrom()) {
+            showAppOpenFailTip("请前往应用商店下载U店在哪app");
+            return;
+          }
+
+          showAppOpenFailTip(
+            errMsg
+              ? "未能打开 App:" + errMsg
+              : "未能打开 App,请确认已安装最新版「U店在哪」"
+          );
         });
         });
       }
       }
 
 
@@ -1254,6 +1291,10 @@
 
 
       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;
@@ -1280,7 +1321,7 @@
         }
         }
 
 
         document.addEventListener("WeixinOpenTagsError", function (e) {
         document.addEventListener("WeixinOpenTagsError", function (e) {
-          disableWxLaunchTagUi();
+          markWxOpenTagBroken();
           console.warn("[WeixinOpenTagsError]", e && e.detail);
           console.warn("[WeixinOpenTagsError]", e && e.detail);
         });
         });
 
 
@@ -1292,6 +1333,13 @@
                 showFabToast(
                 showFabToast(
                   wxInitLastError || "微信 SDK 初始化中,请稍候再点底部按钮"
                   wxInitLastError || "微信 SDK 初始化中,请稍候再点底部按钮"
                 );
                 );
+                initWeChatOpenLaunchApp(true);
+                return;
+              }
+              if (wxOpenTagBroken) {
+                showAppOpenFailTip(
+                  "请使用 App「分享到微信」后点分享卡片进入,或确认已安装最新版「U店在哪」"
+                );
               }
               }
             });
             });
           }
           }