(function($){ $(document).ready(function(){ var funcNumberFormat = function(number){ return number.toString().replace(/([0-9]+?)(?=(?:[0-9]{3})+$)/g , '$1,'); }, //config cfg = { api:{ url:'https://alamode1.xsrv.jp', shopId:18, displayKeywords:'【スタッフコーデ】', //表示キーワード displayKeywordsFlag:1, //キーワードフラグ※0 => 'OR検索', 1 => 'AND検索' sortItem:'id', //並び順対象項目 sortRows:'1', //昇降順 seasonCodeReflect:'0', //季節コード※0 => '反映しない', 1 => '反映する' stockFlg:'1', //在庫切れ商品※0 => '表示しない', 1 => '表示する' limit:30 //上限数 }, staffCoordinateCarousel:{ items:6, itemsDesktop:[1199, 6], itemsDesktopSmall:[979, 6], itemsTablet:[768, 6], itemsMobile:[479, 6], autoPlay:3000, singleItem:false, navigation:true, navigationText:[ '前へ', '次へ' ], slideSpeed:500, paginationSpeed:700 }, detail:{ detailOpacitySpeed:400, cssMarginDetailArea:30 } }, //constructor cst = new function(){ this.getItemCode = location.href.match(/\/fs\/alamode\/([a-z0-9_\-]+)/); this.itemCode = this.getItemCode !== null?this.getItemCode[1]:''; this.staffList = new Array(); this.flagGetDetail = true; }, funcGetStaffCoordinateCarousel = function(){ var eleStaffCoordinateCarousel = $('#staff_coordinate_carousel'), eleStaffCoordinateCarouselParent = $('#staff_coordinate_carousel_parent'); $.ajax({ url:cfg.api.url + '/shop/set_item/search/index.php?request=get_list' + '&shop_id=' + cfg.api.shopId + '&season_code_reflect=' + cfg.api.seasonCodeReflect + '&display_keywords=' + encodeURIComponent(cfg.api.displayKeywords) + '&display_keywords_flag=' + cfg.api.displayKeywordsFlag + '&item_code=' + encodeURIComponent(cst.itemCode) + '&sort_item=' + cfg.api.sortItem + '&sort_rows=' + cfg.api.sortRows + '&limit=' + cfg.api.limit, dataType:'jsonp', error:function(jqXHR, textStatus, errorThrown){ console.log(textStatus); }, success:function(response, textStatus, jqXHR){ if(response.total === '0') return false; for(var i = 0, l = response.set_item.length;i < l;i++){ var d = response.set_item[i], id = d.comment.match(/【id:(.+?)】/), keyId = id === null?'-1':id[1], comment = d.comment.replace(/\r?\n/g, "").match(/【comment:(.+?)】/), staffInfo = typeof cst.staffList[keyId] !== 'undefined'? cst.staffList[keyId]:{ name:'', size:'' }, dataComment = comment === null?'':comment[1]; eleStaffCoordinateCarousel .append('\
\ \ スタッフコーディネート\ \
\ '); } //詳細表示用イベントリスナー $('.staff_coordinate_item_check_button').each(function(){ $(this).on('click', function(){ var dataSetItemCode = $(this).data('set_item_code'), dataCoordinateImg = $(this).data('coordinate_img'), dataComment = $(this).data('comment'), dataStaffId = $(this).data('staff_id'), dataName = $(this).data('name'), dataSize = $(this).data('size'); showDetail(dataSetItemCode, dataCoordinateImg, dataComment, dataStaffId, dataName, dataSize); }); }); eleStaffCoordinateCarousel.owlCarousel(cfg.staffCoordinateCarousel); eleStaffCoordinateCarouselParent.show(); } }); }, showDetail = function(setItemCode, coordinateImg, comment, staffId, name, size){ if(cst.flagGetDetail === false) return false; cst.flagGetDetail = false; $('#staff_coordinate_detail_area').html('\
\
\ \ ×\ \
\ \
\
\
\
\ \
\ \ \ 【' + name + ' ' + size + '】\ \
\
\ ' + (comment !== '' && comment !== null?'\
\

\ ' + comment + '\

\
':'') + '\
\

\ \合わせたアイテムはコレ/\

\
    \
    \
\
\
\
\
\
\ ') .height($('.layout_body').eq(0).outerHeight(true)) .show(); $('#staff_coordinate_detail_area_inner') .css('top', ($(window).scrollTop() + cfg.detail.cssMarginDetailArea) + 'px') .animate( { 'opacity':'1' }, cfg.detail.detailOpacitySpeed ); $('#staff_coordinate_detail_button_close').on('click', function(){ if(cst.flagGetDetail === false) return false; $('#staff_coordinate_detail_area_inner') .animate({ 'opacity':0 }, cfg.detail.detailOpacitySpeed, function(){ $(this).remove(); $('#staff_coordinate_detail_area').hide(); }); }); //着用商品情報取得 $.ajax({ url:cfg.api.url + '/shop/set_item/search/index.php?request=get_detail&shop_id=' + cfg.api.shopId + '&set_code=' + setItemCode + '&stock_flg=' + cfg.api.stockFlg, dataType:'jsonp', error:function(jqXHR, textStatus, errorThrown){ console.log(textStatus); cst.flagGetDetail = true; }, success:function(data, textStatus, jqXHR){ for(var i = 0, l = data.set_item.length;i < l;i++) $('#staff_coordinate_detail_item_list').append('\
  • \
    \ ' + (data.set_item[i].nostock === '1'?'\ \
    売り切れ
    \ \
    \ ':'\ \ \ \ ') + '\
    \

    \ ' + data.set_item[i].short_name + '\

    \
    \ ' + funcNumberFormat(data.set_item[i].price) + '円\ \ (税抜)\ \
    \ \ ご購入はこちら ≫\ \
    \
    \
  • \ '); cst.flagGetDetail = true; } }); }; $.ajax({ url:'/item/coordinate/staff/configs/staff.json?' + Math.random(), dataType:'json', error:function(jqXHR, textStatus, errorThrown){ console.log(textStatus); }, success:function(response, textStatus, jqXHR){ var code = '\ \ '; if($('#item_color_list_parent')[0]){ $('#item_color_list_parent').after(code); }else if($('#main_item_list_parent')[0]){ $('#main_item_list_parent').after(code); }else{ $('.FS2_additional_image_itemdetail_container').eq(0).append(code); } $('body').append('\ \ '); cst.staffList = response; funcGetStaffCoordinateCarousel(); } }); }); })(jQuery);