Authored by 毕凯

Merge branch 'feature/openapp' into 'release/5.5'

Feature/openapp



See merge request !382
... ... @@ -2,6 +2,7 @@
* 移动端尝试打开 app
*/
const qs = require('yoho-qs');
const cookie = require('yoho-cookie');
const u = navigator.userAgent;
const isFromYOHO = /m\.yohobuy\.com/i.test(document.referrer);
... ... @@ -57,19 +58,21 @@ const canOpenApp = () => {
const getAppPath = () => {
let appPath = document.getElementById('main-wrap').dataset.apppath || 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.home","params":{"gender":"1","channel":"2"}}';
let ct = qs.mkt_code || qs.union_type || getMktcBySeo() || '100000000000349';
let clientId = cookie.get('_yasvd');
if (ct) {
appPath = appPath.replace('goapp?', 'goapp?ct=' + ct + '&');
}
if (clientId) {
appPath = appPath.replace('goapp?', 'goapp?client_id=' + clientId + '&');
}
return appPath;
};
if (canOpenApp()) {
let appPath = getAppPath();
let ifr;
setTimeout(function() {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
... ... @@ -84,16 +87,19 @@ if (canOpenApp()) {
if (window._hmt && window._hmt.push) {
window._hmt.push(['_trackEvent', 'H5唤起APP', isiOS ? 'Apple' : 'Android', document.title, location.href]);
}
}, 2000);
}, 1000);
if (isiOS) {
setTimeout(function() {
setTimeout(function() {
let appPath = getAppPath();
let ifr;
if (isiOS) {
window.location.href = appPath;
}, 2000);
} else {
ifr = document.createElement('iframe');
ifr.src = appPath;
ifr.style.display = 'none';
document.body.appendChild(ifr);
}
} else {
ifr = document.createElement('iframe');
ifr.src = appPath;
ifr.style.display = 'none';
document.body.appendChild(ifr);
}
}, 2000);
}
... ...