...
|
...
|
@@ -2,7 +2,6 @@ |
|
|
* 移动端尝试打开 app
|
|
|
*/
|
|
|
const qs = require('yoho-qs');
|
|
|
const cookie = require('yoho-cookie');
|
|
|
|
|
|
const u = navigator.userAgent;
|
|
|
const isFromYOHO = /m\.yohobuy\.com/i.test(document.referrer);
|
...
|
...
|
@@ -22,6 +21,31 @@ const blackCheck = urlBlacklist.some(function(url) { |
|
|
return new RegExp(url, 'i').test(location.href);
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 从referrer中获取信息,设定mktcode
|
|
|
*/
|
|
|
const channelMap = {
|
|
|
'baidu.com': 100000000000055,
|
|
|
'so.com': 100000000000049,
|
|
|
'sogou.com': 100000000000053,
|
|
|
'bing.com': 100000000000057,
|
|
|
'm.sm.cn': 100000000000059,
|
|
|
'google.com': 100000000000061
|
|
|
};
|
|
|
|
|
|
const getMktcBySeo = function() {
|
|
|
var mktc,
|
|
|
rf = document.referrer;
|
|
|
|
|
|
for (let domain in channelMap) {
|
|
|
if (rf.indexOf(domain) > -1) {
|
|
|
mktc = channelMap[domain];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return mktc;
|
|
|
};
|
|
|
|
|
|
const canOpenApp = () => {
|
|
|
if (isApp || isFromYOHO || nodownload || qs.nodownload || qs.no_openapp || blackCheck) {
|
|
|
return false;
|
...
|
...
|
@@ -31,7 +55,7 @@ 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 || cookie.get('mkt_code') || '100000000000349';
|
|
|
let ct = qs.mkt_code || qs.union_type || getMktcBySeo() || '100000000000349';
|
|
|
|
|
|
if (ct) {
|
|
|
appPath = appPath.replace('goapp?', 'goapp?ct=' + ct + '&');
|
...
|
...
|
|