[베네피트][미미위켄드] 치크 챔피온스 (미니 블러셔 5종) - 미미박스(Memebox)
#설렘가득 미니 블러셔 5종 리미티드 에디션 [베네피트][미미위켄드] 치크 챔피온스 (미니 블러셔 5종)
BEST 정** | 2019.11.05
베네피트 중상은 하는 제품이지요!
큰 사이즈는 지금도 사용중이거나 그전에 다 써봤는데..
드림러쉬만 못 써봐서 구매합니다.
향도 좋고 발색도 은은하니 잘되고 미세한 골드펄이 있어서 예뻐요~
아이세도우로 사용해도 예뻐요~!
미니를 3만원에 5칼라를 살수있어서 부담도 없고 좋습니다!
미니쉘 초코렛이 생각나는 포장 너무 귀염귀염 합니다.
그리고 종이박스 아닙니다! 플락스틱 케이스라 튼튼합니다.
'); }else{ html.push(contents.text); } } if(html.length > 0){ $('.bandContents_'+bandId).html(html.join('')); } }else{ console.log('\tskip render '+ bandId); } }, dealDetail: function(data){ $('#dealContent').html(data); // 밴드 상세정보 클릭/옵션선태 버튼 클릭 // deal 객체가 이미 있다고 가정함 $.each($('#dealContent').find('div'), function(){ if($(this).attr('id') && $(this).attr('id').indexOf('band') >= 0){ try{ var bandId = $(this).attr('id').split("_")[1]; var dealId = $(this).data('dealid'); var self = $(this); $.each(bands, function(k, v){ if(v.id === parseInt(bandId) && v.articleStatus !== 'OPENED'){ self.addClass('is-sold-out'); } }); if($(this).attr('class').indexOf('is-sold-out') === -1){ $.each($(this).find('button'), function(){ if($(this).attr('class').indexOf('status__sale-detail') >= 0){ $(this).on('click', function () { console.log('click detail', bandId, dealId); try{ deal.showBandDetail = true; deal.loadBandsDetail(bandId); }catch(e){} }); }else if($(this).attr('class').indexOf('status__sale-option') >= 0){ $(this).on('click', function () { console.log('click option', bandId, dealId); if($('.select_band').length === 0){ Render.band(deal.bands); } $('.order-selected').hide(); $('.order-product').show(); try{ deal.selectBand(parseInt(bandId)); }catch(e){} // 딜상세에서 밴드 선택 try{ analytics.track('Band Select', { id: '588169', // Product ID name: '[베네피트][미미위켄드] 치크 챔피온스 (미니 블러셔 5종)', // Product Name band_id: bandId, // bandId band_name: deal.selectionBand.name // bandName }); }catch(e){} }); } }); } }catch(e){ console.log(e); } } }); try { var arrLink = $('#dealDetail').find('a'); $.each(arrLink, function() { if($(this).attr('href').indexOf('memebox://uri/parse?url=http://m.') >= 0) { this.href = $(this).attr('href').replace('memebox://uri/parse?url=http://m.', 'http://m.'); } if($(this).attr('href').indexOf('memebox://uri/parse?url=http://www.') >= 0) { this.href = $(this).attr('href').replace('memebox://uri/parse?url=http://www.', 'http://m.'); } }); } catch(e) { } }, relatedContents: function(data){ var tmpl = Handlebars.templates['dealRelatedContents']; if(tmpl){ var html = tmpl(data); $("#relatedContents").html(html); console.log('Render.relatedContents', data); } }, recommendation: function(data){ var tmpl = Handlebars.templates['dealRecommendation']; if(tmpl){ var html = tmpl(data); $("#recommendationDeals").html(html); console.log('Render.recommendation', data); } }, delivery: function(data){ var tmpl = Handlebars.templates['dealInfo']; if(tmpl){ var html = tmpl(data); $("#dealInfo .contentsDetail").html(html); console.log('Render.delivery', data); } } }; var Article = function(data){ return { id: data.id, name: data.name, salePrice: data.salePrice, status: data.status, type: data.type, image: data.image, isImage: (data.isImage)? data.isImage : false }; }; var ArticleOption = function(data){ return { name: data.name, status: data.status } }; var Band = function(data){ return { id: data.id, seq: data.seq, articleStatus: data.articleStatus, name: data.name, originPrice: data.originPrice, salePrice: data.salePrice, image: data.image, status: data.articleStatus, articles: [], selections: [], optionStyle: data.optionStyle, options: data.options, contents: data.contents, addSaleItems: function(step, articles){ console.log('Band.addSaleItems', step, articles) var self = this; if(typeof articles === 'undefined'){ return false; } let isImage = !!(articles.items.find(function(item){ return (item.contents && item.contents.length > 0 && item.contents[0].content); })); self.articles = self.articles.slice(0, step); self.articles.push({ type: articles.type, data: articles.items.map(function(item){ if(item.contents && item.contents.length > 0 && item.contents[0].content){ item['image'] = item.contents[0].content.uri; } item['isImage'] = isImage; return (articles.type === 'article')? Article(item) : ArticleOption(item); }) }); /** * 1. 선택한 band의 article selectbox 생성 : .order-product__item **/ var options = { style: self.optionStyle, data: self.articles[step].data, options: self.options }; if(self.articles[step].type === 'article'){ options['title'] = (self.options.length > 0)? self.options[0].title : ''; Render.article(step, options); }else{ Render.option(step, options); } }, addSelection: function(step, value){ console.log('Band.addSelection', step, value) var self = this; /* * 선택한 다음스텝의 selectbox 는 모두 삭제 * */ self.resetSelection(step); self.selections.push(value); }, resetSelection: function(step){ console.log('Band.resetSelection', step) var self = this; if(typeof step === 'undefined' || step > self.selections.length){ return false; } self.selections = self.selections.slice(0, step); /** * 1. step + 1 부터 selectbox 삭제 : .order-product__item **/ step++; $.each($('.order-product__item').find('select'), function(){ var classList = $(this).attr('class').split(' '); var selectboxName = classList.find(function(item){ return item.indexOf('select_') >= 0;}); let splitName = selectboxName.split('_'); if(parseInt(splitName[2]) >= step){ $(this).selectric('destroy'); $(this).remove(); } }); } }; }; var CartItem = function(){ return { article: null, qty: 1, pointRate: 1, totalPrice: 0, addPoint: 0, init: function(data){ var self = this; self.article = data.article; self.qty = data.qty || 1; self.pointRate = data.pointRate || 1; self.calcTotal(); }, changeQty: function(qty){ this.qty = qty; this.calcTotal(); }, calcTotal: function () { this.totalPrice = this.article.salePrice * this.qty; this.addPoint = Math.ceil((this.totalPrice * this.pointRate) / 100); } } }; var Cache = function(){ return { cacheData: {}, add: function(key, value){ console.log('\tCache.add', key, value); this.cacheData[key] = value; return true; }, remove: function(key){ console.log('\tCache.remove', key); this.cacheData[key] = null; }, get: function(key){ var cacheData = this.cacheData[key]; if(cacheData){ console.log('\tCache.get', key, cacheData); } return cacheData; } } }; var Deal = function(){ return { selectionBand: null, bands: [], bandsDetail: null, dependArticles: [], cartItems: [], showBandDetail: false, setBandDetailId: null, submit: false, readOnly: false, cache: Cache(), buyLimit: { min: { deal: 1, article: 1 // 1003xxxx: 최소 xxxx }, max: { deal: 999, // 150000xx: 최대 xx개, 150003xx: 최대 xx회(구매횟수), 15xxxyyy: xxx일 최대 yyy개 article: 999 // 1004xxxx: 최대 xxxx개 } }, init: function(){ var self = this; var policyItems = '[21000000,20030001,20050001,20010005,31010000,30010000]'; if(!policyItems || policyItems === '[]'){ return false; } try{ policyItems = JSON.parse(policyItems); for(var i = 0; i< policyItems.length; i++){ var item = parseInt(policyItems[i]); // deal은 구현하지 않기로 함 if(item >= 10040001 && item <= 10049999){ self.buyLimit.max.article = (item % 10040000 > 0)? item % 10040000 : 1; }else if(item >= 10030001 && item <= 10039999){ self.buyLimit.min.article = (item % 10030000 > 0)? item % 10030000 : 1; } } }catch(e){ return false; } }, addBands: function(bands){ var self = this; if(typeof bands !== 'object'){ return false; } console.log('Deal.addBands', bands); self.bands = []; bands.map(function(band){ if(band.contents && band.contents.length > 0 && band.contents[0].content){ band['image'] = band.contents[0].content.uri; } self.bands.push(Band(band)); }); }, selectBand: function(bandId){ var self = this; console.log('Deal.selectBand', bandId); if(bandId !== null && $('.select_band').length >= 1 && parseInt($('.select_band').val()) !== bandId){ console.log('\tchange value: ', $('.select_band').val(), ' -> ', bandId); $('.select_band').val(bandId); console.log('\trefresh') $('.select_band').selectric('refresh'); console.log('\tclose') $('.select_band').selectric('close'); // close 하면 onChange 가 호출됨 return false; } if(self.readOnly){ return false; } var self = this; self.setSelectionBand(bandId); console.log('\tset selectband', self.selectionBand); /** * article / option 초기화 */ $('.order-product__item').empty(); console.log('\tempty : order-product__item') if(bandId === null){ $('.select_band').val('0'); $('.select_band').selectric('refresh'); }else{ self.selectionBand.selections = []; self.loadSaleItems({step: 0}); } }, setSelectionBand: function(bandId){ var self = this; bandId = parseInt(bandId); self.selectionBand = null; self.bands.map(function(band){ if(band.id === bandId){ self.selectionBand = band; } }); }, selectBandArticle: function(step, value){ console.log('Deal.selectBandArticle', step, value); var self = this; self.selectionBand.addSelection(step, value); self.loadSaleItems({step: (step + 1)}); }, loadAjaxData: function(options, callback){ var cacheData = this.cache.get(options.cacheKey); if(options.cacheKey && (!options.data || !options.data.selectItems || options.data.selectItems.length === 0) && cacheData){ setTimeout(function(){callback(null, cacheData)}, 0); return true; } $.ajax( options ).done(function (res) { return callback(null, res); }).fail(function (res) { return callback(res); }); }, loadBandsDetail: function(bandId){ var self = this; console.log('Deal.loadBandsDetail', bandId); //todo: band 단위로 불러오도록 변경필요 var cacheKey = 'bandDetail'; var options = { type: 'get', url: '/ajax/product/588169/bands', cache: false, cacheKey: cacheKey }; self.loadAjaxData(options, function(err, res){ if(err && err.msg){ alert(err.msg); return false; } console.log('\tajax', res) if(res && res.data && res.data.graphQLErrors){ var errMsg = ''; try{ errMsg = res.data.graphQLErrors[0].message; }catch(e){ errMsg = '일시적인 장애 입니다. 고객센터에 문의해 주세요.'; } return callback(errMsg); } self.cache.add(cacheKey, res); if(res && res.data){ var bands = res.data.map(function(band){ return new Band(band); }); /** * 1. 선택한 밴드 정보를 this.selectionBand 에 할당 * 2. band 상세설명 띄우기 **/ self.setSelectionBand(bandId); self.bandsDetail = bands; Render.bandsDetail(parseInt(bandId), self.bandsDetail); } }); }, loadSaleItems: function(params){ console.log('Deal.loadSaleItems', params); /** * 추가구성 상품(params.depended === true) 은 bandId, selectItems를 보내지 않음 **/ var self = this; if(typeof params.depended === 'undefined'){ params['depended'] = false; } var bandId = (params.depended || self.selectionBand.id < 1)? null : self.selectionBand.id; var selectItems = (params.depended)? [] : self.selectionBand.selections; var cacheKey = 'band_'+ ((bandId === null)? -1 : bandId); if(params.depended === true){ cacheKey += '_depended' } var options = { type: 'post', url: '/ajax/product/588169/saleItems', data: { productId: parseInt('588169'), bandId: bandId, selectItems: selectItems, depended: (!params.depended)? false: params.depended }, cache: false, cacheKey: cacheKey }; self.loadAjaxData(options, function (err, res){ if(err && err.msg){ alert(err.msg); return false; } if(!res.data.selected && (params.step === 0 || params.depended === true)){ self.cache.add(cacheKey, res); } console.log('\tajax', res); var items = res.data.items; var isSmartOption = false; // 최종선택 상품 -> 장바구니 담기 대상 if(res.data.selected){ var selectArticle = res.data.selected; if(selectArticle && selectArticle.contents && selectArticle.contents.length > 0 && selectArticle.contents[0].content){ selectArticle['image'] = selectArticle.contents[0].content.uri; } self.addCartItem(Article(selectArticle)); if(self.showBandDetail === false){ self.selectBand(((self.bands.length > 1)? null: -1)); } }else if(isSmartOption === false && items.length === 1 && items[0].type === 'DEFAULT'){ $('#openBands').remove(); self.selectionBand.selections.push(items[0].id); self.readOnly = true; self.loadSaleItems(params); }else if(typeof params.depended === 'undefined' || params.depended === false) { // 다음단계 article or option self.selectionBand.addSaleItems(params.step, res.data); }else{ // 추가구성 상품 self.addDependArticle(res.data.items) } return false; }); }, loadDetail: function(){ var self = this; var options = { type: 'get', url: '/ajax/product/588169/detail', data: {}, cache: false }; self.loadAjaxData(options, function(err, result){ if(err || !result.data || !result.data.contents){ alert('일시적인 오류 입니다.'); return false; } if(result.data.contents) { Render.dealDetail(result.data.contents); console.log('loading: deal contents'); } if(result.data.relatedContents){ Render.relatedContents(result.data.relatedContents); } }); }, loadRecommencation: function(){ var self = this; var options = { type: 'post', url: '/ajax/product/588169/recommendation', data: { categoryGroupId: 730, brandId: 41592, brandName: "베네피트" }, cache: false }; self.loadAjaxData(options, function(err, result){ if(err || !result.data || !result.data.recommendationDeals){ alert('일시적인 오류 입니다.'); return false; } if(result.data.recommendationDeals) { var searchSegmentData = { s_keywords: getUrlParameter('q'), s_productId: '588169', s_category: '730', s_brand: '41592' }; result.data['searchSegmentData'] = searchSegmentData; Render.recommendation(result.data); } }); }, loadDelivery: function(){ var self = this; var options = { type: 'get', url: '/ajax/product/588169/deliverynDealInfo', cache: false }; self.loadAjaxData(options, function(err, result){ if(err || !result.data){ alert('일시적인 오류 입니다. 잠시 후 다시 시도해 주세요.'); return false; } if(result.data){ Render.delivery(result.data); } }); }, addDependArticle: function(articles){ console.log('Deal.addDependArticle', articles); var self = this; if(typeof articles !== 'object'){ return false; } let isImage = !!(articles.find(function(item){ return (item.contents && item.contents.length > 0 && item.contents[0].content); })); self.dependArticles = []; articles.map(function(article){ if(article.contents && article.contents.length > 0 && article.contents[0].content){ article['image'] = article.contents[0].content.uri; } article['isImage'] = isImage; self.dependArticles.push(Article(article)); }); /** * 1. 추가구성상품 article selectbox 생성 : .dependedArticles **/ Render.depended(self.dependArticles); }, addDependedCartItem: function(articleId){ var self = this; console.log('Deal.addDependedCartItem', articleId); var findArticle = self.dependArticles.find(function(article){ return article.id === articleId }); if(!findArticle){ return false; } self.addCartItem(Article(findArticle)); }, addCartItem: function(articleObject){ console.log('Deal.addCartItem', articleObject); var self = this; if(articleObject.type === 'DEPENDED'){ var dependedItem = self.cartItems.find(function(item){ return item.type !== 'DEPENDED'; }); if(!dependedItem){ alert('추가구성상품만 구매하실 수 없습니다.'); return false; } } var duplicate = self.cartItems.find(function(item){ return item.article.id === articleObject.id; }); if(!duplicate){ var cartItem = CartItem(); cartItem.init({article: articleObject, qty: self.buyLimit.min.article}); self.cartItems.push(cartItem); /** * 1. 구매대상 article 정보추가 생성 -> .selectedArticles (일반상품) .selectedDependedArticles (추가구성상품) **/ Render.cartItem(cartItem); }else{ $('.order-product').hide(); $('.order-selected').show(); var plus = (self.buyLimit.max.article > duplicate.qty)? ++duplicate.qty : self.buyLimit.max.article; self.changeQtyCartItem(articleObject.id, plus); } self.calcCartItem(); }, changeQtyCartItem: function(articleId, qty){ var self = this; console.log('Deal.changeQtyCartItem', articleId, qty); var cartItem = this.cartItems.find(function(item){ return item.article.id === articleId; }); if(!cartItem){ return false; } console.log('\tset cartItem', cartItem); // 구매갯수 제한 qty = (qty < self.buyLimit.min.article)? self.buyLimit.min.article : qty; qty = (qty > self.buyLimit.max.article)? self.buyLimit.max.article : qty; cartItem.changeQty(qty); self.calcCartItem(); $('.item-qty__text[data-articleid='+ articleId +']').val(qty); $('.item-price__number[data-articleid='+ articleId +']').html(cartItem.totalPrice.toString().replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")); }, removeCartItem: function(articleId){ var self = this; console.log('Deal.removeCartItem', articleId); var counter = { default: 0, depended: 0 }; var newCart = this.cartItems.filter(function(item){ if(item.article.id !== articleId && item.article.type === 'DEPENDED'){ counter.depended++; }else if(item.article.id !== articleId){ counter.default++; } return item.article.id !== articleId; }); if(counter.default === 0 && counter.depended > 0){ alert('추가구성상품만 구매하실 수 없습니다.'); return false; } if(counter.default === 0){ $('.order-selected__block').hide(); } if(counter.depended === 0){ $('.order-selected__block-additional').hide(); } self.cartItems = newCart; self.calcCartItem(); return true; }, deleteAllCartItem: function(){ var self = this; if(self.readOnly === true){ return false; } $('.order-selected__block .order-selected__list').empty(); $('.order-selected__block-additional .order-selected__list').empty(); $('.order-selected__block').hide(); self.cartItems = []; self.calcCartItem(); }, calcCartItem: function(){ var totalCount = 0; var totalPrice = 0; var totalPoint = 0; this.cartItems.map(function(item){ totalCount += item.qty; totalPrice += item.totalPrice; totalPoint += item.addPoint; }); /** * 갯수, 금액표시 */ $('.status-qty-number').html(totalCount.toString().replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")); $('.status-price__number').html(totalPrice.toString().replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")); $('#memePoint').html(totalPoint.toString().replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")); // MW 미사용 // if(totalCount === 0){ // $('#memePointInfo').show(); // $('#memePointResult').hide(); // }else{ // $('#memePointInfo').hide(); // $('#memePointResult').show(); // } }, submitCart: function(callback){ var self = this; if(self.submit === true){ return callback('working... please wait.'); } if(self.cartItems.length <= 0){ alert('구매할 상품을 선택하세요.'); // return callback('empty item'); return false; } var cartObject = { carts: [] }; self.cartItems.map(function(item){ cartObject.carts.push({'itemId': item.article.id, 'itemCount': item.qty, 'price': item.totalPrice, 'itemTitle': item.article.name}); }); $.ajax({ type: 'post', url: '/ajax/cart/add', data: cartObject, cache: false }).done(function (res) { console.log(res); self.deleteAllCartItem(); callback(null, res.data); }).fail(function (res) { console.log('err', res); var jqXHRTmp = JSON.parse(res.responseText); callback(jqXHRTmp.msg); }).always(function () { self.submit = false; }); }, submitPurchase: function(callback){ var self = this; if(self.submit === true){ return callback('working... please wait.'); } if(self.cartItems.length <= 0){ alert('구매할 상품을 선택하세요.'); // return callback('empty item'); return false; } var cartObject = { carts: [] }; self.cartItems.map(function(item){ cartObject.carts.push({'itemId': item.article.id, 'itemCount': item.qty, 'price': item.totalPrice, 'itemTitle': item.article.name}); }); $.ajax({ type: 'post', url: '/ajax/checkout', data: cartObject, cache: false }).done(function (jqXHR) { callback(null, jqXHR.data); }).fail(function (jqXHR) { // 해당 오류 메세지 노출 var jqXHRTmp = JSON.parse(jqXHR.responseText); callback(jqXHRTmp.msg); }).always(function () { self.submit = false; }); } } }; try{ var bands = JSON.parse('[{"id":-1,"seq":0,"articleStatus":"SOLDOUT","name":"","originPrice":0,"salePrice":0,"image":"","status":"SOLDOUT","optionStyle":"DEFAULT","options":[],"contents":[]}]'.replace(/"/g, '"')); var saleItem = JSON.parse(''.replace(/"/g, '"')); }catch(e){ console.log(e); } deal.loadDetail(); // 밴드/아이템 선택하기 $('#openBands').on('click', function() { if(deal.bands.length === 0){ return false; } $('.order-selected').hide(); $('.order-product').show(); /** * band, article 초기화 * 1. 선택한 band 초기화 * 2. 밴드가 여러개 일때: 밴드 선택 초기화 * 3. 밴드가 1개 일때: 밴드 감추기 * */ if(deal.bands.length > 1){ Render.band(deal.bands); }else{ deal.selectBand(deal.bands[0].id); } }); // 추가구성상품 선택하기 $('#openAddItems').on('click', function() { /** * 1. 생성되어 있는 band selectbox 삭제 **/ if($('#select_band').length > 0){ $('#select_band').selectric('destroy'); $('#select_band').remove(); } $('.order-selected').hide(); $('.order-product').show(); deal.loadSaleItems({depended: true}); }); // 개별 옵션 수량 변경 $(document).on('click', '.item-qty__trigger', function () { var $this = $(this); var thisId = $this.data('articleid'); var qty = Number($('.item-qty__text[data-articleid='+ thisId +']').val()); if ($this.hasClass('item-qty__up')) { qty++; }else{ qty--; } if(qty <= deal.buyLimit.min.article){ qty = deal.buyLimit.min.article; } console.log('change qty', thisId, qty); deal.changeQtyCartItem(parseInt(thisId), qty); }); // 선택한 아이템 삭제처리 $(document).on('click', '.item-delete', function () { var $this = $(this); var thisId = $this.closest('.order-selected__item'); if (deal.readOnly === true && $this.closest('.order-selected__list').data('type') !== 'depended') { return false; } if(deal.removeCartItem(parseInt($this.data('articleid'))) === true){ $(thisId).remove(); } }); // 즉시구매 버튼 $('.order-trigger-purchase').on('click', function () { var searchKeyword = getUrlParameter('q'); var st = getUrlParameter('st'); var sct = getUrlParameter('sct'); deal.submitPurchase(function(err, result){ if(err){ alert(err); return false; } var loginChk = ''; if (!loginChk && !!result.type && result.type == 'temp') { location.href='/login?returnUrl='+escape('/bridge/checkout'); return false; } if(!result.cid){ alert('일시적인 오류입니다. 고객센터에 문의해 주세요'); return false; } // 즉시 구매 try{ analytics.track('Button Clicked', { category: 'Product Page', label: 'Checkout Right Away Button', band_id: deal.setBandDetailId && deal.showBandDetail === true? deal.setBandDetailId : null, s_keywords: searchKeyword }); }catch(e){} location.href='https://order.memebox.com/order/'+result.cid+'?q='+encodeURI(searchKeyword) + '&st=' + st + '&sct=' + sct; }); }); // 장바구니 넣기 처리 $('#cartAddBtn').on('click', function () { deal.submitCart(function(err, result){ if(err){ alert(err); return false; } // Segment Track Button Behaviour analytics.track('Button Clicked', { category: 'Product Page', label: 'Only Add To Cart Button' }); // GTM addToCart var products = []; for (var i = 0; i < deal.cartItems.length; i++) { products.push({ // Provide product details in a productFieldObject. 'id': deal.cartItems[i].article.id, // Product ID (string). 'name': deal.cartItems[i].article.name, // Product name (string). 'brand': '베네피트', 'category': '', // Product brand (string). 'variant': '', // Product variant (string). 'price': deal.cartItems[i].totalPrice, 'quantity': deal.cartItems[i].qty }); // Segment Analytics: Add To Cart try{ analytics.track('Cart Added', { id: '588169', // Product ID name: '[베네피트][미미위켄드] 치크 챔피온스 (미니 블러셔 5종)', // Product Name item_id: deal.cartItems[i].article.id, // SKU is Variant ID item_name: deal.cartItems[i].article.name, // item_title band_id: deal.setBandDetailId && deal.showBandDetail === true? deal.setBandDetailId : null, quantity: deal.cartItems[i].qty // Variant Quantity }); }catch(e){} } try{ fbq('track', 'AddToCart', { content_type: 'product', content_ids: ['588169'], content_name: '[베네피트][미미위켄드] 치크 챔피온스 (미니 블러셔 5종)', contents_category: fbqCategoryName || '' }); }catch(e){} try{ dataLayer.push({ 'event': 'addToCart', 'ecommerce': { 'currencyCode': 'KRW', 'add': { 'products': products } } }); }catch(e){} if(result.cartTotalCount >= 0){ if(!!$('.cart-block-number').length) { $(".cart-block-number").html(result.cartTotalCount); } else { $('.cart-block-icon').append('' + result.cartTotalCount + ''); } } if(confirm('장바구니에 상품이 담겼습니다. 장바구니로 이동하시겠습니까?')){ setTimeout(function(){ location.href='https://order.memebox.com/cart'; },100); } }); }); // 옵션선택창 열기 $('.order-trigger').click(function(e){ e.preventDefault(); if(deal.showBandDetail === true){ /** * 밴드 상세설명 보기 화면인 경우 (선택된 밴드 정보가 있음) **/ Render.band(deal.bands); $('.order-product').show(); deal.selectBand(deal.selectionBand.id); }else if(deal.cartItems.length === 0) { /** * 장바구니 대상 아이템이 없으면 첫번째 밴드와 아이템 목록을 보여줌 (미리 가져온 saleItem 노출) **/ if(deal.bands.length > 1){ Render.band(deal.bands); }else{ deal.selectBand(deal.bands[0].id); } $('.order-product').show(); }else{ /** * 장바구니 대상 아이템 목록을 보여줌 **/ $('.order-selected').show(); } if(deal.isSmartOption === true && deal.selectionBand !== null){ // deal.selectBand(deal.selectionBand.id); //fixme: band를 변경했는데, onChange 이벤트가 발생하지 않음 // deal.selectBand(deal.selectionBand.id) } return false; }); // 옵션선택창 닫기 $('.order-block__close').on('click', function() { $target = $($(this).closest('.order-block')); $target.hide(); /** * 밴드 설명을 보고 있으면 deal.selectionBand 를 초기화 하지 않음 -> 밴드 설명을 닫을때 초기화 */ if(deal.showBandDetail === false){ deal.setSelectionBand(null); } /** * 장바구니 대상상품이 있을때는 닫지않고, 해당 상품목록 layer를 보여줌 */ if($target.hasClass('order-selected') === false && deal.cartItems.length > 0){ $('.order-selected').show(); } }); // 상품소개 더보기 $('.contentsMoreBtn').on('click', function() { // $('.contentsBtnWrap').toggle(); var $targetEle = $('#dealDetail'); var foldClassName = 'dealDetail-fold'; var topBanner = $('.contentsTopBanner'); var relatedContents = $('.relatedContentsWrap'); if ( $targetEle.hasClass(foldClassName) ) { $targetEle.removeClass(foldClassName); $targetEle.find('.text').text('상품소개 접기'); topBanner.each(function(obj, idx){ $(this).show(); }); } else { $targetEle.addClass(foldClassName); $targetEle.find('.text').text('상품소개 열기'); topBanner.each(function(obj, idx){ $(this).hide(); }); } }); var isWished = false; var TARGET_TYPE = { PRODUCT: 10001001 }; var disabledWish = false; // 찜하기 클릭 $('#addWish').click(function(){ var loginChk = ''; if(!loginChk){ if (confirm('로그인이 필요한 서비스 입니다. 로그인 하시겠습니까?')) { location.href = 'https://m.memebox.com/login?returnUrl=' + encodeURIComponent(location.href); } return false; } var $addBtn = $(this); var params = { targetType: TARGET_TYPE.PRODUCT, targetId: '587183' || 0 }; if(disabledWish) { return false; } var apiUrl = '/ajax/wish/create'; if(isWished) { apiUrl = '/ajax/wish/remove'; params.id= $(this).attr('data-wishid') || 0; } disabledWish = true; $.ajax({ url: apiUrl, type: 'POST', data: params }).done(function(result) { if(!isWished) { $("#addWish").addClass("on"); isWished = 1; $addBtn.attr('data-wishid', result.data.id); try{ // Segment Analytics: Tracks when user adds product to wishlist analytics.track('Wishlist Added', { id: '588169', name: '[베네피트][미미위켄드] 치크 챔피온스 (미니 블러셔 5종)' }); }catch(e){} try { fbq('track', 'AddToWishlist', { content_type: 'product', content_ids: ['588169'], content_name: '[베네피트][미미위켄드] 치크 챔피온스 (미니 블러셔 5종)', contents_category: fbqCategoryName || '' }); }catch(e){} return alert('찜한 상품에 저장 되었습니다.'); } else { $("#addWish").removeClass("on"); isWished = 0; $addBtn.attr('data-wishid', 0); // Segment Analytics: Tracks when user removes product from wishlist analytics.track('Wishlist Removed', { id: '588169', name: '[베네피트][미미위켄드] 치크 챔피온스 (미니 블러셔 5종)' }); return alert('찜한 상품에서 해제 되었습니다.'); } }).fail(function(jqXHR) { var error = JSON.parse(jqXHR.responseText); console.log(error); alert(error.msg || ' 다시 시도해주세요. '); }).always(function() { disabledWish = false; return false; }); }); // 상품상세정보 네비게이션 var lastId; var topMenu = $('.dealContents-nav'); var topMenuHeight = topMenu.outerHeight(); var menuItems = topMenu.find('a'); var scrollItems = menuItems.map(function(){ var item = $($(this).attr('href')); if (item.length) { return item; } }); // 메뉴 클릭 (상품설명 위) menuItems.on('click', function(e){ var href = $(this).attr('href'), offsetTop = (href === '#') ? 0 : $(href).offset().top - topMenuHeight + parseInt($(href).css('padding-top')) + 1; if ( $(href).offset().top <= $(window).scrollTop() ) { offsetTop -= $('.page-header-history-wrap').outerHeight() - 1; } $('html, body').stop().animate({ scrollTop: offsetTop }, 300); return false; }); // 쿠폰북 $('#couponPageOpenBtn').click(function (){ analytics.track("Button Clicked", { name: $(this).text().trim() // name: 할인쿠폰 }); var couponObj = { productId: '588169' || 0, brandId: '41592' || 0, partnerId: '16' || 0, categoryId: '730,332,177' || 0 }; location.href='/coupon/list?productId='+couponObj.productId+'&brandId='+couponObj.brandId+'&partnerId='+couponObj.partnerId+'&categoryId='+couponObj.categoryId; return false; }); // 브랜드샵 링크 $('#brandShopLink').click(function() { analytics.track("Button Clicked", { name: $(this).attr('data-name') // name: 할인쿠폰 }); }); function getUrlParameter(sParam) { try { var sURLVariables = location.search.substring(1).split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? '' : decodeURIComponent(sParameterName[1]).replace(/\+/g, ' '); } } } catch(ex){ console.error(ex); } return ''; } function elementScrolled(elem) { var docViewTop = $(window).scrollTop(); var docViewBottom = docViewTop + $(window).height(); var elemTop = $(elem).offset().top; return ((elemTop <= docViewBottom) && (elemTop >= docViewTop)); } function deviceException(){ var bottomBuffer = "50px"; var bottomBufferToggle = 0; var ua = $("#userAgent").data('ua'); var exceptionList = ["LG-F240"]; for (var i = 0;i=0) { if(ua.indexOf('Chrome')==-1) { $(".dealOption").css('bottom','50px'); $(window).scroll(function() { if($(window).scrollTop() + $(window).height() +50 > $(document).height()) { if(bottomBufferToggle ==0) { $(".dealOption").css('bottom','0px'); } bottomBufferToggle = 1 } else { if(bottomBufferToggle == 1) { bottomBufferToggle = 0; { $(".dealOption").css('bottom',bottomBuffer); } } } }); } } } } $('.timer').memeCountdown({ prefix: '', msg : '판매가 종료되었습니다.' }); var loadDeliveryInfo = false; var loadRecommendation = false; // scroll 이벤트 $(window).scroll(function(){ if ( $(this).scrollTop() > $('.dealContents').offset().top ) { var fromTop = $(this).scrollTop() + topMenuHeight; if (topMenu.hasClass('headroom--pinned')) { fromTop += $('.page-header-history-wrap').outerHeight(); } var cur = scrollItems.map(function () { if ($(this).offset().top < fromTop) return this; }); cur = cur[cur.length - 1]; var id = cur && cur.length ? cur[0].id : "1234"; if (lastId !== id) { lastId = id; menuItems.parent().removeClass("on").end().filter("[href='#" + id + "']").parent().addClass("on"); } } // 배송/판매정보 로드 if(!loadDeliveryInfo && elementScrolled('#dealInfoTitle')){ loadDeliveryInfo = true; deal.loadDelivery(); } // 고객추천 로드 if(!loadRecommendation && elementScrolled('#dealRecommend')){ loadRecommendation = true; deal.loadRecommencation(); } }); // 찜했는지 체크 function checkWished(){ var loginChk = ''; if(!loginChk){ return false; } var options = { type: 'get', url: '/ajax/wish/findOne?dealId=588169', data: {}, cache: false }; deal.loadAjaxData(options, function(err, result){ if(err || !result.data){ alert('일시적인 오류 입니다.'); return false; } isWished = !!(result.data.wishId); if(isWished){ $('#addWish').addClass('on'); $('#addWish').attr('data-wishid', result.data.wishId); } }); } // load 이벤트 $(function() { deviceException(); checkWished(); });