//* 商品列表頁與商品詳情頁js程序 */

// 詳情頁頂部大圖
//  var swiperTopBig = new Swiper('.big-pic .swiper-container');
 
 // you may also like
//  var alsoLike = new Swiper('.like-pics .swiper-container', {
//    slidesPerView: 2,
//    spaceBetween: 30,
//    slidesPerGroup: 2,
//    loop: true,
//    loopFillGroupWithBlank: true,
//    navigation: {
// 	 nextEl: '.like-pics .swiper-button-next',
// 	 prevEl: '.like-pics .swiper-button-prev',
//    },
//  });
 
 // you may also like
//  var recentView = new Swiper('.recent-view-pics .swiper-container', {
//    slidesPerView: 2,
//    spaceBetween: 30,
//    slidesPerGroup: 2,
//    loop: true,
//    loopFillGroupWithBlank: true,
//    navigation: {
//  	 nextEl: '.recent-view-pics .swiper-button-next',
//  	 prevEl: '.recent-view-pics .swiper-button-prev',
//    },
//  });
 
 
// 關閉彈窗
 $('body').delegate('.modal-close', 'click', function() {
 	let _this = $(this); 
 	let modal = _this.closest(".modal") ;
	modal.hide() ;
 	return false ;
 }) 

// 尺寸建議
 $('body').delegate('.sizeSuggest', 'click', function() {
 	let modal = $(".modal-size-suggest") ;
	modal.show() ;
 	return false ;
 })
 
// 貨到通知
 $('body').delegate('.relative-product .recommend', 'click', function() {
 	let modal = $(".modal-notice") ;
 	modal.show() ;
 	return false ;
 })
 
 // share
 $('body').delegate('.collect-share .share', 'click', function() {
 	let modal = $(".modal-share") ;
 	modal.show() ;
 	return false ;
 })
 
 
// 商品数量减
//  $('body').delegate('.p-num-box .reduce', 'click', function() {
//  	let numbox = $(this).closest('.p-num-box') ;
// 	let number = numbox.find('input[name="number"]') ;
// 	let value = number.val() ;
// 	if( value <= 0 ){
// 		value = 0 ;
// 		number.val( value ).focus() ;
// 	}else{
// 		value -- ;
// 		number.val( value ).focus() ;
// 	}
// 	return false ;
//  })
//  // 商品数量加
//  $('body').delegate('.p-num-box .plus', 'click', function() {
//  	let numbox = $(this).closest('.p-num-box') ;
//  	let number = numbox.find('input[name="number"]') ;
//  	let value = number.val() ;
// 	value ++  ;
// 	number.val( value ).focus() ;
//  	return false ;
//  })

// 尺寸切换
//  $('body').delegate('.choose-size .size-item', 'click', function() {
//  	let sizeItem = $(this) ;
// 	// 判断有无货&是否已经选中
// 	if( ! sizeItem.hasClass( '.empty , .active' ) ){
// 		let otherItems = sizeItem.siblings('.size-item') ;
// 		otherItems.removeClass('active') ;
// 		sizeItem.addClass('active') ;
// 	}
//  	return false ;
//  })
 
 // 颜色切换
//   $('body').delegate('.choose-color .color-item', 'click', function() {
//   	let colorItem = $(this) ;
//  	// 判断有无货&是否已经选中
//  	if( ! colorItem.hasClass( '.active' ) ){
//  		let otherItems = colorItem.siblings('.color-item') ;
//  		otherItems.removeClass('active') ;
//  		colorItem.addClass('active') ;
//  	}
//   	return false ;
//   })
 
 // 詳情頁商品收藏
//  $('body').delegate('.collect-share .collect-span', 'click', function() {
//  	let collect = $(this) ;
// 	if( collect.hasClass('collected') ){
// 		//取消收藏
// 		collect.removeClass('collected')
// 	}else{
// 		// 收藏
// 		collect.addClass('collected')
// 	}
//  	return false ;
//  })
 
// 貨到通知我--提交
 $('body').delegate('.n-submit', 'click', function() {
 	let submit = $(this) ;
	// xxx
 	if( ! submit.hasClass('done') ){
 		submit.addClass('done')
 	}
 	return false ;
 })
 

 $(function(){
	// 商品列表頁跳轉內容頁
	// $('body').delegate('.goods-item .img-box', 'click', function() {
	// 	window.location.href = "pages/product_details.html"
	// }) 
 })



/**
 * pc版代碼
 * 
 *----------------------------------------------------------------------------------------------------------------
 */
// 展開左側邊欄
// $('body').delegate('.sidebar-l-tool .m-1', 'click', function() {
// 	let _this = $(this);
// 	if( ! _this.hasClass('ac')  && _this.next('ul').length > 0 ){
// 		_this.addClass('ac').next('ul').slideDown(300)
// 	}else if( _this.hasClass('ac') && _this.next('ul').length > 0 ){
// 		_this.removeClass('ac').next('ul').slideUp(300);
// 	}
// 	return false ;
// })

// 調出關鍵篩選
$('body').delegate('.keywords-btn-pc', 'click', function() {
	let _this = $(this);
	let wordSiderbar = $('.sidebar-words-pc');
	if( _this.hasClass('show') ){
		_this.removeClass('show');
		wordSiderbar.animate({
			right :"-350px"
		},300)
	}else{
		_this.addClass('show');
		wordSiderbar.animate({
			right :"0px"
		},300)
	}
	return false ;
}) 

// 收起關鍵篩選
$("html").delegate(".shops-pc", "click", function(e) {
	let btn = $('.keywords-btn-pc');
	let _con = $('.sidebar-words-pc');
	if (!_con.is(e.target) && _con.has(e.target).length === 0) {
		_con.animate({
			right :"-350px"
		}, 300);
		btn.removeClass('show')
	}
	return;
})



// 商品大圖
// var bigPicsPc = new Swiper('.big-pics-pc .swiper-container', {
//   navigation: {
// 	nextEl: '.big-pics-pc .swiper-button-next',
// 	prevEl: '.big-pics-pc .swiper-button-prev',
//   },
// });
 // you may also like
//  var alsoLike = new Swiper('.like-pics-pc .swiper-container', {
//    slidesPerView: 4,
//    spaceBetween: 30,
//    slidesPerGroup: 4,
//    loop: true,
//    loopFillGroupWithBlank: true,
//    navigation: {
// 	 nextEl: '.like-pics .swiper-button-next',
// 	 prevEl: '.like-pics .swiper-button-prev',
//    },
//  });
 // recentView
//  var recentViewPc = new Swiper('.recent-pics-pc .swiper-container', {
//    slidesPerView: 4,
//    spaceBetween: 30,
//    slidesPerGroup: 4,
//    loop: true,
//    loopFillGroupWithBlank: true,
//    navigation: {
//  	 nextEl: '.recent-pics-pc .swiper-button-next',
//  	 prevEl: '.recent-pics-pc .swiper-button-prev',
//    },
//  });

  
//  // 貨到通知
 //  $('body').delegate('.shops-pc .relative-product .recommend-pc:not(.clicked)', 'click', function() {
 //  	let modal = $(".modal-pc-notice") ;
	// $('body').addClass('overhidden');
	// modal.find('.n-submit').removeClass('done');
 //  	modal.show() ;
 //  	return false ;
 //  })
 

