Showing
4 changed files
with
62 additions
and
2 deletions
@@ -4,6 +4,8 @@ | @@ -4,6 +4,8 @@ | ||
4 | 'use strict'; | 4 | 'use strict'; |
5 | const _ = require('lodash'); | 5 | const _ = require('lodash'); |
6 | const commentModel = require('./consult-comment'); | 6 | const commentModel = require('./consult-comment'); |
7 | +const bundle = require('./bundle'); | ||
8 | +const productProcess = require(`${utils}/product-process`); | ||
7 | 9 | ||
8 | 10 | ||
9 | const api = global.yoho.API; | 11 | const api = global.yoho.API; |
@@ -205,6 +207,23 @@ const tool = { | @@ -205,6 +207,23 @@ const tool = { | ||
205 | }); | 207 | }); |
206 | } | 208 | } |
207 | return feedbacks; | 209 | return feedbacks; |
210 | + }, | ||
211 | + | ||
212 | + /** | ||
213 | + * 套餐数据处理 | ||
214 | + * @param bundleData | ||
215 | + * @param skn | ||
216 | + * @returns {{}} | ||
217 | + */ | ||
218 | + processBundle(bundleData, skn) { | ||
219 | + return { | ||
220 | + title: '优惠套装', | ||
221 | + href: helpers.urlFormat('/product/bundle/detail', {skn: skn}), | ||
222 | + description: '立省¥' + | ||
223 | + (parseInt(_.get(bundleData, 'bundleInfo.salesPrice', 0), 10) - | ||
224 | + parseInt(_.get(bundleData, 'bundleInfo.discountPrice', 0), 10)) + '元', | ||
225 | + productList: productProcess.processProductList(bundleData && bundleData.productList) | ||
226 | + }; | ||
208 | } | 227 | } |
209 | }; | 228 | }; |
210 | 229 | ||
@@ -253,7 +272,8 @@ const newDetail = { | @@ -253,7 +272,8 @@ const newDetail = { | ||
253 | }), // 1 评论信息 | 272 | }), // 1 评论信息 |
254 | commentModel.getCommonConsult(), // 2 默认咨询信息 | 273 | commentModel.getCommonConsult(), // 2 默认咨询信息 |
255 | commentModel.getConsults(productId, 1, 2), // 3 咨询列表 | 274 | commentModel.getConsults(productId, 1, 2), // 3 咨询列表 |
256 | - this.queryPromotion(skn) // 4 促销活动 | 275 | + this.queryPromotion(skn), // 4 促销活动 |
276 | + bundle.getBundleBySkn(skn) | ||
257 | ]).then(info => { | 277 | ]).then(info => { |
258 | let finalResult = { | 278 | let finalResult = { |
259 | promotion: null, | 279 | promotion: null, |
@@ -272,6 +292,20 @@ const newDetail = { | @@ -272,6 +292,20 @@ const newDetail = { | ||
272 | userConsult: info[3] | 292 | userConsult: info[3] |
273 | }, productId); | 293 | }, productId); |
274 | 294 | ||
295 | + let bundleData = _.get(info[5], 'data', null); | ||
296 | + | ||
297 | + /* 套装 */ | ||
298 | + if (bundleData && _.get(bundleData, 'bundleInfo.discountType', null) === 1) { | ||
299 | + finalResult.bundleData = tool.processBundle(bundleData, skn); | ||
300 | + } | ||
301 | + | ||
302 | + /* 量贩 */ | ||
303 | + if (bundleData && _.get(bundleData, 'bundleInfo.discountType', null) === 2) { | ||
304 | + finalResult.discountBuy = { | ||
305 | + num: _.get(bundleData, 'bundleInfo.bundleCount', 1), | ||
306 | + promotionPhrase: _.get(bundleData, 'bundleInfo.promotionPhrase', '') | ||
307 | + }; | ||
308 | + } | ||
275 | return finalResult; | 309 | return finalResult; |
276 | }); | 310 | }); |
277 | }, | 311 | }, |
@@ -71,6 +71,9 @@ | @@ -71,6 +71,9 @@ | ||
71 | {{!-- 占位: 用户反馈, 店铺入口 --}} | 71 | {{!-- 占位: 用户反馈, 店铺入口 --}} |
72 | <div id="placeholder-feedback-store"></div> | 72 | <div id="placeholder-feedback-store"></div> |
73 | 73 | ||
74 | + {{!-- 占位: 套装 --}} | ||
75 | + <div id="placeholder-bundle"></div> | ||
76 | + | ||
74 | <div id="productDesc" class="product-desc {{#if limit}}limit{{/if}}"></div> | 77 | <div id="productDesc" class="product-desc {{#if limit}}limit{{/if}}"></div> |
75 | {{> detail/recommend-for-you}} | 78 | {{> detail/recommend-for-you}} |
76 | 79 |
1 | +{{# bundleData}} | ||
1 | <div class="bundle"> | 2 | <div class="bundle"> |
2 | <div class="bundle-nav"> | 3 | <div class="bundle-nav"> |
3 | <div class="bundle-title">{{title}}</div> | 4 | <div class="bundle-title">{{title}}</div> |
@@ -19,4 +20,5 @@ | @@ -19,4 +20,5 @@ | ||
19 | {{/ productList}} | 20 | {{/ productList}} |
20 | </div> | 21 | </div> |
21 | </div> | 22 | </div> |
22 | -</div> | ||
23 | +</div> | ||
24 | +{{/ bundleData}} |
@@ -194,10 +194,12 @@ setTimeout(() => { | @@ -194,10 +194,12 @@ setTimeout(() => { | ||
194 | var promotionT = require('product/detail/promotion.hbs'); | 194 | var promotionT = require('product/detail/promotion.hbs'); |
195 | var feedbackT = require('product/detail/feedbacks.hbs'); | 195 | var feedbackT = require('product/detail/feedbacks.hbs'); |
196 | var enterStoreT = require('product/detail/enterStore.hbs'); | 196 | var enterStoreT = require('product/detail/enterStore.hbs'); |
197 | + var bundleT = require('product/detail/bundle.hbs'); | ||
197 | 198 | ||
198 | // placeholder | 199 | // placeholder |
199 | var $feedbackStore = $('#placeholder-feedback-store'); | 200 | var $feedbackStore = $('#placeholder-feedback-store'); |
200 | var $promotion = $('#placeholder-promotion'); | 201 | var $promotion = $('#placeholder-promotion'); |
202 | + var $bundle = $('#placeholder-bundle'); | ||
201 | 203 | ||
202 | /** | 204 | /** |
203 | * 渲染 feedback, 店铺, 替换placeholder | 205 | * 渲染 feedback, 店铺, 替换placeholder |
@@ -236,6 +238,20 @@ setTimeout(() => { | @@ -236,6 +238,20 @@ setTimeout(() => { | ||
236 | return $placeholder.replaceWith(promotionHtml); | 238 | return $placeholder.replaceWith(promotionHtml); |
237 | } | 239 | } |
238 | 240 | ||
241 | + /** | ||
242 | + * 渲染 套装,替换placeholder | ||
243 | + * @param data | ||
244 | + * @param $placeholder | ||
245 | + * @returns {*} | ||
246 | + */ | ||
247 | + function renderBundle(data, $placeholder) { | ||
248 | + var bundleHtml = bundleT({ | ||
249 | + bundleData: data.bundleData | ||
250 | + }); | ||
251 | + | ||
252 | + return $placeholder.replaceWith(bundleHtml); | ||
253 | + } | ||
254 | + | ||
239 | function promotionInit() { | 255 | function promotionInit() { |
240 | var $goodsDiscount = $('#goodsDiscount'); | 256 | var $goodsDiscount = $('#goodsDiscount'); |
241 | var $discountFirstItem = $goodsDiscount.find('.first-item'); | 257 | var $discountFirstItem = $goodsDiscount.find('.first-item'); |
@@ -275,9 +291,14 @@ setTimeout(() => { | @@ -275,9 +291,14 @@ setTimeout(() => { | ||
275 | renderFeedbackStore(info, $feedbackStore); | 291 | renderFeedbackStore(info, $feedbackStore); |
276 | renderPromotion(info, $promotion); | 292 | renderPromotion(info, $promotion); |
277 | 293 | ||
294 | + if (info.bundleData) { | ||
295 | + renderBundle(info, $bundle); | ||
296 | + } | ||
297 | + | ||
278 | // step2: init js | 298 | // step2: init js |
279 | require('./detail/comments-consults'); | 299 | require('./detail/comments-consults'); |
280 | require('./detail/consultform'); // TODO | 300 | require('./detail/consultform'); // TODO |
301 | + require('./detail/bundle'); | ||
281 | promotionInit(); | 302 | promotionInit(); |
282 | window.rePosFooter && window.rePosFooter(); | 303 | window.rePosFooter && window.rePosFooter(); |
283 | }); | 304 | }); |
-
Please register or login to post a comment