|
|
@@ -497,22 +497,17 @@
|
|
|
|
|
|
.fab-wx-hit {
|
|
|
display: none;
|
|
|
- width: 100%;
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ top: 0;
|
|
|
height: 48px;
|
|
|
+ z-index: 3;
|
|
|
}
|
|
|
|
|
|
- /* wx.config 成功后:隐藏普通按钮,只显示开放标签(真机必须直接点开放标签) */
|
|
|
- #fabDock.wx-open-enabled #openApp {
|
|
|
- display: none !important;
|
|
|
- }
|
|
|
-
|
|
|
+ /* 底层 #openApp 始终显示;上层透明开放标签接收点击(标签未渲染时仍能看见并点底层按钮) */
|
|
|
#fabDock.wx-open-enabled .fab-wx-hit {
|
|
|
display: block;
|
|
|
- position: relative;
|
|
|
- left: auto;
|
|
|
- right: auto;
|
|
|
- top: auto;
|
|
|
- z-index: 3;
|
|
|
}
|
|
|
|
|
|
#launch-btn {
|
|
|
@@ -1057,18 +1052,11 @@
|
|
|
margin: 0;
|
|
|
padding: 0;
|
|
|
border: none;
|
|
|
+ opacity: 0;
|
|
|
background: transparent;
|
|
|
}
|
|
|
- .wx-open-app-btn img {
|
|
|
- display: block;
|
|
|
- width: 100%;
|
|
|
- height: 48px;
|
|
|
- object-fit: contain;
|
|
|
- }
|
|
|
</style>
|
|
|
- <button class="wx-open-app-btn" aria-label="APP内打开">
|
|
|
- <img src="https://test.ailien.shop/h5/HBuilderProjects/images/uBtn.png" alt="APP内打开" />
|
|
|
- </button>
|
|
|
+ <button class="wx-open-app-btn" aria-label="APP内打开">打开</button>
|
|
|
</script>
|
|
|
</wx-open-launch-app>
|
|
|
</div>
|
|
|
@@ -1519,7 +1507,6 @@
|
|
|
wxSignUrlFullBeforeStrip = '';
|
|
|
}
|
|
|
scheduleWxOpenTagRefresh();
|
|
|
- showFabToast('请点击底部 APP内打开(微信开放标签)');
|
|
|
resolve(true);
|
|
|
});
|
|
|
wx.error(function (err) {
|
|
|
@@ -1569,6 +1556,27 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ function tryTriggerWxOpenLaunchApp() {
|
|
|
+ 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 (eWx) {
|
|
|
+ console.warn('[wx-open-launch-app] trigger', eWx);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
function refreshWxLaunchTagAttrs() {
|
|
|
var tag = document.getElementById('launch-btn');
|
|
|
if (!tag) return;
|
|
|
@@ -1606,17 +1614,6 @@
|
|
|
}, ms);
|
|
|
})(delays[i]);
|
|
|
}
|
|
|
- window.setTimeout(function () {
|
|
|
- if (!weChatJssdkConfigured) return;
|
|
|
- var tag = document.getElementById('launch-btn');
|
|
|
- var h = tag ? tag.offsetHeight || 0 : 0;
|
|
|
- if (h >= 20) return;
|
|
|
- var dock = document.getElementById('fabDock');
|
|
|
- if (dock) dock.classList.remove('wx-open-enabled');
|
|
|
- showAppOpenFailTip(
|
|
|
- '开放标签未渲染(高度为 0)。请检查:移动应用 AppID、开放平台绑定、测试号 JS 域名;链接加 wxDebug=1 查看 config。'
|
|
|
- );
|
|
|
- }, 2800);
|
|
|
}
|
|
|
|
|
|
var openAppFabClickLock = 0;
|
|
|
@@ -1624,16 +1621,6 @@
|
|
|
var now = Date.now();
|
|
|
if (now - openAppFabClickLock < 500) return;
|
|
|
openAppFabClickLock = now;
|
|
|
- var dock = document.getElementById('fabDock');
|
|
|
- if (
|
|
|
- isWeChatInAppBrowser() &&
|
|
|
- weChatJssdkConfigured &&
|
|
|
- dock &&
|
|
|
- dock.classList.contains('wx-open-enabled')
|
|
|
- ) {
|
|
|
- showFabToast('请点 APP内打开 按钮(由微信开放标签唤起,非普通链接)');
|
|
|
- return;
|
|
|
- }
|
|
|
tryOpenHBuilderApp();
|
|
|
}
|
|
|
|
|
|
@@ -1785,7 +1772,15 @@
|
|
|
}
|
|
|
|
|
|
if (inWx && weChatJssdkConfigured) {
|
|
|
- showFabToast('请使用底部 APP内打开 按钮(微信开放标签)');
|
|
|
+ refreshWxLaunchTagAttrs();
|
|
|
+ updateFabOpenLayer();
|
|
|
+ if (tryTriggerWxOpenLaunchApp()) {
|
|
|
+ showFabToast('正在打开 U店在哪…');
|
|
|
+ } else {
|
|
|
+ showAppOpenFailTip(
|
|
|
+ '请点击底部 APP内打开 图片按钮;若仍无效,请用 wxDebug=1 查看开放标签是否 launch:fail。'
|
|
|
+ );
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
|