attr('src', $(this).find('img').attr('data-img')).attr('jqimg', $(this).find( 'img').attr('data-big')); }) var i = 0; if (length <= 5) { $('.product-gallery .next-btn').css('display', 'none'); } else { //前一张缩略图 $('.next-left').click(function () { i--; if (i < 0) { i = 0; return; } $picBox.animate({ left: -i * 70 }, 500); }) //后前一张缩略图 $('.next-right').click(function () { i++; if (i > length - 5) { i = length - 5; return; } $picBox.animate({ left: -i * 70 }, 500); }) } } //购买数量加减 function altergoodsnum(n) { var num = parseInt($('#number').val()); var maxnum = parseInt($('#number').attr('max')); if (maxnum > 200) { maxnum = 200; } num += n; num <= 0 ? num = 1 : num; if (num >= maxnum) { $(this).addClass('no-mins'); num = maxnum; } $('#store_count').text(maxnum - num); //更新库存数量 $('#number').val(num); /* initGoodsPrice();*/ } //初始化商品价格库存 function initGoodsPrice() { var goods_id = $('input[name="goods_id"]').val(); var goods_num = parseInt($('#number').val()); if (!$.isEmptyObject(spec_goods_price)) { var goods_spec_arr = []; $("input[name^='goods_spec']").each(function () { if ($(this).attr('checked') == 'checked') { goods_spec_arr.push($(this).val()); } }); var spec_key = goods_spec_arr.sort(sortNumber).join('_'); //排序后组合成 key if (spec_goods_price[spec_key] != undefined) { var item_id = spec_goods_price[spec_key]['item_id']; $('input[name=item_id]').val(item_id); } else { $("#goods_price").html("" + 0); //变动价格显示 $('#spec_store_count').html(0); $('input[name="shop_price"]').attr('value', 0); //商品价格 $('input[name="store_count"]').attr('value', 0); //商品库存 $('.buy_button').addClass('buy_bt_disable'); return false; } } $.ajax({ type: 'post', dataType: 'json', data: { goods_id: goods_id, item_id: item_id, goods_num: goods_num }, url: "/Home/Goods/activity.html", success: function (data) { if (data.status == 1) { $('input[name="goods_prom_type"]').attr('value', data.result.goods.prom_type); //商品活动类型 $('input[name="shop_price"]').attr('value', data.result.goods.shop_price); //商品价格 $('input[name="store_count"]').attr('value', data.result.goods.store_count); //商品库存 $('input[name="market_price"]').attr('value', data.result.goods.market_price); //商品原价 $('input[name="start_time"]').attr('value', data.result.goods.start_time); //活动开始时间 $('input[name="end_time"]').attr('value', data.result.goods.end_time); //活动结束时间 $('input[name="activity_title"]').attr('value', data.result.goods.activity_title); //活动标题 $('input[name="prom_detail"]').attr('value', data.result.goods.prom_detail); //促销详情 $('input[name="activity_is_on"]').attr('value', data.result.goods.activity_is_on); //活动是否正在进行中 price_ladder = data.result.goods.price_ladder; goods_activity_theme(); buy_button(); } doInitRegion(); } }); } //价格阶梯显示 var price_ladder = null; function priceLadderShow() { var price_ladder_html = ''; if (price_ladder != null && price_ladder != '') { $.each(price_ladder, function (i, o) { price_ladder_html += '
  • ' + o.amount + '件
    ' + o.price + '
  • '; }); $('#price_ladder_html').empty().html(price_ladder_html); if (price_ladder.length > 3) { $('.price_ladder_more').show(); } else { $('.price_ladder_more').hide(); } $('.pre_sell_div').show(); } } //商品价格库存显示 function goods_activity_theme() { $('.pre_sell_div').hide(); var goods_prom_type = $('input[name="goods_prom_type"]').attr('value'); var activity_is_on = $('input[name="activity_is_on"]').attr('value'); if (activity_is_on == 0) { setNormalGoodsPrice(); } else { if (goods_prom_type == 0 || goods_prom_type == 6) { //普通商品 setNormalGoodsPrice(); } else if (goods_prom_type == 1) { //抢购 setFlashSaleGoodsPrice(); } else if (goods_prom_type == 2) { //团购 setGroupByGoodsPrice(); } else if (goods_prom_type == 3) { //优惠促销 setPromGoodsPrice(); } else { } } var buy_num = parseInt($('#number').val()); //购买数 var store = parseInt($('input[name="store_count"]').val()); //实际库存数量 if (store <= 0) { $('.buy_button').addClass('buy_bt_disable'); } else { $('.buy_button').removeClass('buy_bt_disable'); } if (buy_num > store) { $('.buyNum').val(store); } } //普通商品库存和价格 function setNormalGoodsPrice() { var goods_price, store_count; //商品价,商品库存 var market_price = $("input[name='market_price']").attr('value'); // 商品市场价 var exchange_integral = $("input[name='exchange_integral']").attr('value'); // 兑换积分 var point_rate = $("input[name='point_rate']").attr('value'); // 积分金额比 // 如果有属性选择项 if (!$.isEmptyObject(spec_goods_price)) { var goods_spec_arr = []; $("input[name^='goods_spec']").each(function () { if ($(this).attr('checked') == 'checked') { goods_spec_arr.push($(this).val()); } }); var spec_key = goods_spec_arr.sort(sortNumber).join('_'); //排序后组合成 key goods_price = spec_goods_price[spec_key]['price']; // 找到对应规格的价格 store_count = spec_goods_price[spec_key]['store_count']; // 找到对应规格的库存 market_price = spec_goods_price[spec_key]['market_price']; // 找到对应规格的市场价 $("input[name='shop_price']").attr('value', goods_price); $("input[name='store_count']").attr('v