/* Js for , Version=1714139702 */ v.theme = {"template":"mobile","theme":"colorful","device":"mobile"};;v.path = ["16","110"];;v.categoryID = 110;;v.categoryPath = ["16","110"];;v.addToCartSuccess = "\u6210\u529f\u52a0\u5165\u8d2d\u7269\u8f66\u3002";;v.gotoCart = "\u53bb\u8d2d\u7269\u8f66\u7ed3\u7b97";;v.goback = "\u8fd4\u56de";;v.location = "L3pwZGlhbmhhbmppLzM0Lm1odG1s";; ;v.price = 0;;v.currencySymbol = "\uffe5";; $(function() { var userLink = createLink('user', 'login'); extra = {}; $('.price-label').click(function() { hideAttrForm(); $(this).parent().find('.active').removeClass('active'); $(this).addClass('active'); code = $(this).data('attribute'); extra[code] = $(this).data('value'); $(this).find('[type=hidden]').val($(this).data('value')); computedPrice(); }); $('.attr-selector').click(function() { code = $(this).data('attribute'); $('.' + code + '-inputer').val($(this).data('value')); }) $('#count').change(function() { $('.count-input').val($(this).val()) }); $('.btncart').click(function() { if(!checkAttr()) { alertAttrForm(); return false; } cartLink = $(this).data('url').replace('countParam', $('#count').val()) $.post(cartLink, {extra: extra}, function(response) { if(response.result == 'success') { setCartCount(); $.messager.success(window.v.addToCartSuccess); } else { location.href = response.locate; } }, 'json' ) }); $('#buyBtn.login').click(function(){location.href=createLink('user', 'login', "referer=" + v.location)} ); $('#buyBtn.buy').click(function() { if(!checkAttr()) { alertAttrForm(); return false; } $('#buyForm').submit(); }); function alertAttrForm() { window.scrollTo(0,$('#attribute').offset().top-200) $('.attr-selector').parents('tr').css('border', '1px solid red'); } function hideAttrForm() { window.scrollTo(0,$('#attribute').offset().top-200) $('.attr-selector').parents('tr').css('border', 'none'); } function computedPrice() { if(!checkAttr()) return false; price = v.price; $('.attr-selector.active').each(function() { if($(this).data('price') != 0) { value = $(this).data('price'); price = parseFloat(price) + parseFloat(value); } price = parseFloat(price).toFixed(2); }); if(v.hasDiscount) { price = price * v.discount; price = parseFloat(price).toFixed(2); } $('#priceBox .text-danger').html(v.currencySymbol + price); $('#price').val(price); } function checkAttr() { attrSelected = true; $('.attr-selector').each(function() { if($(this).parents('td').find('.attr-selector.active').size() == 0) attrSelected = false; }); return attrSelected; } }); ;$(function() { /* Set current active topNav. */ var hasActive = false; if(v.categoryID > 0 && $('.nav-product-' + v.categoryID).length >= 1) { hasActive = true; $('.nav-product-' + v.categoryID).addClass('active'); } if(v.categoryPath && v.categoryPath.length) { $.each(v.categoryPath, function(index, category) { if(!hasActive) { if($('.nav-product-' + category).length >= 1) hasActive = true; $('.nav-product-' + category).addClass('active'); } }); } else if(v.path && v.path.length) { $.each(v.path, function(index, category) { if(!hasActive) { if($('.nav-product-' + category).length >= 1) hasActive = true; $('.nav-product-' + category).addClass('active'); } }); if(!hasActive) $('.nav-product-0').addClass('active'); } if(v.categoryID !== 0) $('#category' + v.categoryID).parent().addClass('active'); }) +(function($){ 'use strict'; var minDelta = 20; $.fn.numberInput = function(){ return $(this).each(function(){ var $input = $(this); $input.on('click', '.btn-minus, .btn-plus', function(){ var $val = $input.find('.btn-number, [type="number"]'); var val = parseInt($val.val()); val = Math.max(1, $(this).hasClass('btn-minus') ? (val - 1) : (val + 1)); $val.val(val).trigger('change'); }); }); }; $(function(){$('.input-number').numberInput();}); }(Zepto)); function setCartCount() { $.getJSON(createLink('cart', 'count'), function(data) { $('.label.badge.red.circle').text(data.count); }) } function hideMessage() { $('div .comment-post.vertical-center').hide(); } setCartCount(); hideMessage(); $(function() { $(document).on('click', '#message', function() { if($('div .comment-post.vertical-center').css('display') != 'none') { $('div .comment-post.vertical-center').hide(); } else { $('div .comment-post.vertical-center').show(); } }) $(document).on('click', '#submitComment', function() { $('div .comment-post.vertical-center').hide(); }) $(document).on('click', '.btn-buy', function() { window.location.href = $(this).data('url').replace('productcount', $('#count').val()); }).on('click', '.btn-cart', function() { var $btn = $(this); if($btn.hasClass('disabled')) return; $btn.addClass('disabled') $.getJSON($btn.data('url').replace('productcount', $('#count').val()), function(data, status) { if(status === 'success') { if($.isPlainObject(data) && data.result === 'success') { if($.isFunction($.refreshCart)) { $.refreshCart(true); } else if(window.v && window.v.addToCartSuccess) { setCartCount(); $.messager.success(window.v.addToCartSuccess); } } else if(data && data.locate) { window.location.href = data.locate; } else { $.messager.danger($.param(data)); } } else { if(window.v && window.v.lang.timeout) { $.messager.danger(window.v.lang.timeout); } } $btn.removeClass('disabled'); }); }); if(v.stockOpened) { $('#count').change(function() { if($('#count').val() > v.stock) $(this).val(v.stock); }) } });