|
|
@@ -469,38 +469,32 @@
|
|
|
pointer-events: auto;
|
|
|
}
|
|
|
|
|
|
- .fab-dock__inner {
|
|
|
- position: relative;
|
|
|
- width: 100%;
|
|
|
- max-width: 320px;
|
|
|
- height: 48px;
|
|
|
- margin: 0 auto;
|
|
|
+ /* 底部按钮始终展示,不因 wx.config 切换而隐藏 */
|
|
|
+ #fabDock {
|
|
|
+ display: block;
|
|
|
}
|
|
|
|
|
|
- /* 开放标签透明盖在可见按钮上;勿隐藏底层 #openApp,否则 wx.ready 后会像「按钮消失」 */
|
|
|
- .fab-wx-layer {
|
|
|
- display: none;
|
|
|
- position: absolute;
|
|
|
- left: 0;
|
|
|
- right: 0;
|
|
|
- top: 0;
|
|
|
- height: 48px;
|
|
|
- z-index: 2;
|
|
|
+ #fabDock .fab {
|
|
|
pointer-events: auto;
|
|
|
}
|
|
|
|
|
|
- #fabDock.wx-launch-ready .fab-wx-layer {
|
|
|
- display: block;
|
|
|
+ /* 开放标签仅满足 openTagList,不占位、不遮挡可见按钮 */
|
|
|
+ #fabWxHost {
|
|
|
+ position: fixed;
|
|
|
+ left: -9999px;
|
|
|
+ top: 0;
|
|
|
+ width: 1px;
|
|
|
+ height: 1px;
|
|
|
+ overflow: hidden;
|
|
|
+ opacity: 0;
|
|
|
+ pointer-events: none;
|
|
|
+ visibility: hidden;
|
|
|
}
|
|
|
|
|
|
#launch-btn {
|
|
|
display: block;
|
|
|
- width: 100%;
|
|
|
- height: 48px;
|
|
|
- min-height: 48px;
|
|
|
- margin: 0;
|
|
|
- pointer-events: auto;
|
|
|
- overflow: visible;
|
|
|
+ width: 1px;
|
|
|
+ height: 1px;
|
|
|
}
|
|
|
|
|
|
.fab {
|
|
|
@@ -1001,31 +995,26 @@
|
|
|
<div id="staffGroupsMount"></div>
|
|
|
</section>
|
|
|
</div>
|
|
|
- <!-- 底层 #openApp 始终可见;微信 JSSDK 成功后 #fabWxLayer 透明叠加以唤起 App -->
|
|
|
<div id="fabDock" class="fab-wrap">
|
|
|
- <div class="fab-dock__inner">
|
|
|
- <button type="button" class="fab" id="openApp">
|
|
|
- <img src="images/uBtn.png" alt="APP内打开" decoding="async">
|
|
|
- </button>
|
|
|
- <div id="fabWxLayer" class="fab-wx-layer" aria-hidden="true">
|
|
|
- <wx-open-launch-app id="launch-btn" appid="wx5598889b28511717">
|
|
|
- <script type="text/wxtag-template">
|
|
|
- <style>
|
|
|
- .wx-open-hit {
|
|
|
- display: block;
|
|
|
- width: 100%;
|
|
|
- height: 48px;
|
|
|
- margin: 0;
|
|
|
- padding: 0;
|
|
|
- border: none;
|
|
|
- opacity: 0;
|
|
|
- background: transparent;
|
|
|
- }
|
|
|
- </style>
|
|
|
- <button class="wx-open-hit" aria-label="APP内打开">打开</button>
|
|
|
- </script>
|
|
|
- </wx-open-launch-app>
|
|
|
- </div>
|
|
|
+ <button type="button" class="fab" id="openApp">
|
|
|
+ <img src="images/uBtn.png" alt="APP内打开" decoding="async">
|
|
|
+ </button>
|
|
|
+ <div id="fabWxHost" aria-hidden="true">
|
|
|
+ <wx-open-launch-app id="launch-btn" appid="wx5598889b28511717">
|
|
|
+ <script type="text/wxtag-template">
|
|
|
+ <style>
|
|
|
+ .wx-open-hit {
|
|
|
+ display: block;
|
|
|
+ width: 1px;
|
|
|
+ height: 1px;
|
|
|
+ opacity: 0;
|
|
|
+ border: 0;
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+ <button class="wx-open-hit" aria-label="APP内打开">打开</button>
|
|
|
+ </script>
|
|
|
+ </wx-open-launch-app>
|
|
|
</div>
|
|
|
<div class="home-indicator" aria-hidden="true"></div>
|
|
|
</div>
|
|
|
@@ -1404,7 +1393,6 @@
|
|
|
tag.setAttribute('extinfo', buildWeChatLaunchExtinfo());
|
|
|
} catch (eReady) {}
|
|
|
}
|
|
|
- setFabLaunchMode('wx');
|
|
|
resolve(true);
|
|
|
});
|
|
|
wx.error(function (err) {
|
|
|
@@ -1420,7 +1408,6 @@
|
|
|
) {
|
|
|
weChatJssdkConfigured = false;
|
|
|
showAppOpenFailTip(formatWxConfigErrorTip(err, urlForWx));
|
|
|
- setFabLaunchMode('scheme');
|
|
|
resolve(false);
|
|
|
return;
|
|
|
}
|
|
|
@@ -1432,7 +1419,6 @@
|
|
|
if (!sign2) {
|
|
|
weChatJssdkConfigured = false;
|
|
|
showAppOpenFailTip(formatWxConfigErrorTip(err, urlForWx));
|
|
|
- setFabLaunchMode('scheme');
|
|
|
resolve(false);
|
|
|
return;
|
|
|
}
|
|
|
@@ -1441,24 +1427,33 @@
|
|
|
.catch(function () {
|
|
|
weChatJssdkConfigured = false;
|
|
|
showAppOpenFailTip(formatWxConfigErrorTip(err, urlForWx));
|
|
|
- setFabLaunchMode('scheme');
|
|
|
resolve(false);
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- function setFabLaunchMode(mode) {
|
|
|
- var dock = document.getElementById('fabDock');
|
|
|
- var layer = document.getElementById('fabWxLayer');
|
|
|
- if (!dock) return;
|
|
|
- if (mode === 'wx') {
|
|
|
- dock.classList.add('wx-launch-ready');
|
|
|
- if (layer) layer.setAttribute('aria-hidden', 'false');
|
|
|
- } else {
|
|
|
- dock.classList.remove('wx-launch-ready');
|
|
|
- if (layer) layer.setAttribute('aria-hidden', 'true');
|
|
|
+ /** 点击可见按钮时,若 JSSDK 已就绪则先尝试触发隐藏开放标签(部分机型有效) */
|
|
|
+ function tryTriggerWxOpenLaunchApp() {
|
|
|
+ if (!isWeChatInAppBrowser() || !weChatJssdkConfigured) return false;
|
|
|
+ var tag = document.getElementById('launch-btn');
|
|
|
+ if (!tag) return false;
|
|
|
+ try {
|
|
|
+ if (tag.shadowRoot) {
|
|
|
+ var inner = tag.shadowRoot.querySelector('button');
|
|
|
+ if (inner && typeof inner.click === 'function') {
|
|
|
+ inner.click();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (typeof tag.click === 'function') {
|
|
|
+ tag.click();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } catch (eWxClick) {
|
|
|
+ console.warn('[wx-open-launch-app] trigger click', eWxClick);
|
|
|
}
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
function bindWeChatLaunchTagEvents() {
|
|
|
@@ -1474,7 +1469,6 @@
|
|
|
var detail = e && e.detail;
|
|
|
console.warn('[wx-open-launch-app]', detail);
|
|
|
weChatJssdkConfigured = false;
|
|
|
- setFabLaunchMode('scheme');
|
|
|
var errMsg =
|
|
|
detail && detail.errMsg
|
|
|
? String(detail.errMsg)
|
|
|
@@ -1503,16 +1497,12 @@
|
|
|
var signPageUrl = getWxConfigSignUrl();
|
|
|
var reqUrl = buildWxGetConfigRequestUrl(signPageUrl);
|
|
|
|
|
|
- if (!inWx) {
|
|
|
- setFabLaunchMode('scheme');
|
|
|
- } else {
|
|
|
+ if (inWx) {
|
|
|
var domainHint = checkWxJsSafeDomainHint();
|
|
|
if (domainHint) {
|
|
|
console.warn('[wx]', domainHint);
|
|
|
showAppOpenFailTip(domainHint);
|
|
|
}
|
|
|
- /* 签名完成前仍显示普通按钮,避免底部长时间空白 */
|
|
|
- setFabLaunchMode('scheme');
|
|
|
}
|
|
|
|
|
|
console.log('[wx] GET', reqUrl);
|
|
|
@@ -1527,7 +1517,6 @@
|
|
|
}
|
|
|
if (typeof wx === 'undefined') {
|
|
|
console.warn('[wx] jweixin not loaded');
|
|
|
- setFabLaunchMode('scheme');
|
|
|
return false;
|
|
|
}
|
|
|
bindWeChatLaunchTagEvents();
|
|
|
@@ -1536,16 +1525,12 @@
|
|
|
showAppOpenFailTip(
|
|
|
'微信 JSSDK:getWxConfig 未返回可用的 appId/timestamp/nonceStr/signature。'
|
|
|
);
|
|
|
- setFabLaunchMode('scheme');
|
|
|
return false;
|
|
|
}
|
|
|
return applyWxConfig(sign, signPageUrl);
|
|
|
})
|
|
|
.catch(function (e) {
|
|
|
console.warn('[wx] init failed', e);
|
|
|
- if (inWx) {
|
|
|
- setFabLaunchMode('scheme');
|
|
|
- }
|
|
|
return false;
|
|
|
});
|
|
|
}
|
|
|
@@ -1584,10 +1569,8 @@
|
|
|
* 系统浏览器:scheme 唤起;微信内优先 wx-open-launch-app,失败再 scheme(不再弹「在浏览器中打开」)。
|
|
|
*/
|
|
|
function tryOpenHBuilderApp() {
|
|
|
- /** 微信内且开放标签已配置:仅开放标签可唤起,scheme 会被拦截,勿误报「去应用商店」 */
|
|
|
- if (isWeChatInAppBrowser() && weChatJssdkConfigured) {
|
|
|
- showAppOpenFailTip('请使用页面底部「APP内打开」按钮(微信开放标签)。');
|
|
|
- return;
|
|
|
+ if (isWeChatInAppBrowser()) {
|
|
|
+ tryTriggerWxOpenLaunchApp();
|
|
|
}
|
|
|
|
|
|
var deepLink = buildAppDeepLink();
|
|
|
@@ -2811,6 +2794,7 @@
|
|
|
tryOpenHBuilderApp();
|
|
|
});
|
|
|
}
|
|
|
+ /* 底部 #fabDock / #openApp 不做 display 切换,进入页即显示 */
|
|
|
initWeChatOpenLaunchApp();
|
|
|
}
|
|
|
|