|
|
const $ = require('jquery');
|
|
|
const lazyload = require('../plugins/lazyload');
|
|
|
const common = require('./common');
|
|
|
|
|
|
let indexObj = {
|
|
|
init: function() {
|
|
|
|
|
|
if (this.queryString().openType === 'baidu') {
|
|
|
this.setCookie('openType', '1', {path: '/', expires: 1});
|
|
|
if (common.queryString().openType === 'baidu') {
|
|
|
common.setCookie('openType', '1', {path: '/', expires: 1});
|
|
|
}
|
|
|
|
|
|
this.lazyLoad();
|
...
|
...
|
@@ -38,69 +39,33 @@ let indexObj = { |
|
|
_this.resizeInit();
|
|
|
});
|
|
|
},
|
|
|
cookie: function(name) {
|
|
|
let cookies = document.cookie,
|
|
|
cookieVal;
|
|
|
|
|
|
if (cookies) {
|
|
|
cookies = cookies.split(';');
|
|
|
// cookie: function(name) {
|
|
|
// let cookies = document.cookie,
|
|
|
// cookieVal;
|
|
|
|
|
|
for (let i = 0; i < cookies.length; i++) {
|
|
|
if (cookies[i].indexOf(name) > -1) {
|
|
|
cookieVal = decodeURIComponent($.trim(cookies[i].replace(name + '=', '')));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// if (cookies) {
|
|
|
// cookies = cookies.split(';');
|
|
|
|
|
|
return cookieVal;
|
|
|
},
|
|
|
// for (let i = 0; i < cookies.length; i++) {
|
|
|
// if (cookies[i].indexOf(name) > -1) {
|
|
|
// cookieVal = decodeURIComponent($.trim(cookies[i].replace(name + '=', '')));
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// return cookieVal;
|
|
|
// },
|
|
|
downShow: function() {
|
|
|
if (this.cookie('ignoreDownload') || this.cookie('openType')) {
|
|
|
if (common.getCookie('ignoreDownload') || common.getCookie('openType') ||
|
|
|
common.queryString().openType === 'baidu') {
|
|
|
$('.download').remove();
|
|
|
}
|
|
|
},
|
|
|
queryString: function() {
|
|
|
var vars = [],
|
|
|
hash,
|
|
|
i;
|
|
|
var hashes = window.location.search.slice(1).split('&');
|
|
|
|
|
|
for (i = 0; i < hashes.length; i++) {
|
|
|
hash = hashes[i].split('=');
|
|
|
vars.push(hash[0]);
|
|
|
vars[hash[0]] = hash[1];
|
|
|
}
|
|
|
return vars;
|
|
|
},
|
|
|
setCookie: function(name, value, options) {
|
|
|
var expires = '',
|
|
|
path,
|
|
|
domain,
|
|
|
secure,
|
|
|
date;
|
|
|
|
|
|
if (typeof value !== 'undefined') {
|
|
|
options = options || {};
|
|
|
if (value === null) {
|
|
|
value = '';
|
|
|
options.expires = -1;
|
|
|
}
|
|
|
|
|
|
if (options.expires &&
|
|
|
(typeof options.expires === 'number' || options.expires.toUTCString)) {
|
|
|
if (typeof options.expires === 'number') {
|
|
|
date = new Date();
|
|
|
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
|
|
|
} else {
|
|
|
date = options.expires;
|
|
|
}
|
|
|
expires = '; expires=' + date.toUTCString();
|
|
|
}
|
|
|
path = options.path ? '; path=' + options.path : '';
|
|
|
domain = options.domain ? '; domain=' + options.domain : '';
|
|
|
secure = options.secure ? '; secure' : '';
|
|
|
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
|
|
|
if (common.getCookie('openType') || common.queryString().openType === 'baidu') {
|
|
|
$('.shop-detail-page .h5-download').remove();
|
|
|
$('.shop-detail-page .city-list').remove();
|
|
|
$('.detail-page .h5-download').remove();
|
|
|
}
|
|
|
},
|
|
|
};
|
...
|
...
|
|