Showing
12 changed files
with
423 additions
and
101 deletions
@@ -28,7 +28,7 @@ | @@ -28,7 +28,7 @@ | ||
28 | <img src="{{thumb}}"> | 28 | <img src="{{thumb}}"> |
29 | </a> | 29 | </a> |
30 | {{# is_soon_sold_out}} | 30 | {{# is_soon_sold_out}} |
31 | - <p class="few-tag">即将售罄</p> | 31 | + <p class="few-tag ">即将售罄</p> |
32 | {{/ is_soon_sold_out}} | 32 | {{/ is_soon_sold_out}} |
33 | 33 | ||
34 | {{# is_solded}} | 34 | {{# is_solded}} |
@@ -681,7 +681,7 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => { | @@ -681,7 +681,7 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => { | ||
681 | } | 681 | } |
682 | 682 | ||
683 | // 商品信息 | 683 | // 商品信息 |
684 | - let cartInfo = productProcess.processSizeInfo(origin); | 684 | + let cartInfo = productProcess.processSkusInfo(origin); |
685 | let soldOut = (origin.storage_sum === 0) || (cartInfo.totalStorageNum === 0); // status | 685 | let soldOut = (origin.storage_sum === 0) || (cartInfo.totalStorageNum === 0); // status |
686 | let notForSale = origin.attribute === 2; | 686 | let notForSale = origin.attribute === 2; |
687 | let preSale = (origin.status === 0 && origin.advance_shelve_time > 0); | 687 | let preSale = (origin.status === 0 && origin.advance_shelve_time > 0); |
@@ -10,13 +10,13 @@ const isProduction = process.env.NODE_ENV === 'production'; | @@ -10,13 +10,13 @@ const isProduction = process.env.NODE_ENV === 'production'; | ||
10 | const isTest = process.env.NODE_ENV === 'test'; | 10 | const isTest = process.env.NODE_ENV === 'test'; |
11 | 11 | ||
12 | const domains = { | 12 | const domains = { |
13 | - api: 'http://api.yoho.cn/', | ||
14 | - service: 'http://service.yoho.cn/', | 13 | + // api: 'http://api.yoho.cn/', |
14 | + // service: 'http://service.yoho.cn/', | ||
15 | liveApi: 'http://testapi.live.yohops.com:9999/', | 15 | liveApi: 'http://testapi.live.yohops.com:9999/', |
16 | singleApi: 'http://api-test3.yohops.com:9999/', | 16 | singleApi: 'http://api-test3.yohops.com:9999/', |
17 | 17 | ||
18 | - // api: 'http://dev-api.yohops.com:9999/', | ||
19 | - // service: 'http://dev-service.yohops.com:9999/', | 18 | + api: 'http://dev-api.yohops.com:9999/', |
19 | + service: 'http://service-test3.yohops.com:9999/', | ||
20 | // liveApi: 'http://api.live.yoho.cn/', | 20 | // liveApi: 'http://api.live.yoho.cn/', |
21 | // singleApi: 'http://single.yoho.cn/', | 21 | // singleApi: 'http://single.yoho.cn/', |
22 | 22 |
@@ -5,8 +5,7 @@ | @@ -5,8 +5,7 @@ | ||
5 | <div class="infos {{#if @root.tickets}} tickets-info {{/if}}"> | 5 | <div class="infos {{#if @root.tickets}} tickets-info {{/if}}"> |
6 | <div class="basic-info"> | 6 | <div class="basic-info"> |
7 | <div class="thumb-img"> | 7 | <div class="thumb-img"> |
8 | - {{#each thumbs}} | ||
9 | - <img class="thumb {{#unless @first}}hide{{/unless}}" src="{{img}}"> {{/each}} | 8 | + <img class="thumb" src="{{defaultThumb}}"> |
10 | </div> | 9 | </div> |
11 | <div class="text-info"> | 10 | <div class="text-info"> |
12 | <p class="price"> | 11 | <p class="price"> |
@@ -23,25 +22,16 @@ | @@ -23,25 +22,16 @@ | ||
23 | </div> | 22 | </div> |
24 | </div> | 23 | </div> |
25 | <div class="chose-items"> | 24 | <div class="chose-items"> |
26 | - <div class="color-list block-list"> | ||
27 | - <span class="name">{{#if @root.tickets}}日期{{else}}颜色{{/if}}</span> {{#each colors}} | ||
28 | - <ul id="{{id}}" data-index="{{@index}}" class="size-row clearfix {{#unless @first}}hide{{/unless}}"> | ||
29 | - {{#each color}} | ||
30 | - <li class="block {{#if chosed}} chosed{{/if}} {{#unless colorNum}} zero-stock{{/unless}}" data-num="{{colorNum}}">{{name}}</li> | 25 | + {{#each props}} |
26 | + <div class="block-list"> | ||
27 | + <span class="name">{{name}}</span> | ||
28 | + <ul class="size-row clearfix"> | ||
29 | + {{#each values}} | ||
30 | + <li class="block" data-prop-id="{{../type}}" data-value-id="{{id}}">{{name}}</li> | ||
31 | {{/each}} | 31 | {{/each}} |
32 | </ul> | 32 | </ul> |
33 | - {{/each}} | ||
34 | </div> | 33 | </div> |
35 | - <div class="size-list block-list {{#if @root.single}} hide{{/if}}"> | ||
36 | - <span class="name">{{#if @root.tickets}}区域{{else}}尺码{{/if}}</span> {{#each sizes}} | ||
37 | - <ul class="size-row clearfix {{#unless @first}}hide{{/unless}}"> | ||
38 | - {{#each size}} | ||
39 | - <li class="block {{#if chosed}} chosed{{/if}} {{#unless sizeNum}} zero-stock {{/unless}}" data-num="{{sizeNum}}" data-id="{{id}}" | ||
40 | - data-skuid="{{skuId}}" data-info="{{sizeInfo}}">{{name}}</li> | ||
41 | - {{/each}} | ||
42 | - </ul> | ||
43 | {{/each}} | 34 | {{/each}} |
44 | - </div> | ||
45 | <div class="num"> | 35 | <div class="num"> |
46 | <span class="name">数量</span> | 36 | <span class="name">数量</span> |
47 | <div class="clearfix"> | 37 | <div class="clearfix"> |
@@ -70,7 +60,7 @@ | @@ -70,7 +60,7 @@ | ||
70 | </div> | 60 | </div> |
71 | </div> | 61 | </div> |
72 | <div class="btn-wrap"> | 62 | <div class="btn-wrap"> |
73 | - <button id="chose-btn-sure" class="btn btn-sure">{{#if @root.tickets}}立即购买{{else}}加入购物车{{/if}}</button> | 63 | + <button id="chose-btn-sure" class="btn btn-sure">{{@root.buttonText}}</button> |
74 | </div> | 64 | </div> |
75 | </div> | 65 | </div> |
76 | </div> | 66 | </div> |
@@ -38,7 +38,7 @@ var $chosePanel = $('#chose-panel'), | @@ -38,7 +38,7 @@ var $chosePanel = $('#chose-panel'), | ||
38 | queryString, | 38 | queryString, |
39 | $choseArea, | 39 | $choseArea, |
40 | $cartBar, | 40 | $cartBar, |
41 | - $soonSoldOut = $('.soonSoldOut-tag'), | 41 | + $soonSoldOut = $('.soon-sold-out-tag'), |
42 | $yohoPage = $('.yoho-page'), | 42 | $yohoPage = $('.yoho-page'), |
43 | 43 | ||
44 | // 门票 限购数量 | 44 | // 门票 限购数量 |
public/js/common/chose-panel-new.js
0 → 100644
1 | +/** | ||
2 | + * 购物车选择尺寸、颜色和数量面板 | ||
3 | + * @author: feng.chen<feng.chen@yoho.cn> | ||
4 | + * @date: 2017/3/2 | ||
5 | + * 示例: | ||
6 | + * let chosePanel = require('chose-panel-new'); | ||
7 | + * chosePanel.show({ | ||
8 | + * data: {}, | ||
9 | + * buttonText: '加入购物车' | ||
10 | + * }).then((sku) => { | ||
11 | + * //点击确认按钮回调,返回sku对象,各自业务在此处实现,该组件不做选择后的处理 | ||
12 | + * //... | ||
13 | + * }, () => { | ||
14 | + * //关闭选择框回调 | ||
15 | + * }); | ||
16 | + * choselPanel.close(); //关闭选择框 | ||
17 | + */ | ||
18 | +let $ = require('yoho-jquery'), | ||
19 | + innerScroll = require('../plugin/inner-scroll'); | ||
20 | + | ||
21 | +let panelT = require('common/chose-panel.hbs'); | ||
22 | + | ||
23 | +let $yohoPage = $('.yoho-page'), | ||
24 | + $chosePanel = $('.chose-panel'), | ||
25 | + $choseArea; | ||
26 | + | ||
27 | +let chosePanelObj = { | ||
28 | + setting: { | ||
29 | + buttonText: '确认' | ||
30 | + }, | ||
31 | + show(opt) { | ||
32 | + let self = this; | ||
33 | + | ||
34 | + if (opt) { | ||
35 | + self.data = opt.data; | ||
36 | + self.setting.buttonText = opt.buttonText || self.getButtonText(); | ||
37 | + } | ||
38 | + | ||
39 | + if (!self.data) { | ||
40 | + throw new Error('未赋值'); | ||
41 | + } | ||
42 | + if (!opt) { | ||
43 | + $('.chose-panel').show(); | ||
44 | + return; | ||
45 | + } | ||
46 | + self.render(); | ||
47 | + return new Promise((resolve, reject) => { | ||
48 | + self._resolve = resolve; | ||
49 | + self._reject = reject; | ||
50 | + }); | ||
51 | + }, | ||
52 | + render() { | ||
53 | + let self = this, | ||
54 | + html; | ||
55 | + | ||
56 | + html = panelT(Object.assign(self.data, { | ||
57 | + buttonText: self.setting.buttonText | ||
58 | + })); | ||
59 | + if ($chosePanel.length) { | ||
60 | + $chosePanel.replaceWith(html); | ||
61 | + } else { | ||
62 | + $yohoPage.append(html); | ||
63 | + } | ||
64 | + | ||
65 | + self._setVariable(); | ||
66 | + self._initStatus(); | ||
67 | + self._regEvents(); | ||
68 | + }, | ||
69 | + disableNumEdit() { | ||
70 | + $('.btn-minus,.btn-plus').addClass('disabled'); | ||
71 | + }, | ||
72 | + close() { | ||
73 | + let self = this; | ||
74 | + | ||
75 | + $('.chose-panel').hide(); | ||
76 | + self._reject(); | ||
77 | + }, | ||
78 | + getButtonText() { | ||
79 | + let self = this; | ||
80 | + | ||
81 | + if (self.data.tickets) { | ||
82 | + return '立即购买'; | ||
83 | + } | ||
84 | + | ||
85 | + }, | ||
86 | + _initStatus() { | ||
87 | + let self = this, | ||
88 | + noStorageSkus = self.skus.filter(sku => sku.storage === 0); | ||
89 | + | ||
90 | + $('.block').removeClass('zero-stock'); | ||
91 | + noStorageSkus.forEach(sku => { | ||
92 | + for (let propType in sku.prop) { | ||
93 | + if (propType) { | ||
94 | + let prop = sku.prop[propType]; | ||
95 | + let zeroStock = !self.skus.some(_ => _.prop[propType].valId === prop.valId && _.storage > 0); //TODO 量贩 | ||
96 | + let $block = $(`.block[data-prop-id="${propType}"][data-value-id="${prop.valId}"]`); | ||
97 | + | ||
98 | + if (zeroStock) { | ||
99 | + $block.addClass('zero-stock'); | ||
100 | + } else { | ||
101 | + $block.removeClass('zero-stock'); | ||
102 | + } | ||
103 | + } | ||
104 | + } | ||
105 | + }); | ||
106 | + }, | ||
107 | + _setVariable() { | ||
108 | + let self = this; | ||
109 | + | ||
110 | + $chosePanel = $('.chose-panel'); | ||
111 | + $choseArea = $('.chose-panel .main .chose-items'); | ||
112 | + self.skus = self.data && self.data.cartInfo && self.data.cartInfo.skus || []; | ||
113 | + self.props = self.data && self.data.cartInfo && self.data.cartInfo.props || []; | ||
114 | + }, | ||
115 | + _regEvents() { | ||
116 | + let self = this; | ||
117 | + | ||
118 | + innerScroll.disableScroll($choseArea); | ||
119 | + $yohoPage.off('touchstart', '.chose-panel').on('touchstart', '.chose-panel', (e) => { | ||
120 | + return self._closeClick(e); | ||
121 | + }); | ||
122 | + $yohoPage.off('touchstart', '.block').on('touchstart', '.block', (e) => { | ||
123 | + return self._blockClick(e); | ||
124 | + }); | ||
125 | + }, | ||
126 | + _closeClick(e) { | ||
127 | + let self = this; | ||
128 | + let $cur = $(e.target); | ||
129 | + | ||
130 | + if ($cur.closest('.main').length > 0 && !$cur.hasClass('close')) { | ||
131 | + return; | ||
132 | + } | ||
133 | + self.close(); | ||
134 | + return false; | ||
135 | + }, | ||
136 | + _blockClick(e) { | ||
137 | + let self = this; | ||
138 | + let $block = $(e.currentTarget); | ||
139 | + | ||
140 | + if ($block.hasClass('chosed')) { | ||
141 | + $block.removeClass('chosed'); | ||
142 | + } else { | ||
143 | + $block.addClass('chosed').siblings().removeClass('chosed'); | ||
144 | + } | ||
145 | + self._selectBlock($block); | ||
146 | + }, | ||
147 | + _selectBlock($selectBlock) { | ||
148 | + let self = this; | ||
149 | + let propId = $selectBlock.data('prop-id'), | ||
150 | + valueId = $selectBlock.data('value-id'); | ||
151 | + let chosed = $($selectBlock).hasClass('chosed'); | ||
152 | + | ||
153 | + if ($('.block.chosed').length === 0) { | ||
154 | + self._initStatus(); | ||
155 | + } else { | ||
156 | + let filterSkus = self.skus.filter(sku => (!chosed || sku.prop[propId].valId === valueId) && sku.storage > 0); // TODO 量贩 | ||
157 | + let filterProps = self.props.filter(prop => prop.type !== propId); | ||
158 | + | ||
159 | + filterProps.forEach(prop => { | ||
160 | + $(`.block[data-prop-id="${prop.type}"]`).each((i, ele) => { | ||
161 | + let $block = $(ele); | ||
162 | + let valId = $block.data('value-id'); | ||
163 | + let existsSku = filterSkus.some(sku => sku.prop[prop.type].valId === valId); | ||
164 | + | ||
165 | + if (!existsSku) { | ||
166 | + $block.addClass('zero-stock'); | ||
167 | + } else { | ||
168 | + $block.removeClass('zero-stock'); | ||
169 | + } | ||
170 | + }); | ||
171 | + }); | ||
172 | + } | ||
173 | + | ||
174 | + self._initBlockStatus(); | ||
175 | + }, | ||
176 | + _initBlockStatus() { | ||
177 | + let self = this, | ||
178 | + selectSku = self._getSelectSku(); | ||
179 | + | ||
180 | + // 设置底部按钮文字 | ||
181 | + if ($('.block.chosed.zero-stock').length) { | ||
182 | + $('#chose-btn-sure').css('background-color', '#c0c0c0').text('已售罄'); | ||
183 | + } else { | ||
184 | + $('#chose-btn-sure').css('background-color', '#eb0313').text(self.setting.buttonText); | ||
185 | + } | ||
186 | + | ||
187 | + // 根据颜色属性设置缩略图 | ||
188 | + let $colorBlock = $('.block.chosed[data-prop-id="color"]'); | ||
189 | + | ||
190 | + if ($colorBlock.length) { | ||
191 | + let colorSkus = self.skus.filter(sku => sku.prop.color && | ||
192 | + sku.prop.color.valId === $colorBlock.data('value-id')); | ||
193 | + | ||
194 | + if (colorSkus.length) { | ||
195 | + let thumb = colorSkus[0].thumb; | ||
196 | + | ||
197 | + if (!thumb) { | ||
198 | + thumb = self.data.cartInfo.defaultThumb; | ||
199 | + } | ||
200 | + $chosePanel.find('.thumb').attr('src', thumb); | ||
201 | + } | ||
202 | + } | ||
203 | + | ||
204 | + // 设置选择属性提示 | ||
205 | + let valueList = Array.from($('.block.chosed').map((index, ele) => { | ||
206 | + return $(ele).text(); | ||
207 | + })); | ||
208 | + | ||
209 | + if (valueList.length) { | ||
210 | + $('.not-choose').addClass('hide'); | ||
211 | + $('.choosed-info').removeClass('hide'); | ||
212 | + $('.choosed-info').text(`已选:${valueList.join('、')}`); | ||
213 | + } else { | ||
214 | + $('.not-choose').removeClass('hide'); | ||
215 | + $('.choosed-info').addClass('hide'); | ||
216 | + } | ||
217 | + | ||
218 | + if (selectSku) { | ||
219 | + // 设置left-num文字 | ||
220 | + let cartInfo = self.data.cartInfo, | ||
221 | + numText; | ||
222 | + | ||
223 | + if (cartInfo.limit) { | ||
224 | + numText = `限购${cartInfo.limit}件`; | ||
225 | + } else if (selectSku.storage < 4) { // TODO 即将售罄 移到业务调用设置 | ||
226 | + numText = `剩余${selectSku.storage}件`; | ||
227 | + } else { | ||
228 | + numText = ''; | ||
229 | + } | ||
230 | + $chosePanel.find('.left-num').text(numText); | ||
231 | + } | ||
232 | + }, | ||
233 | + _getSelectSku() { | ||
234 | + let self = this, | ||
235 | + selectValues, | ||
236 | + selectSku; | ||
237 | + | ||
238 | + if ($('.block.chosed').length !== self.props.length) { | ||
239 | + return; | ||
240 | + } | ||
241 | + selectValues = Array.from($('.block.chosed').map((index, ele) => { | ||
242 | + let $block = $(ele); | ||
243 | + | ||
244 | + return { | ||
245 | + propId: $block.data('prop-id'), | ||
246 | + valueId: $block.data('value-id') | ||
247 | + }; | ||
248 | + })); | ||
249 | + selectSku = self.skus.find(sku => { | ||
250 | + return selectValues | ||
251 | + .map(value => { | ||
252 | + return sku.prop[value.propId].valId === value.valueId; | ||
253 | + }) | ||
254 | + .filter(match => match).length === self.props.length; | ||
255 | + }); | ||
256 | + return selectSku; | ||
257 | + } | ||
258 | +}; | ||
259 | + | ||
260 | +module.exports = chosePanelObj; |
@@ -42,7 +42,17 @@ function innerScroll(e) { | @@ -42,7 +42,17 @@ function innerScroll(e) { | ||
42 | } | 42 | } |
43 | } | 43 | } |
44 | 44 | ||
45 | +function enableScroll($choseArea) { | ||
46 | + | ||
47 | + $choseArea.off('touchstart'); | ||
48 | + $choseArea.off('touchmove'); | ||
49 | + $choseArea.off('mousewheel'); | ||
50 | + | ||
51 | + $(document).off('mousewheel', preventDefault); | ||
52 | + $(document).off('touchmove', preventDefault); | ||
53 | +} | ||
45 | function disableScroll($choseArea) { | 54 | function disableScroll($choseArea) { |
55 | + enableScroll($choseArea); | ||
46 | var startX, startY; | 56 | var startX, startY; |
47 | 57 | ||
48 | // 内部可滚 | 58 | // 内部可滚 |
@@ -89,15 +99,6 @@ function disableScroll($choseArea) { | @@ -89,15 +99,6 @@ function disableScroll($choseArea) { | ||
89 | $(document).on('touchmove', preventDefault); | 99 | $(document).on('touchmove', preventDefault); |
90 | } | 100 | } |
91 | 101 | ||
92 | -function enableScroll($choseArea) { | ||
93 | - | ||
94 | - $choseArea.off('touchstart'); | ||
95 | - $choseArea.off('touchmove'); | ||
96 | - $choseArea.off('mousewheel'); | ||
97 | - | ||
98 | - $(document).off('mousewheel', preventDefault); | ||
99 | - $(document).off('touchmove', preventDefault); | ||
100 | -} | ||
101 | 102 | ||
102 | exports.enableScroll = enableScroll; | 103 | exports.enableScroll = enableScroll; |
103 | exports.disableScroll = disableScroll; | 104 | exports.disableScroll = disableScroll; |
@@ -6,14 +6,10 @@ | @@ -6,14 +6,10 @@ | ||
6 | 6 | ||
7 | 7 | ||
8 | var $ = require('yoho-jquery'), | 8 | var $ = require('yoho-jquery'), |
9 | - tip = require('plugin/tip'), | ||
10 | - chosePanel = require('cart/chose-panel'); | 9 | + tip = require('plugin/tip'); |
11 | 10 | ||
12 | var productId = $('#productId').val(); | 11 | var productId = $('#productId').val(); |
13 | 12 | ||
14 | -var skn = $('#productSkn').val(), | ||
15 | - productCode = $('#limitProductCode').val(); | ||
16 | - | ||
17 | var C_ID = window._ChannelVary[window.cookie('_Channel')], | 13 | var C_ID = window._ChannelVary[window.cookie('_Channel')], |
18 | PRD_ID; | 14 | PRD_ID; |
19 | 15 | ||
@@ -93,18 +89,4 @@ $('#likeBtn').on('touchstart', function() { | @@ -93,18 +89,4 @@ $('#likeBtn').on('touchstart', function() { | ||
93 | return false; | 89 | return false; |
94 | }); | 90 | }); |
95 | 91 | ||
96 | -$('#addtoCart').on('touchstart', function() { | ||
97 | - $('.cart-bar').hide(); | ||
98 | - productCode && chosePanel.setLimitGoodModeWithSknId(productCode, skn); | ||
99 | - chosePanel.show(); | ||
100 | 92 | ||
101 | - // 统计代码:用于统计用户加入购物车的动作 | ||
102 | - if (window._yas && window._yas.sendCustomInfo) { | ||
103 | - window._yas.sendCustomInfo({ | ||
104 | - pd: productId, | ||
105 | - by: 1 | ||
106 | - }, true); | ||
107 | - } | ||
108 | - | ||
109 | - return false; | ||
110 | -}); |
1 | require('product/detail/detail.page.css'); | 1 | require('product/detail/detail.page.css'); |
2 | -var $ = require('yoho-jquery'); | ||
3 | -var productId = $('#productId').val(); | ||
4 | -var goodsId = $('#goodsId').val(); | ||
5 | -var productSkn = $('#productSkn').val(); | ||
6 | -var brandId = $('#brand-id').val(); | ||
7 | -var bundleType = $('#bundleType').val(); | 2 | +let $ = require('yoho-jquery'); |
3 | +let productId = $('#productId').val(); | ||
4 | +let goodsId = $('#goodsId').val(); | ||
5 | +let productSkn = $('#productSkn').val(); | ||
6 | +let brandId = $('#brand-id').val(); | ||
7 | +let bundleType = $('#bundleType').val(); | ||
8 | 8 | ||
9 | require('../common'); | 9 | require('../common'); |
10 | 10 | ||
@@ -20,10 +20,10 @@ require('./detail/recommend-for-you-product-desc'); | @@ -20,10 +20,10 @@ require('./detail/recommend-for-you-product-desc'); | ||
20 | window.rePosFooter && window.rePosFooter(); | 20 | window.rePosFooter && window.rePosFooter(); |
21 | 21 | ||
22 | setTimeout(() => { | 22 | setTimeout(() => { |
23 | - var Swiper = require('yoho-swiper'); | 23 | + let Swiper = require('yoho-swiper'); |
24 | 24 | ||
25 | // 顶部swiper | 25 | // 顶部swiper |
26 | - var swiper = new Swiper('.banner-swiper', { | 26 | + let swiper = new Swiper('.banner-swiper', { |
27 | preloadImages: false, | 27 | preloadImages: false, |
28 | lazyLoading: true, | 28 | lazyLoading: true, |
29 | lazyLoadingInPrevNext: true, | 29 | lazyLoadingInPrevNext: true, |
@@ -52,7 +52,7 @@ setTimeout(() => { | @@ -52,7 +52,7 @@ setTimeout(() => { | ||
52 | return; | 52 | return; |
53 | } | 53 | } |
54 | 54 | ||
55 | - var dbClass = 'data-bind', | 55 | + let dbClass = 'data-bind', |
56 | infoDataHbs = require('product/detail/infodata.hbs'), | 56 | infoDataHbs = require('product/detail/infodata.hbs'), |
57 | priceDataHbs = require('product/detail/pricedata.hbs'); | 57 | priceDataHbs = require('product/detail/pricedata.hbs'); |
58 | 58 | ||
@@ -84,7 +84,7 @@ setTimeout(() => { | @@ -84,7 +84,7 @@ setTimeout(() => { | ||
84 | 84 | ||
85 | if (data.isDepositAdvance === 'Y') { | 85 | if (data.isDepositAdvance === 'Y') { |
86 | // 定金预售商品 | 86 | // 定金预售商品 |
87 | - var tip = require('../plugin/tip'); | 87 | + let tip = require('../plugin/tip'); |
88 | 88 | ||
89 | setTimeout(function() { | 89 | setTimeout(function() { |
90 | $('#addtoCart').text('立即购买').off('touchstart').on('touchstart', function() { | 90 | $('#addtoCart').text('立即购买').off('touchstart').on('touchstart', function() { |
@@ -108,13 +108,13 @@ setTimeout(() => { | @@ -108,13 +108,13 @@ setTimeout(() => { | ||
108 | }, | 108 | }, |
109 | success: (data) => { | 109 | success: (data) => { |
110 | // 如果当前是秒杀商品,且不在秒杀路径下,跳到该商品的秒杀详情页 | 110 | // 如果当前是秒杀商品,且不在秒杀路径下,跳到该商品的秒杀详情页 |
111 | - var reg = /\/product\/show_([\d]+)/; | ||
112 | - var regPro = /\/product\/pro_([\d]+)_([\d]+)/; | ||
113 | - var regSeckill = /\/product\/seckill/; | 111 | + let reg = /\/product\/show_([\d]+)/; |
112 | + let regPro = /\/product\/pro_([\d]+)_([\d]+)/; | ||
113 | + let regSeckill = /\/product\/seckill/; | ||
114 | 114 | ||
115 | - // var regProSeckill = /\/product\/seckill\/pro_([\d]+)_([\d]+)/; | ||
116 | - var thisHref = window.location.href; | ||
117 | - var thisRefer = document.referrer; | 115 | + // let regProSeckill = /\/product\/seckill\/pro_([\d]+)_([\d]+)/; |
116 | + let thisHref = window.location.href; | ||
117 | + let thisRefer = document.referrer; | ||
118 | 118 | ||
119 | if (!regSeckill.test(thisRefer)) { | 119 | if (!regSeckill.test(thisRefer)) { |
120 | if (data.isSecKill === 'Y' && (reg.test(thisHref) || regPro.test(thisHref))) { | 120 | if (data.isSecKill === 'Y' && (reg.test(thisHref) || regPro.test(thisHref))) { |
@@ -134,8 +134,8 @@ setTimeout(() => { | @@ -134,8 +134,8 @@ setTimeout(() => { | ||
134 | require('./detail/like'); | 134 | require('./detail/like'); |
135 | 135 | ||
136 | // 设定购物bar | 136 | // 设定购物bar |
137 | - var $cartBar = $('.cart-bar'); | ||
138 | - var timer = setInterval(function() { | 137 | + let $cartBar = $('.cart-bar'); |
138 | + let timer = setInterval(function() { | ||
139 | if ($cartBar) { | 139 | if ($cartBar) { |
140 | window.reMarginFooter('.cart-bar'); | 140 | window.reMarginFooter('.cart-bar'); |
141 | clearInterval(timer); | 141 | clearInterval(timer); |
@@ -145,10 +145,37 @@ setTimeout(() => { | @@ -145,10 +145,37 @@ setTimeout(() => { | ||
145 | }, 500); | 145 | }, 500); |
146 | 146 | ||
147 | // 限购 | 147 | // 限购 |
148 | - var dialog = require('../plugin/dialog'); | 148 | + let dialog = require('../plugin/dialog'); |
149 | + | ||
150 | + let chosePanel = require('common/chose-panel-new'); | ||
151 | + | ||
152 | + $('#addtoCart').on('touchstart', function() { | ||
153 | + let productCode = $('#limitProductCode').val(); | ||
154 | + | ||
155 | + $('.cart-bar').hide(); | ||
156 | + // productCode && chosePanel.setLimitGoodModeWithSknId(productCode, productSkn); | ||
157 | + chosePanel.show({ | ||
158 | + data: data, | ||
159 | + buttonText: '加入购物车' | ||
160 | + }).then(() => { | ||
161 | + console.log('choice') | ||
162 | + }, () => { | ||
163 | + $('.cart-bar').show(); | ||
164 | + console.log('cancel') | ||
165 | + }); | ||
166 | + | ||
167 | + // 统计代码:用于统计用户加入购物车的动作 | ||
168 | + if (window._yas && window._yas.sendCustomInfo) { | ||
169 | + window._yas.sendCustomInfo({ | ||
170 | + pd: productId, | ||
171 | + by: 1 | ||
172 | + }, true); | ||
173 | + } | ||
149 | 174 | ||
175 | + return false; | ||
176 | + }); | ||
150 | $('#limit-sale').on('touchend', function(e) { | 177 | $('#limit-sale').on('touchend', function(e) { |
151 | - var loginUrl = $('#loginUrl').val(), | 178 | + let loginUrl = $('#loginUrl').val(), |
152 | time, | 179 | time, |
153 | ifr; | 180 | ifr; |
154 | 181 | ||
@@ -163,7 +190,7 @@ setTimeout(() => { | @@ -163,7 +190,7 @@ setTimeout(() => { | ||
163 | rightBtnText: '打开Yoho!Buy有货APP' | 190 | rightBtnText: '打开Yoho!Buy有货APP' |
164 | } | 191 | } |
165 | }, function() { | 192 | }, function() { |
166 | - var appUrl = $('input[name="limitCodeUrl"]').val(); | 193 | + let appUrl = $('input[name="limitCodeUrl"]').val(); |
167 | 194 | ||
168 | ifr = document.createElement('iframe'); | 195 | ifr = document.createElement('iframe'); |
169 | ifr.src = appUrl; | 196 | ifr.src = appUrl; |
@@ -202,15 +229,15 @@ setTimeout(() => { | @@ -202,15 +229,15 @@ setTimeout(() => { | ||
202 | */ | 229 | */ |
203 | + (function(skn, productId, brandId) { // eslint-disable-line | 230 | + (function(skn, productId, brandId) { // eslint-disable-line |
204 | // 模版: 促销, feedback, 店铺 | 231 | // 模版: 促销, feedback, 店铺 |
205 | - var promotionT = require('product/detail/promotion.hbs'); | ||
206 | - var feedbackT = require('product/detail/feedbacks.hbs'); | ||
207 | - var enterStoreT = require('product/detail/enterStore.hbs'); | ||
208 | - var bundleT = require('product/detail/bundle.hbs'); | 232 | + let promotionT = require('product/detail/promotion.hbs'); |
233 | + let feedbackT = require('product/detail/feedbacks.hbs'); | ||
234 | + let enterStoreT = require('product/detail/enterStore.hbs'); | ||
235 | + let bundleT = require('product/detail/bundle.hbs'); | ||
209 | 236 | ||
210 | // placeholder | 237 | // placeholder |
211 | - var $feedbackStore = $('#placeholder-feedback-store'); | ||
212 | - var $promotion = $('#placeholder-promotion'); | ||
213 | - var $bundle = $('#placeholder-bundle'); | 238 | + let $feedbackStore = $('#placeholder-feedback-store'); |
239 | + let $promotion = $('#placeholder-promotion'); | ||
240 | + let $bundle = $('#placeholder-bundle'); | ||
214 | 241 | ||
215 | /** | 242 | /** |
216 | * 渲染 feedback, 店铺, 替换placeholder | 243 | * 渲染 feedback, 店铺, 替换placeholder |
@@ -221,11 +248,11 @@ setTimeout(() => { | @@ -221,11 +248,11 @@ setTimeout(() => { | ||
221 | * @param $placeholder | 248 | * @param $placeholder |
222 | */ | 249 | */ |
223 | function renderFeedbackStore(data, $placeholder) { | 250 | function renderFeedbackStore(data, $placeholder) { |
224 | - var feedbackHtml = feedbackT({ | 251 | + let feedbackHtml = feedbackT({ |
225 | feedbacks: data.feedbacks | 252 | feedbacks: data.feedbacks |
226 | }); | 253 | }); |
227 | 254 | ||
228 | - var enterStoreHtml = enterStoreT({ | 255 | + let enterStoreHtml = enterStoreT({ |
229 | enterStore: data.enterStore | 256 | enterStore: data.enterStore |
230 | }); | 257 | }); |
231 | 258 | ||
@@ -242,7 +269,7 @@ setTimeout(() => { | @@ -242,7 +269,7 @@ setTimeout(() => { | ||
242 | * @param $placeholder | 269 | * @param $placeholder |
243 | */ | 270 | */ |
244 | function renderPromotion(data, $placeholder) { | 271 | function renderPromotion(data, $placeholder) { |
245 | - var promotionHtml = promotionT({ | 272 | + let promotionHtml = promotionT({ |
246 | promotion: data.promotion | 273 | promotion: data.promotion |
247 | }); | 274 | }); |
248 | 275 | ||
@@ -256,7 +283,7 @@ setTimeout(() => { | @@ -256,7 +283,7 @@ setTimeout(() => { | ||
256 | * @returns {*} | 283 | * @returns {*} |
257 | */ | 284 | */ |
258 | function renderBundle(data, $placeholder) { | 285 | function renderBundle(data, $placeholder) { |
259 | - var bundleHtml = bundleT({ | 286 | + let bundleHtml = bundleT({ |
260 | bundleData: data.bundleData | 287 | bundleData: data.bundleData |
261 | }); | 288 | }); |
262 | 289 | ||
@@ -264,10 +291,10 @@ setTimeout(() => { | @@ -264,10 +291,10 @@ setTimeout(() => { | ||
264 | } | 291 | } |
265 | 292 | ||
266 | function promotionInit() { | 293 | function promotionInit() { |
267 | - var $goodsDiscount = $('#goodsDiscount'); | ||
268 | - var $discountFirstItem = $goodsDiscount.find('.first-item'); | ||
269 | - var $discountFolder = $goodsDiscount.find('.discount-folder'); | ||
270 | - var $discountArrow = $goodsDiscount.find('.first-item span'); | 294 | + let $goodsDiscount = $('#goodsDiscount'); |
295 | + let $discountFirstItem = $goodsDiscount.find('.first-item'); | ||
296 | + let $discountFolder = $goodsDiscount.find('.discount-folder'); | ||
297 | + let $discountArrow = $goodsDiscount.find('.first-item span'); | ||
271 | 298 | ||
272 | // 初始化goods-discount | 299 | // 初始化goods-discount |
273 | if ($discountFolder.children().length === 0) { | 300 | if ($discountFolder.children().length === 0) { |
@@ -332,8 +359,8 @@ setTimeout(() => { | @@ -332,8 +359,8 @@ setTimeout(() => { | ||
332 | 359 | ||
333 | $(document).scroll(function() { | 360 | $(document).scroll(function() { |
334 | if ($(document).scrollTop() >= $(document).height() - $(window).height() - 120) { | 361 | if ($(document).scrollTop() >= $(document).height() - $(window).height() - 120) { |
335 | - var top = $('.back-to-top').offset().top - $('.float-top').offset().top + ($('.back-to-top').height() - $('.float-top').height()) / 2; | ||
336 | - var left = $('.back-to-top').offset().left - $('.float-top').offset().left; | 362 | + let top = $('.back-to-top').offset().top - $('.float-top').offset().top + ($('.back-to-top').height() - $('.float-top').height()) / 2; |
363 | + let left = $('.back-to-top').offset().left - $('.float-top').offset().left; | ||
337 | 364 | ||
338 | $('.float-top').addClass('animation').css({ | 365 | $('.float-top').addClass('animation').css({ |
339 | transform: 'translate(' + left + 'px, ' + top + 'px) scale(0, 0)', | 366 | transform: 'translate(' + left + 'px, ' + top + 'px) scale(0, 0)', |
@@ -137,7 +137,6 @@ | @@ -137,7 +137,6 @@ | ||
137 | bottom: 0; | 137 | bottom: 0; |
138 | left: 0; | 138 | left: 0; |
139 | z-index: 5; | 139 | z-index: 5; |
140 | - display: none; | ||
141 | height: 100%; | 140 | height: 100%; |
142 | background: rgba(0, 0, 0, 0.3); | 141 | background: rgba(0, 0, 0, 0.3); |
143 | 142 | ||
@@ -198,6 +197,12 @@ | @@ -198,6 +197,12 @@ | ||
198 | float: none; | 197 | float: none; |
199 | } | 198 | } |
200 | 199 | ||
200 | + .choosed-info { | ||
201 | + overflow: hidden; | ||
202 | + text-overflow: ellipsis; | ||
203 | + white-space: nowrap; | ||
204 | + } | ||
205 | + | ||
201 | .name { | 206 | .name { |
202 | display: -webkit-box; | 207 | display: -webkit-box; |
203 | overflow: hidden; | 208 | overflow: hidden; |
@@ -239,8 +244,7 @@ | @@ -239,8 +244,7 @@ | ||
239 | } | 244 | } |
240 | } | 245 | } |
241 | 246 | ||
242 | - .color-list, | ||
243 | - .size-list, | 247 | + .block-list, |
244 | .num { | 248 | .num { |
245 | position: relative; | 249 | position: relative; |
246 | padding-left: 80px; | 250 | padding-left: 80px; |
@@ -290,16 +294,11 @@ | @@ -290,16 +294,11 @@ | ||
290 | } | 294 | } |
291 | } | 295 | } |
292 | 296 | ||
293 | - .color-list, | ||
294 | - .size-list { | 297 | + .block-list { |
295 | border-bottom: 1PX solid #e6e6e6; | 298 | border-bottom: 1PX solid #e6e6e6; |
296 | margin: 30px 0; | 299 | margin: 30px 0; |
297 | } | 300 | } |
298 | 301 | ||
299 | - .size-list li.hide { | ||
300 | - display: none; | ||
301 | - } | ||
302 | - | ||
303 | .block { | 302 | .block { |
304 | display: block; | 303 | display: block; |
305 | float: left; | 304 | float: left; |
@@ -353,6 +353,70 @@ exports.processFilter = (list, options) => { | @@ -353,6 +353,70 @@ exports.processFilter = (list, options) => { | ||
353 | }; | 353 | }; |
354 | 354 | ||
355 | /** | 355 | /** |
356 | + * 解析skn数据 | ||
357 | + */ | ||
358 | +exports.processSkusInfo = (origin) => { | ||
359 | + let tickets = origin.attribute === 3; | ||
360 | + let dest = { | ||
361 | + productId: origin.product_id, | ||
362 | + name: origin.product_name || '', | ||
363 | + totalNum: origin.storage_sum, | ||
364 | + skus: [], | ||
365 | + props: [{ | ||
366 | + name: tickets ? '日期' : '颜色', | ||
367 | + type: 'color', | ||
368 | + values: [] | ||
369 | + }, { | ||
370 | + name: tickets ? '区域' : '尺码', | ||
371 | + type: 'size', | ||
372 | + values: [] | ||
373 | + }] | ||
374 | + }; | ||
375 | + | ||
376 | + _.each(origin.goods_list, color => { | ||
377 | + _.each(color.size_list, size => { | ||
378 | + let colorProp = dest.props.find(prop => prop.type === 'color'), | ||
379 | + sizeProp = dest.props.find(prop => prop.type === 'size'); | ||
380 | + | ||
381 | + if (!_.some(colorProp.values, prop => prop.id === color.color_id)) { | ||
382 | + colorProp.values.push({ | ||
383 | + id: color.color_id, | ||
384 | + name: color.factory_goods_name || color.color_name | ||
385 | + }); | ||
386 | + } | ||
387 | + if (!_.some(sizeProp.values, prop => prop.id === size.size_id)) { | ||
388 | + sizeProp.values.push({ | ||
389 | + id: size.size_id, | ||
390 | + name: size.size_name | ||
391 | + }); | ||
392 | + } | ||
393 | + | ||
394 | + dest.skus.push({ | ||
395 | + skuId: size.product_sku, | ||
396 | + sizeInfo: size.size_info, | ||
397 | + storage: size.storage_number, | ||
398 | + thumb: helpers.image(color.color_image, 300, 395), | ||
399 | + prop: { | ||
400 | + color: { | ||
401 | + valId: color.color_id, | ||
402 | + valName: color.factory_goods_name || color.color_name | ||
403 | + }, | ||
404 | + size: { | ||
405 | + valId: size.size_id, | ||
406 | + valName: size.size_name | ||
407 | + } | ||
408 | + } | ||
409 | + }); | ||
410 | + }); | ||
411 | + }); | ||
412 | + | ||
413 | + dest.defaultThumb = helpers.image(_.get(dest, 'skus[0].thumb', ''), 300, 395); | ||
414 | + | ||
415 | + | ||
416 | + return dest; | ||
417 | +}; | ||
418 | + | ||
419 | +/** | ||
356 | * 解析尺码弹出框数据 | 420 | * 解析尺码弹出框数据 |
357 | */ | 421 | */ |
358 | exports.processSizeInfo = (origin) => { | 422 | exports.processSizeInfo = (origin) => { |
-
Please register or login to post a comment