$(function(){ var winH=$(window).height(); var winW=$(window).width(); var swiper = new Swiper('.swiper-container', { slidesPerView: 3, spaceBetween: 0, centeredSlides: true, initialSlide :1, loopAdditionalSlides: 100, observer:true,//修改swiper自己或子元素时,自动初始化swiper observeParents:true,//修改swiper的父元素时,自动初始化swiper //loop: true, nextButton: '.swiper-button-next', prevButton: '.swiper-button-prev', breakpoints: { 767: { slidesPerView:1, } } }); // $(document).on('click','.pic-scroll-btn',function(){ $(".cus-reg-bg").fadeIn(); $(".cus-reg-close").fadeIn(); $(".pic-scroll-tc").fadeIn(); $(this).parents("li").find(".big-pic span").each(function(){ var src1 = $(this).attr("data-src"); swiper.appendSlide('<div class="swiper-slide"><div class="img bg_cover" style="background-image:url('+src1+');"><i></i></div></div>'); //加到Swiper的最后 }); swiper.update(); }) //弹窗 售后注册 $(document).on('click','.custom-message-btn',function(){ var obj_type = $(this).attr('obj_type'); if(obj_type == 'undefined') { $(".cus-reg-close").fadeIn(); $(".cus-reg-tc-wrap").fadeIn(); $(".cus-reg-bg").fadeIn(); return; } var obj_id = $(this).attr('obj_id'); $.post('/api_user/is_login',{},function(json){ var rs = eval('('+json+')'); if (rs.status == 20001) { $(".login-tc").fadeIn(); return false; } else { if(obj_type == 'gift') { if(parseInt(obj_id) > 0 == false) { layer.msg('请选择一个礼品'); return false; } else { $(".cus-reg-close").fadeIn(); $(".cus-reg-tc-wrap").fadeIn(); $(".cus-reg-bg").fadeIn(); var is_submit = true; $('[rel="submit_gift"]').attr('obj_type', obj_type).attr('obj_id', obj_id).unbind('click').bind('click', function(){ var value = new Object(); $.each($('[rel="giftform"]'), function(){ if($(this).val() == '' && $(this).attr('msg') != '') { layer.msg($(this).attr('msg')); is_submit = false; return false; } else { value[$(this).attr('id')] = $(this).val(); } }) value['obj_type'] = obj_type; value['obj_id'] = obj_id; if(is_submit == true) { is_submit = false; layer.open({ shadeClose: false, title: [ '友情提示' ], content: '正在提交中,请勿重复提交', }); $('.layui-layer-close').remove(); $('.layui-layer-btn').remove(); $.post('/api_user/gift_save',value,function(json){ is_submit = true; layer.closeAll(); var rs = eval('('+json+')'); if(rs.status == 10000){ $('[rel="giftform"]').val(''); $('#number').val('1'); $('[rel="submit_gift"]').attr('obj_type', 0).attr('obj_id', 0); $(".cus-reg-close").fadeOut(); $(".pic-scroll-tc").fadeOut(); $(".cus-reg-tc-wrap").fadeOut(); $(".cus-reg-bg").fadeOut(); swiper.removeAllSlides(); swiper.update(); layer.msg(rs.info); return true; } else if (rs.status == 20001) { $(".login-tc").fadeIn(); return false; } else { layer.msg(rs.info); return false; } }) } }) } } } }) }); $(document).on('click','.cus-close-btn',function(){ $(".cus-reg-close").fadeOut(); $(".pic-scroll-tc").fadeOut(); $(".cus-reg-tc-wrap").fadeOut(); $(".cus-reg-bg").fadeOut(); swiper.removeAllSlides(); //移除全部 swiper.update(); }); })