...
|
...
|
@@ -3,6 +3,27 @@ |
|
|
*/
|
|
|
const qs = require('yoho-qs');
|
|
|
|
|
|
const u = navigator.userAgent;
|
|
|
const isFromYOHO = /m\.yohobuy\.com/i.test(document.referrer);
|
|
|
const isApp = /yohobuy/i.test(u) || !!window.yohoInterface || /app_version=/i.test(location.search) || /openrefer=/i.test(location.search);
|
|
|
|
|
|
const isiOS = /(iPhone|iPad|iPod|iOS)/i.test(u); // ios终端
|
|
|
const isAndroid = /Android/i.test(u); // android终端
|
|
|
const iOSVersion = parseInt((u.match(/OS (\d+)_(\d+)_?(\d+)?/i) || [])[1], 10); // iOS 版本
|
|
|
|
|
|
const nodownload = document.getElementById('no-download'); // 页面不需要下载
|
|
|
const urlBlacklist = ['m.yohobuy.com/brands', 'm.yohobuy.com/passport'];
|
|
|
const blackCheck = urlBlacklist.some(function (url) {
|
|
|
return new RegExp(url, 'i').test(location.href);
|
|
|
});
|
|
|
|
|
|
const canOpenApp = () => {
|
|
|
if (isApp || isFromYOHO || nodownload || qs.nodownload || qs.no_openapp || blackCheck) {
|
|
|
return false;
|
|
|
}
|
|
|
return isAndroid || iOSVersion < 9 || qs.openapp;
|
|
|
};
|
|
|
|
|
|
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;
|
...
|
...
|
@@ -14,14 +35,8 @@ const getAppPath = () => { |
|
|
return appPath;
|
|
|
};
|
|
|
|
|
|
const u = navigator.userAgent;
|
|
|
const isFromYOHO = /m\.yohobuy\.com/i.test(document.referrer);
|
|
|
const isiOS = /(iPhone|iPad|iPod|iOS)/i.test(u); // ios终端
|
|
|
const isAndroid = /Android/i.test(u); // android终端
|
|
|
const iOSVersion = parseInt((u.match(/OS (\d+)_(\d+)_?(\d+)?/i) || [])[1], 10);
|
|
|
|
|
|
|
|
|
if (!isFromYOHO && !qs.no_openapp && (isAndroid || iOSVersion < 9 || qs.openapp)) {
|
|
|
if (canOpenApp()) {
|
|
|
let appPath = getAppPath();
|
|
|
let ifr;
|
|
|
|
...
|
...
|
|