|
|
@@ -73,12 +73,11 @@
|
|
|
opacity: 1;
|
|
|
}
|
|
|
|
|
|
- /* 仅分享卡片等场景展示开放标签;复制链接进入见 .wx-copy-link-entry */
|
|
|
- body.is-wechat.wx-jssdk-ready.wx-open-tag-scene #launch-btn {
|
|
|
+ body.is-wechat.wx-jssdk-ready #launch-btn {
|
|
|
display: block;
|
|
|
}
|
|
|
|
|
|
- body.is-wechat.wx-jssdk-ready.wx-open-tag-scene #openApp {
|
|
|
+ body.is-wechat.wx-jssdk-ready #openApp {
|
|
|
display: none !important;
|
|
|
}
|
|
|
|
|
|
@@ -799,48 +798,31 @@
|
|
|
|
|
|
function getWxShareEntryFrom() {
|
|
|
var from = q('from');
|
|
|
- return from ? String(from).trim().toLowerCase() : '';
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * wx-open-launch-app 仅在分享卡片等场景可用;复制链接打开会 launch:fail。
|
|
|
- * 勿在 getWxConfig 前改地址栏(iOS 微信按进入时 url 验签,replaceState 会导致签名无效)。
|
|
|
- */
|
|
|
- function isWxOpenLaunchAppSceneSupported() {
|
|
|
- if (!isWeChatInAppBrowser()) return false;
|
|
|
- if (readQueryParam('wxOpenTag') === '1' || readQueryParam('wxForceOpenTag') === '1') {
|
|
|
- return true;
|
|
|
- }
|
|
|
- var from = getWxShareEntryFrom();
|
|
|
- return (
|
|
|
- from === 'singlemessage' ||
|
|
|
- from === 'groupmessage' ||
|
|
|
- from === 'timeline'
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- function applyWxOpenLaunchSceneBodyClass() {
|
|
|
- if (!isWeChatInAppBrowser()) return;
|
|
|
- var ok = isWxOpenLaunchAppSceneSupported();
|
|
|
- document.body.classList.toggle('wx-open-tag-scene', ok);
|
|
|
- document.body.classList.toggle('wx-copy-link-entry', !ok);
|
|
|
+ if (from) return String(from).trim().toLowerCase();
|
|
|
+ try {
|
|
|
+ var h = location.hash || '';
|
|
|
+ var qi = h.indexOf('?');
|
|
|
+ if (qi >= 0) {
|
|
|
+ var hf = new URLSearchParams(h.slice(qi + 1)).get('from');
|
|
|
+ if (hf) return String(hf).trim().toLowerCase();
|
|
|
+ }
|
|
|
+ } catch (eH) {}
|
|
|
+ try {
|
|
|
+ var sf = new URLSearchParams(location.search || '').get('from');
|
|
|
+ if (sf) return String(sf).trim().toLowerCase();
|
|
|
+ } catch (eS) {}
|
|
|
+ return '';
|
|
|
}
|
|
|
|
|
|
function logWxEntryDiagnostics() {
|
|
|
if (!isWeChatInAppBrowser()) return;
|
|
|
console.log('[wx-entry]', {
|
|
|
- entryFrom: getWxShareEntryFrom() || '(无,多为复制链接进入)',
|
|
|
- openLaunchTagScene: isWxOpenLaunchAppSceneSupported(),
|
|
|
+ entryFrom: getWxShareEntryFrom() || '(无)',
|
|
|
+ wxJssdkReady: weChatJssdkConfigured,
|
|
|
signUrl: getWxConfigSignUrl()
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- function showWxCopyLinkEntryTip() {
|
|
|
- showFabToast(
|
|
|
- '当前为复制链接进入,微信不支持直接打开 App。请使用 App「分享到微信」发送卡片后,点卡片进入。'
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
function isIOSWeChatBrowser() {
|
|
|
var ua = navigator.userAgent || '';
|
|
|
return /MicroMessenger/i.test(ua) && /iPhone|iPad|iPod/i.test(ua);
|
|
|
@@ -1091,10 +1073,7 @@
|
|
|
wx.ready(function () {
|
|
|
weChatJssdkConfigured = true;
|
|
|
document.body.classList.add('wx-jssdk-ready');
|
|
|
- applyWxOpenLaunchSceneBodyClass();
|
|
|
- if (isWxOpenLaunchAppSceneSupported()) {
|
|
|
- refreshWxLaunchTagAttrs();
|
|
|
- }
|
|
|
+ refreshWxLaunchTagAttrs();
|
|
|
console.log('[wx.config] ready, htmlUrl=', htmlUrl);
|
|
|
resolve(true);
|
|
|
});
|
|
|
@@ -1150,9 +1129,17 @@
|
|
|
? String(detail.errmsg)
|
|
|
: '';
|
|
|
console.warn('[wx-open-launch-app]', detail);
|
|
|
- showAppOpenFailTip(
|
|
|
- '请确复制链接进入U店在哪'
|
|
|
- );
|
|
|
+ if (/launch:fail/i.test(errMsg) && !getWxShareEntryFrom()) {
|
|
|
+ showAppOpenFailTip(
|
|
|
+ '当前环境无法直接打开 App,请使用 App「分享到微信」后点分享卡片进入'
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ showAppOpenFailTip(
|
|
|
+ errMsg
|
|
|
+ ? '未能打开 App:' + errMsg
|
|
|
+ : '未能打开 App,请确认已安装最新版「U店在哪」'
|
|
|
+ );
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -2130,7 +2117,6 @@
|
|
|
bindWeChatLaunchTagEvents();
|
|
|
if (isWeChatInAppBrowser()) {
|
|
|
document.body.classList.add('is-wechat');
|
|
|
- applyWxOpenLaunchSceneBodyClass();
|
|
|
logWxEntryDiagnostics();
|
|
|
}
|
|
|
if (shouldInitWeChatJssdkOnLoad()) {
|
|
|
@@ -2142,7 +2128,6 @@
|
|
|
|
|
|
document.addEventListener('WeixinOpenTagsError', function (e) {
|
|
|
console.warn('[WeixinOpenTagsError]', e && e.detail);
|
|
|
- applyWxOpenLaunchSceneBodyClass();
|
|
|
});
|
|
|
|
|
|
if (isWeChatInAppBrowser()) {
|
|
|
@@ -2153,10 +2138,6 @@
|
|
|
showFabToast(
|
|
|
wxInitLastError || '微信 SDK 初始化中,请稍候再点底部按钮'
|
|
|
);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!isWxOpenLaunchAppSceneSupported()) {
|
|
|
- showWxCopyLinkEntryTip();
|
|
|
}
|
|
|
});
|
|
|
}
|