Merge branch 'feature/openapp' into gray
Showing
1 changed file
with
17 additions
and
10 deletions
@@ -17,21 +17,28 @@ const getAppPath = () => { | @@ -17,21 +17,28 @@ const getAppPath = () => { | ||
17 | const u = navigator.userAgent; | 17 | const u = navigator.userAgent; |
18 | const isFromYOHO = /m\.yohobuy\.com/i.test(document.referrer); | 18 | const isFromYOHO = /m\.yohobuy\.com/i.test(document.referrer); |
19 | const isiOS = /(iPhone|iPad|iPod|iOS)/i.test(u); // ios终端 | 19 | const isiOS = /(iPhone|iPad|iPod|iOS)/i.test(u); // ios终端 |
20 | +const isAndroid = /Android/i.test(u); // android终端 | ||
21 | +const iOSVersion = parseInt(u.match(/OS (\d+)_(\d+)_?(\d+)?/i)[1], 10); | ||
20 | 22 | ||
21 | -// const isAndroid = /Android/i.test(u); // android终端 | ||
22 | -// const iOSVersion = parseInt(u.match(/OS (\d+)_(\d+)_?(\d+)?/i)[1], 10); | ||
23 | 23 | ||
24 | - | ||
25 | -/* | ||
26 | - 2.13 日要求,暂时不管通用链接,所有情况都尝试唤起 App | ||
27 | - | ||
28 | - isAndroid || iOSVersion < 9 将来配合 通用链接使用 | ||
29 | -*/ | ||
30 | - | ||
31 | -if (!isFromYOHO) { | 24 | +if (!isFromYOHO && (isAndroid || iOSVersion < 9 || qs.openapp)) { |
32 | let appPath = getAppPath(); | 25 | let appPath = getAppPath(); |
33 | let ifr; | 26 | let ifr; |
34 | 27 | ||
28 | + if (window._yas && window._yas.sendCustomInfo) { | ||
29 | + window._yas.sendCustomInfo({ | ||
30 | + op: 'YB_H5_AWAKE_APP', | ||
31 | + param: JSON.stringify({ | ||
32 | + PAGE_NAME: encodeURIComponent(document.title), | ||
33 | + PAGE_URL: encodeURIComponent(location.href) | ||
34 | + }) | ||
35 | + }, true); | ||
36 | + } | ||
37 | + | ||
38 | + if (window._hmt && window._hmt.push) { | ||
39 | + window._hmt.push(['_trackEvent', 'H5唤起APP', isiOS ? 'Apple' : 'Android', document.title, location.href]); | ||
40 | + } | ||
41 | + | ||
35 | if (isiOS) { | 42 | if (isiOS) { |
36 | window.location.href = appPath; | 43 | window.location.href = appPath; |
37 | } else { | 44 | } else { |
-
Please register or login to post a comment