javascript Issue325:20171113 - no57。共通ヘッダーに「最近见たお店」导线追加
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Issue325:20171113 - no57。共通ヘッダーに「最近见たお店」导线追加相关的知识,希望对你有一定的参考价值。
(function($, util) {
window.issue325 = {
$page : $('#page'),
$header: $('#gnHeader'),
start: function(pattern) {
var that = this;
var ghistoryObjs = that.getGhistories($.cookie('GHistory'));
var $btnReserve = $('#gnHeaderReserve');
var $btnChottog = $('#gnHeaderChottogBtn');
var $btnNews = $('#gnHeaderNewsBtn');
var $btnUser = $('#gnHeaderUserBtn');
var $btnHistory = '<li id="gnHeaderHistory" class="gnBtn gnBtn--history"><a href="http://my.gnavi.co.jp/s/history/?sc_lid=r_smp-history_icon"><p>閲覧履歴<span class="gnHeaderHistory__count">' + ghistoryObjs.length + '</span></p></a></li>';
that.$page.addClass('issue325');
switch (pattern) {
case 1:
$btnReserve.remove();
$btnChottog.before($btnHistory);
break;
case 2:
$btnReserve.remove();
$btnChottog.before($btnHistory);
that.$page.addClass('issue325--sticky');
that.$header.addClass('gnHeader--sticky');
break;
case 3:
$btnNews.remove();
$btnUser.before($btnHistory);
break;
case 4:
$btnNews.remove();
$btnUser.before($btnHistory);
that.setSticky();
break;
default:
break;
}
},
setClass: function() {
// TODO: 納品時は不要なので消す
// ローカルで直近4日のcookieを明示的にセット
// テスト環境以降ではサーバーサイドで処理
$.cookie('GHistory', 'a460202:110:1508471184,p735402:110:1508471180,i924718:110:1508465246,g725415:110:1508464740,a236419:110:1508464635,g501210:110:1508464589,gfpw300:110:1508464578,a046600:110:1508464499,a042600:110:1508464434,a046600:110:1508464499,a460202:110:1508471184,p735402:110:1508471180,i924718:110:1508465246,g725415:110:1508464740,a236419:110:1508464635,g501210:110:1508464589,gfpw300:110:1508464578,a046600:110:1508464499,a042600:110:1508464434,a046600:110:1508464499,a460202:110:1508471184,p735402:110:1508471180,i924718:110:1508465246,g725415:110:1508464740,a236419:110:1508464635,g501210:110:1508464589,gfpw300:110:1508464578,a046600:110:1508464499,a042600:110:1508464434,a046600:110:1508464499');
$.cookie('ghistory_reserve', 'abc1234:1508314800,b029500:1508314800');
// TODO: 納品時は不要なので消す
var that = this;
var ghistoryReserveObjs = that.getGhistories($.cookie('ghistory_reserve'));
var currentSid = JSON.parse($('body').attr('data-r')).sid;
if (!ghistoryReserveObjs ||
(ghistoryReserveObjs.length === 1 && ghistoryReserveObjs[0].sid === currentSid)) {
return false;
}
$('body').addClass('js-issue325-cookie-is-valid');
},
getGhistories: function(ghistory) {
if (!ghistory) {
return null;
}
var histories = ghistory.split(',');
return histories.map(function(history) {
var item = history.split(':');
return {
sid: item[0],
timestamp: item[1]
}
});
},
setSticky: function() {
var that = this;
var windowH = $(window).height();
$(window).on('scroll', function() {
if ($(this).scrollTop() > windowH) {
that.$page.addClass('issue325--sticky');
that.$header.addClass('gnHeader--sticky');
} else {
that.$page.removeClass('issue325--sticky');
that.$header.removeClass('gnHeader--sticky');
}
});
}
}
util.abtestRun(325);
window.issue325.setClass();
})(jQuery, util);
以上是关于javascript Issue325:20171113 - no57。共通ヘッダーに「最近见たお店」导线追加的主要内容,如果未能解决你的问题,请参考以下文章
javascript Issue84 - 20190620电话导线改善
javascript LRM_BP_issue
javascript Issue302:20171018 - 动画商品トライアル
javascript Issue319:20171101 - バナーとモーダルとAMP
javascript Issue15:20180705 - no79.CVエリア改善
javascript Issue30:20180920 - no82。他店铺リンク设置