$("#integral").html(integral + '+' + exchange_integral + '积分'); //积分显示 $('#spec_store_count').html(store_count); $('.presale-time').hide(); $('#number').attr('max', store_count); } //秒杀商品库存和价格 function setFlashSaleGoodsPrice() { var flash_sale_price = $("input[name='shop_price']").attr('value'); var flash_sale_count = $("input[name='store_count']").attr('value'); var market_price = $("input[name='market_price']").attr('value'); var start_time = $("input[name='start_time']").attr('value'); var end_time = $("input[name='end_time']").attr('value'); var activity_title = $("input[name='activity_title']").attr('value'); $("#goods_price").html("" + flash_sale_price); //变动价格显示 $('#spec_store_count').html(flash_sale_count); $('#goods_price_title').html('抢购价:'); $('#market_price_title').empty().html('原  价:'); $('#activity_label').empty().html('抢  购:'); $('#activity_title').empty().html(activity_title); $('#activity_title_div').show(); $('#market_price').empty().html(market_price); $('.presale-time').show(); $('#prom_detail').hide(); $('#number').attr('max', flash_sale_count); setInterval(activityTime, 1000); } //团购商品库存和价格 function setGroupByGoodsPrice() { var group_by_price = $("input[name='shop_price']").attr('value'); var group_by_count = $("input[name='store_count']").attr('value'); var market_price = $("input[name='market_price']").attr('value'); var start_time = $("input[name='start_time']").attr('value'); var end_time = $("input[name='end_time']").attr('value'); var activity_title = $("input[name='activity_title']").attr('value'); $("#goods_price").empty().html("" + group_by_price); //变动价格显示 $('#spec_store_count').empty().html(group_by_count); $('#activity_type').empty().html('团购'); $('#goods_price_title').empty().html('团购价:'); $('#market_price_title').empty().html('原  价:'); $('#activity_label').empty().html('团  购:'); $('#activity_title').empty().html(activity_title); $('#activity_title_div').show(); $('#market_price').empty().html(market_price); $('.presale-time').show(); $('#prom_detail').hide(); $('#number').attr('max', group_by_count); setInterval(activityTime, 1000); } //促销商品库存和价格 function setPromGoodsPrice() { var prom_goods_price = $("input[name='shop_price']").attr('value'); var prom_goods_count = $("input[name='store_count']").attr('value'); var market_price = $("input[name='market_price']").attr('value'); var start_time = $("input[name='start_time']").attr('value'); var end_time = $("input[name='end_time']").attr('value'); var activity_title = $("input[name='activity_title']").attr('value'); var prom_detail = $("input[name='prom_detail']").attr('value'); $("#goods_price").empty().html("" + prom_goods_price); //变动价格显示 $('#spec_store_count').empty().html(prom_goods_count); $('#activity_type').empty().html('促销'); $('.presale-time').show(); $('#prom_detail').empty().html(prom_detail).show(); $('#activity_time').hide(); $('#goods_price_title').empty().html('促销价:'); $('#market_price_title').empty().html('原  价:'); $('#activity_label').empty().html('促  销:'); $('#activity_title').empty().html(activity_title); $('#activity_title_div').show(); $('#market_price').empty().html(market_price); $('#number').attr('max', prom_goods_count); } // 倒计时 function activityTime() { var end_time = parseInt($("input[name='end_time']").attr('value')); var timestamp = Date.parse(new Date()); var now = timestamp / 1000; var end_time_date = formatDate(end_time * 1000); var text = GetRTime(end_time_date); //活动时间到了就刷新页面重新载入 if (now > end_time) { layer.msg('该商品活动已结束', function () { location.reload(); }); } $("#overTime").text(text); } //时间戳转换 function add0(m) { return m < 10 ? '0' + m : m } //时间戳转换字符 function formatDate(now) { var time = new Date(now); var y = time.getFullYear(); var m = time.getMonth() + 1; var d = time.getDate(); var h = time.getHours(); var mm = time.getMinutes(); var s = time.getSeconds(); return y + '/' + add0(m) + '/' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s); } //sort排序用 function sortNumber(a, b) { return a - b; } // 关注店铺 $('#follow-shop-info').click(function () { if (getCookie('user_id') == '') { layer.msg('请先登录!', { icon: 2 }); } }) //收藏商品 $('#collectLink').click(function () { if (getCookie('user_id') == '') { layer.msg('请先登录!', { icon: 1 }); } else { var goods_arr = new Array(); //单个收藏 goods_arr.push($('input[name="goods_id"]').val()); $.ajax({ type: 'post', dataType: 'json', data: { goods_ids: goods_arr }, url: "/Home/Goods/collect_goods.html", success: function (res) { if (res.status == 1) { layer.msg(res.msg, { icon: 1 }); } else { layer.msg(res.msg, { icon: 3 }); } } }); } }); //点击切换规格 $(document).on('click', '.spec_item', function () { var spec_item_img_src = $(this).find('img').attr('src'); if (spec_item_img_src != '') { $('#zoomimg').attr('jqimg', spec_item_img_src).attr('src', spec_item_img_src); } $(this).addClass('red').siblings('a').removeClass('red'); $(this).siblings('input').removeAttr('checked'); $(this).prev('input').attr('checked', 'checked').prop('checked', 'checked'); if ($('#video').length > 0) { //判断是否有视频标签 $('#photoBody').addClass('picshow-ac'); video.pause(); } // 更新商品价格 initGoodsPrice(); //获取搭配购列表 getCombination(); })