// g_store_header !(function () { var $document = $(document); var $mainHeaderTopAd = $("#mainHeaderTopAd"); var $mainHeaderTopAdClose = $("#mainHeaderTopAd button.close"); var $mainHeaderMemberInfo = $("#mainHeaderMemberInfo"); var $mainHeaderCartQuantity = $("#mainHeaderCart em"); var $mainHeaderMainNavInkBar = $("#mainHeaderMainNav div.ink-bar"); var $mainHeaderMainNavItem = $("#mainHeaderMainNav li"); var $mainHeaderMainNavActiveItem = $("#mainHeaderMainNav li.active"); var mainHeaderMemberInfoTemplate = _.template($("#mainHeaderMemberInfoTemplate").html()); // 顶部广告 if (sessionStorage.getItem("mainHeaderTopAdHidden") == null) { $mainHeaderTopAd.show(); } // 顶部广告 $mainHeaderTopAdClose.click(function () { sessionStorage.setItem("mainHeaderTopAdHidden", "true"); $mainHeaderTopAd.velocity("slideUp"); }); // 会员信息 $mainHeaderMemberInfo.html(mainHeaderMemberInfoTemplate({ currentUser: $.getCurrentUser() })); // 用户注销 $mainHeaderMemberInfo.on("click", "a.logout", function () { $document.trigger("https://sms10001.zhaosw.com/resources/shop/js/loggedOut.shopxx.user", $.getCurrentUser()); }); // 购物车数量 $document.on("complete.shopxx.setCurrentCartQuantity", function (event, quantity) { $mainHeaderCartQuantity.text(quantity < 100 ? quantity : "99+"); }); // 主导航 if ($mainHeaderMainNavItem.length > 0) { if ($mainHeaderMainNavActiveItem.length < 1) { $mainHeaderMainNavActiveItem = $mainHeaderMainNavItem.first(); } $mainHeaderMainNavInkBar.css({ width: $mainHeaderMainNavActiveItem.outerWidth(), display: "block", left: $mainHeaderMainNavActiveItem.position().left }); $mainHeaderMainNavItem.hover(function () { var $element = $(this); $mainHeaderMainNavInkBar.css({ width: $element.outerWidth(), left: $element.position().left }); }, function () { $mainHeaderMainNavInkBar.css({ width: $mainHeaderMainNavActiveItem.outerWidth(), left: $mainHeaderMainNavActiveItem.position().left }); }); } }()) // m_store_header !(function () { var $document = $(document); var $mainHeaderProductSearchKeyword = $("#mainHeaderProductSearch input[name='q']"); var $searchButtonLocal = $("#searchButtonLocal"); var $mainHeaderProductSearchForm = $("#mainHeaderProductSearch form"); var storeUrl = $("#storeUrl").data('url'); // 商品搜索 $mainHeaderProductSearchForm.submit(function () { if ($.trim($mainHeaderProductSearchKeyword.val()) == "") { return false; } }); // 搜索本站 $searchButtonLocal.click(function () { var keyword = $.trim($mainHeaderProductSearchKeyword.val()) if (keyword == "") { return false; } location.href = "https://sms10001.zhaosw.com/products?keyword=" + keyword; }).click(function () { //关键词搜索记录 var keyword = $.trim($mainHeaderProductSearchKeyword.val()); if (keyword.length < 1) { return; } $.ajax({ url: '/common/keywordRecord/saveKeyword', data: { keyword: keyword, searchType: 'local', source: 'pc' } }); }); // 店铺二维码 $('#store-qrcode1').qrcode({ width: 135, height: 135, text: storeUrl }); $('.store-info .icon3').webuiPopover(); $('.store-info .icon4').webuiPopover(); }()) // store_footer // !(function () { // $(document).on('get-store-base-info', function (event, res) { // contactPageInfoRender(res); // footerInfoRender(res); // }) // // function contactPageInfoRender(res) { // var $wrap = $('.contact-box'); // $wrap.find('.jName').html(res.name); // $wrap.find('.jLinkName').html(res.linkName); // $wrap.find('.jPhone').html(res.phone); // $wrap.find('.jMobile').html(res.showMobile || res.mobile); // $wrap.find('.jFax').html(res.fax); // } // // function footerInfoRender(res) { // var $wrap = $('.store-footer'); // $wrap.find('.jName').html(res.name); // $wrap.find('.jPhone').html(res.showMobile || res.mobile || res.phone); // $wrap.find('.jLinkName').html(res.linkName); // } // }()) // plan_promotion !(function () { function filter() { if ($sourceFlag == 0 || $sourceFlag == 1) { //搜索页面||商品类目页面 var plankeywords = ""; $("input[name='plankeywords']").each(function () { if ($(this).val()) { plankeywords += $(this).val() + ","; } }); if (plankeywords == "") { return false; } return true; } else if ($sourceFlag == 2 || $sourceFlag == 3 || $sourceFlag == 4) { //商品落地页||店铺详情页面 // var $referrer = getUrltest2(); var $referrer = document.referrer; if (!$referrer) { return false; } var arr = $referrer.split("?") if (arr[0].indexOf($jsCookieDomain) != -1) { return false; } return true; } } if (filter()) { collectSave(); eventBind(); } function sendPromotion(options, cb) { $.ajax({ url: '/product/promotion/collection', type: 'POST', data: { "comeUrl": options.comeUrl, "sourceUrl": options.sourceUrl, "showFlag": options.showFlag, "clickFlag": options.clickFlag, "sourceFlag": $sourceFlag, "businessId": options.businessId, "productId": options.productId, "searchWord": options.searchWord, "planKeywordIds": options.planKeywordIds, "deviceType": $deviceType }, complete: function () { cb && cb(); } }) } function collectSave() { if ($sourceFlag == 0 || $sourceFlag == 1) { var searchWord = $sourceFlag == 1 ? $productCategoryName : $productKeyword; var planKeywordIds = ""; $("input[name='plankeywords']").each(function () { if ($(this).val()) { planKeywordIds += $(this).val() + ","; } }); sendPromotion({ showFlag: 1, clickFlag: 0, searchWord: searchWord, planKeywordIds: planKeywordIds, comeUrl: document.URL, sourceUrl: document.referrer // comeUrl: getUrltest(), // sourceUrl: getUrltest2() }); } else if ($sourceFlag == 2) { sendPromotion({ showFlag: 1, clickFlag: 1, productId: $productId, comeUrl: document.URL, sourceUrl: document.referrer // comeUrl: getUrltest(), // sourceUrl: getUrltest2() }); } else if ($sourceFlag == 3) { sendPromotion({ showFlag: 1, clickFlag: 1, businessId: $businessId, comeUrl: document.URL, sourceUrl: document.referrer // comeUrl: getUrltest(), // sourceUrl: getUrltest2() }); } else if ($sourceFlag == 4) { sendPromotion({ showFlag: 1, clickFlag: 1, productId: $pageId, comeUrl: document.URL, sourceUrl: document.referrer // comeUrl: getUrltest(), // sourceUrl: getUrltest2() }); } } function eventBind() { $('.promotion-click').click(function (ev) { var productUrl = $(this).data('href'); var planKeyword = $(this).data('id'); if ($deviceType != 1) { ev.preventDefault(); } if (planKeyword) { var searchWord = $sourceFlag == 1 ? $productCategoryName : $productKeyword; sendPromotion({ showFlag: 0, clickFlag: 1, searchWord: searchWord, planKeywordIds: planKeyword, comeUrl: $siteUrl + productUrl, sourceUrl: document.URL // sourceUrl: getUrltest() }, function () { if ($deviceType != 1) { location.href = productUrl; } }); } }); } function getUrltest() { var url = document.location.href; var arrUrl = url.split("aaaa"); return arrUrl[0]; } function getUrltest2() { var url = document.location.href; if (url.indexOf("aaaa=") !== -1) { var arrUrl = url.split("aaaa="); return arrUrl[1]; } else { return document.referrer; } } }())