/* Js for , Version=1555084564 */ v.theme = {"template":"mobile","theme":"default","device":"mobile"};;v.path = ["18"];;v.categoryID = 18;;v.categoryPath = ["18"];;v.addToCartSuccess = "\u6210\u529f\u52a0\u5165\u8d2d\u7269\u8f66\u3002";;v.gotoCart = "\u53bb\u8d2d\u7269\u8f66\u7ed3\u7b97";;v.goback = "\u8fd4\u56de";;v.stockOpened = false;;v.stock = 0;; ;$(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('.form-control-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() { $(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) { $.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); }) } }); ; $(function() { var countLink = '/cart-count.mhtml'; var browseLink = '/cart-browse.mhtml'; $.refreshCart = function(twinkle) { $.getJSON(countLink, function(data) { if($.isPlainObject(data) && data.result === 'success') { var $count = $('.cart-count').text(data.count).toggleClass('hide', data.count < 1); if(data.count > 0 && twinkle) { $count.addClass('twinkle'); setTimeout(function(){$count.removeClass('twinkle')}, 200); if(window.v && window.v.addToCartSuccess) $.messager.success(window.v.addToCartSuccess + "
" + window.v.gotoCart + "
" + data.count + "
", {time: 10000, cssClass: 'msger-cart'}); } } }); }; $.refreshCart(); });