Showing
9 changed files
with
431 additions
and
288 deletions
@@ -352,11 +352,20 @@ const swapGift = (req, res, next) => { | @@ -352,11 +352,20 @@ const swapGift = (req, res, next) => { | ||
352 | }).catch(next); | 352 | }).catch(next); |
353 | }; | 353 | }; |
354 | 354 | ||
355 | -const queryPromotionGift = (req, res, next) => { | 355 | +/** |
356 | + * 查询优惠可选择的商品, | ||
357 | + * 根据用户购物车数据标记是否选中 | ||
358 | + * @param req | ||
359 | + * @param res | ||
360 | + * @param next | ||
361 | + */ | ||
362 | +const queryUserPromotionGift = (req, res, next) => { | ||
356 | 363 | ||
364 | + let uid = req.user && req.user.uid; | ||
365 | + let shoppingKey = helper.getShoppingKeyByCookie(req); | ||
357 | let promotionId = req.query.promotionId; | 366 | let promotionId = req.query.promotionId; |
358 | 367 | ||
359 | - service.queryPromotionGift(promotionId) | 368 | + service.queryUserPromotionGift(promotionId, uid, shoppingKey) |
360 | .then(ret => { | 369 | .then(ret => { |
361 | res.send(ret); | 370 | res.send(ret); |
362 | }).catch(next); | 371 | }).catch(next); |
@@ -379,5 +388,5 @@ module.exports = { | @@ -379,5 +388,5 @@ module.exports = { | ||
379 | getIncreasePurchase, | 388 | getIncreasePurchase, |
380 | modifyProduct, | 389 | modifyProduct, |
381 | swapGift, | 390 | swapGift, |
382 | - queryPromotionGift | 391 | + queryUserPromotionGift |
383 | }; | 392 | }; |
@@ -74,7 +74,8 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys | @@ -74,7 +74,8 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys | ||
74 | yohoIcon: it.get_yoho_coin || 0, | 74 | yohoIcon: it.get_yoho_coin || 0, |
75 | productSubtotal: transPrice(it.last_vip_price * it.buy_number), | 75 | productSubtotal: transPrice(it.last_vip_price * it.buy_number), |
76 | promotionId: it.promotion_id || 0, | 76 | promotionId: it.promotion_id || 0, |
77 | - isLimitSkn: it.is_limit_skn === 'Y' // is_limit_skn=Y 不支持7天无理由退货 | 77 | + isLimitSkn: it.is_limit_skn === 'Y', // is_limit_skn=Y 不支持7天无理由退货 |
78 | + isAdvance: isAdvanceCart | ||
78 | }; | 79 | }; |
79 | 80 | ||
80 | 81 | ||
@@ -214,70 +215,77 @@ const formatSoldOuts = (soldOutsList, isAdvanceCart, analysis) => { | @@ -214,70 +215,77 @@ const formatSoldOuts = (soldOutsList, isAdvanceCart, analysis) => { | ||
214 | }; | 215 | }; |
215 | 216 | ||
216 | /** | 217 | /** |
217 | - * 可选加价购 | ||
218 | - * isGift 是否是赠品:true-赠品 | 218 | + * 格式化单个加价购商品 |
219 | */ | 219 | */ |
220 | -const formatPriceGifts = (giftList, isGift) => { | 220 | +const formatPriceGiftOne = (it) => { |
221 | + | ||
222 | + let gift = { | ||
223 | + // isShowGift: isGift, // 控制是否显示赠品 | ||
224 | + // isFold: true, // 控制是否[展开] | ||
225 | + promotionId: it.promotion_id, | ||
226 | + promotionTitle: it.promotion_title.replace('¥', '¥'), // + '(注:您看到的商品可能因为下单时间差已售完)', // subjoinType | ||
227 | + maxSelectNumber: it.max_select_number, | ||
228 | + promotionType: it.promotion_type, | ||
229 | + tag: PROMOTION_TYPE_TAG_MAP[it.promotion_type], | ||
230 | + isGift: 'Gift' === it.promotion_type, | ||
231 | + isPriceGift: 'Needpaygift' === it.promotion_type | ||
232 | + }; | ||
221 | 233 | ||
222 | - return _.map(giftList, (it) => { | 234 | + gift.goodsList = _.map(it.goods_list, (g) => { |
223 | 235 | ||
224 | - let gift = { | ||
225 | - isShowGift: isGift, // 控制是否显示赠品 | ||
226 | - isFold: true, // 控制是否[展开] | ||
227 | - promotionId: it.promotion_id, | ||
228 | - promotionTitle: it.promotion_title.replace('¥', '¥') + '(注:您看到的以下商品可能因为下单时间差已售完)', // subjoinType | ||
229 | - maxSelectNumber: it.max_select_number, | ||
230 | - promotionType: it.promotion_type | 236 | + let goods = { |
237 | + id: g.product_id, | ||
238 | + skn: g.product_skn, | ||
239 | + subjoinTitle: g.product_name, | ||
240 | + imgCover: it.goods_images ? helpers.image(it.goods_images, 60, 60) : '', | ||
241 | + subjoinPrice: transPrice(g.last_price), | ||
242 | + marketPrice: gift.isGift ? '' : transPrice(g.market_price), | ||
243 | + yohoIcon: 0, | ||
244 | + isGift: gift.isGift, | ||
245 | + isPriceGift: gift.isPriceGift | ||
231 | }; | 246 | }; |
232 | 247 | ||
233 | - gift.goodsList = _.map(it.goods_list, (g) => { | 248 | + // 商品链接 |
249 | + if (g.goods_id) { | ||
250 | + let cnAlphaBet = g.cn_alphabet ? g.cn_alphabet : md5(g.product_name); | ||
234 | 251 | ||
235 | - let goods = { | ||
236 | - id: g.product_id, | ||
237 | - skn: g.product_skn, | ||
238 | - subjoinTitle: g.product_name, | ||
239 | - imgCover: it.goods_images ? helpers.image(it.goods_images, 60, 60) : '', | ||
240 | - subjoinPrice: transPrice(g.last_price), | ||
241 | - marketPrice: isGift ? '' : transPrice(g.market_price), | ||
242 | - yohoIcon: 0 | ||
243 | - }; | 252 | + goods.subjoinLink = helpers.urlFormat(`/product/pro_${g.product_id}_${g.goods_id}/${cnAlphaBet}.html`, |
253 | + null, 'item'); | ||
254 | + } else { | ||
255 | + let uri = `/product/show_${g.product_id}_${g.product_skn}/${makeToken(g.product_skn)}.html`; | ||
244 | 256 | ||
245 | - // 商品链接 | ||
246 | - if (g.goods_id) { | ||
247 | - let cnAlphaBet = g.cn_alphabet ? g.cn_alphabet : md5(g.product_name); | 257 | + goods.subjoinLink = helpers.urlFormat(uri, null, 'item'); |
258 | + } | ||
248 | 259 | ||
249 | - goods.subjoinLink = helpers.urlFormat(`/product/pro_${g.product_id}_${g.goods_id}/${cnAlphaBet}.html`, | ||
250 | - null, 'item'); | ||
251 | - } else { | ||
252 | - let uri = `/product/show_${g.product_id}_${g.product_skn}/${makeToken(g.product_skn)}.html`; | 260 | + return goods; |
261 | + }); | ||
253 | 262 | ||
254 | - goods.subjoinLink = helpers.urlFormat(uri, null, 'item'); | ||
255 | - } | 263 | + return gift; |
264 | +}; | ||
256 | 265 | ||
257 | - // 赠品 | ||
258 | - if (isGift) { | ||
259 | - goods.isGift = true; | ||
260 | - } else { // 加价购 | ||
261 | - goods.isPriceGift = true; | ||
262 | - } | 266 | +/** |
267 | + * 可选加价购 | ||
268 | + * isGift 是否是赠品:true-赠品 | ||
269 | + */ | ||
270 | +const formatPriceGifts = (giftList) => { | ||
263 | 271 | ||
264 | - return goods; | ||
265 | - }); | 272 | + return _.map(giftList, (it) => { |
273 | + return formatPriceGiftOne(it); | ||
266 | }); | 274 | }); |
267 | }; | 275 | }; |
268 | 276 | ||
269 | /** | 277 | /** |
270 | * 购物车赠品 | 278 | * 购物车赠品 |
271 | */ | 279 | */ |
272 | -const formatGifts = (giftList) => { | ||
273 | - return formatPriceGifts(giftList, true); | ||
274 | -}; | 280 | +/*const formatGifts = (giftList) => { |
281 | + return formatPriceGifts(giftList); | ||
282 | +};*/ | ||
275 | 283 | ||
276 | -const checkGoodsIsSel = (goodsList, promotionId, giftsList, pricesGifts) => { | 284 | +const checkGoodsIsSel = (goodsList, promotionId, selectedGiftsList) => { |
277 | 285 | ||
278 | return _.map(goodsList, goods => { | 286 | return _.map(goodsList, goods => { |
279 | 287 | ||
280 | - _.forEach((giftsList || []).concat(pricesGifts), gift => { | 288 | + _.forEach((selectedGiftsList || []), gift => { |
281 | 289 | ||
282 | if (goods.id === gift.id && promotionId === gift.promotionId) { | 290 | if (goods.id === gift.id && promotionId === gift.promotionId) { |
283 | goods.isCheckedGift = true; | 291 | goods.isCheckedGift = true; |
@@ -292,69 +300,76 @@ const checkGoodsIsSel = (goodsList, promotionId, giftsList, pricesGifts) => { | @@ -292,69 +300,76 @@ const checkGoodsIsSel = (goodsList, promotionId, giftsList, pricesGifts) => { | ||
292 | }; | 300 | }; |
293 | 301 | ||
294 | /** | 302 | /** |
295 | - * 优惠池头部优惠信息列表 | 303 | + * 格式化promotion 里的数据 |
296 | */ | 304 | */ |
297 | -const formatPoolPromotionInfos = (infoList, giftsList, priceGifts) => { | 305 | +const formatPromotion = (it, selectedGiftsList) => { |
306 | + | ||
307 | + let status = Number(it.status); | ||
308 | + let info = { | ||
309 | + status: status, | ||
310 | + | ||
311 | + // "status": 0, // 状态 0 未满足 10 已满足 [20 售光 30 更换 ] | ||
312 | + conditionUnit: it.condition_unit, // 0满足,1 件,2金额 | ||
313 | + conditionValue: it.condition_value, | ||
314 | + giftPrice: it.gift_price, // 赠品或加价购商品价格 | ||
315 | + giftGoodsList: formatCartGoods(it.gift_goods_List), // 可供选择的赠品或加价购商品列表 | ||
316 | + promotionId: it.promotion_id, // 促销id | ||
317 | + promotionTitle: it.promotion_title, // "已满足[满30减10-dev30]", | ||
318 | + promotionType: it.promotion_type, // 促销类型 | ||
319 | + // list.yohobuy.com?pp_id=10408 | ||
320 | + promotionPageUrl: helpers.urlFormat('', { pp_id: it.promotion_id }, 'list'), | ||
321 | + tag: PROMOTION_TYPE_TAG_MAP[it.promotion_type], | ||
322 | + | ||
323 | + isGift: it.promotion_type === 'Gift', | ||
324 | + isPriceGift: it.promotion_type === 'Needpaygift', | ||
325 | + isNotReach: status === 0, // 未满足 | ||
326 | + isReach: status === 10, // 满足条件 | ||
327 | + isEmpty: status === 20, // 已售完 | ||
328 | + isSelected: status === 30 // 已选择,可更换 | ||
329 | + }; | ||
298 | 330 | ||
299 | - return _.map(infoList, it => { | 331 | + // 判断赠品/加价购商品,是否被选中 |
332 | + info.giftGoodsList = checkGoodsIsSel(info.giftGoodsList, info.promotionId, selectedGiftsList); | ||
300 | 333 | ||
301 | - let status = Number(it.status); | ||
302 | - let info = { | ||
303 | - status: status, | ||
304 | - | ||
305 | - // "status": 0, // 状态 0 未满足 10 已满足 [20 售光 30 更换 ] | ||
306 | - conditionUnit: it.condition_unit, // 0满足,1 件,2金额 | ||
307 | - conditionValue: it.condition_value, | ||
308 | - giftPrice: it.gift_price, // 赠品或加价购商品价格 | ||
309 | - giftGoodsList: formatCartGoods(it.gift_goods_List), // 可供选择的赠品或加价购商品列表 | ||
310 | - promotionId: it.promotion_id, // 促销id | ||
311 | - promotionTitle: it.promotion_title, // "已满足[满30减10-dev30]", | ||
312 | - promotionType: it.promotion_type, // 促销类型 | ||
313 | - // list.yohobuy.com?pp_id=10408 | ||
314 | - promotionPageUrl: helpers.urlFormat('', { pp_id: it.promotion_id }, 'list'), | ||
315 | - tag: PROMOTION_TYPE_TAG_MAP[it.promotion_type], | ||
316 | - | ||
317 | - isGift: it.promotion_type === 'Gift', | ||
318 | - isPriceGift: it.promotion_type === 'Needpaygift', | ||
319 | - isNotReach: status === 0, // 未满足 | ||
320 | - isReach: status === 10, // 满足条件 | ||
321 | - isEmpty: status === 20, // 已售完 | ||
322 | - isSelected: status === 30 // 已选择,可更换 | ||
323 | - }; | 334 | + if (status === 0) { |
335 | + let tipTxt = `差${ -1 * info.conditionValue}`; | ||
324 | 336 | ||
325 | - // 判断赠品/加价购商品,是否被选中 | ||
326 | - info.giftGoodsList = checkGoodsIsSel(info.giftGoodsList, info.promotionId, giftsList, priceGifts); | 337 | + if (info.conditionUnit === 1) { |
338 | + tipTxt += '件'; | ||
339 | + } else if (info.conditionUnit === 2) { | ||
340 | + tipTxt += '元'; | ||
341 | + } | ||
327 | 342 | ||
328 | - if (status === 0) { | ||
329 | - let tipTxt = `差${ -1 * info.conditionValue}`; | 343 | + info.promotionTitle = tipTxt + info.promotionTitle; |
344 | + } else if (status === 10) { | ||
345 | + info.promotionTitle = '已满足' + info.promotionTitle; | ||
346 | + } | ||
330 | 347 | ||
331 | - if (info.conditionUnit === 1) { | ||
332 | - tipTxt += '件'; | ||
333 | - } else if (info.conditionUnit === 2) { | ||
334 | - tipTxt += '元'; | ||
335 | - } | 348 | + if (info.giftGoodsList) { |
349 | + info.giftGoodsListStr = JSON.stringify(info.giftGoodsList); | ||
350 | + } | ||
351 | + return info; | ||
352 | +}; | ||
336 | 353 | ||
337 | - info.promotionTitle = tipTxt + info.promotionTitle; | ||
338 | - } else if (status === 10) { | ||
339 | - info.promotionTitle = '已满足' + info.promotionTitle; | ||
340 | - } | 354 | +/** |
355 | + * 优惠池头部优惠信息列表 | ||
356 | + */ | ||
357 | +const formatPoolPromotionInfos = (infoList, selectedGiftsList) => { | ||
341 | 358 | ||
342 | - if (info.giftGoodsList) { | ||
343 | - info.giftGoodsListStr = JSON.stringify(info.giftGoodsList); | ||
344 | - } | ||
345 | - return info; | 359 | + return _.map(infoList, it => { |
360 | + return formatPromotion(it, selectedGiftsList); | ||
346 | }); | 361 | }); |
347 | }; | 362 | }; |
348 | 363 | ||
349 | /** | 364 | /** |
350 | * 格式化子优惠池信息,返回商品列表,子优惠列表放在每个商品中 | 365 | * 格式化子优惠池信息,返回商品列表,子优惠列表放在每个商品中 |
351 | */ | 366 | */ |
352 | -const formatSubPromotionPools = (pools, gifts, priceGifts) => { | 367 | +const formatSubPromotionPools = (pools, selectedGiftsList) => { |
353 | 368 | ||
354 | let goodsListPool = _.map(pools, p => { | 369 | let goodsListPool = _.map(pools, p => { |
355 | let pool = { | 370 | let pool = { |
356 | goodsList: formatCartGoods(p.goods_list), | 371 | goodsList: formatCartGoods(p.goods_list), |
357 | - promotionInfos: formatPoolPromotionInfos(p.promotion_list, gifts, priceGifts) | 372 | + promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList) |
358 | }; | 373 | }; |
359 | 374 | ||
360 | let goodsList = pool.goodsList; | 375 | let goodsList = pool.goodsList; |
@@ -377,18 +392,18 @@ const formatSubPromotionPools = (pools, gifts, priceGifts) => { | @@ -377,18 +392,18 @@ const formatSubPromotionPools = (pools, gifts, priceGifts) => { | ||
377 | * giftsList, priceGifts 已选择的赠品和加价购,判断可选的赠品和加价购是否被选中 | 392 | * giftsList, priceGifts 已选择的赠品和加价购,判断可选的赠品和加价购是否被选中 |
378 | * 优惠池 | 393 | * 优惠池 |
379 | */ | 394 | */ |
380 | -const formatPromotionPools = (pools, giftsList, priceGifts) => { | 395 | +const formatPromotionPools = (pools, selectedGiftsList) => { |
381 | return _.map(pools, p => { | 396 | return _.map(pools, p => { |
382 | 397 | ||
383 | let pool = { | 398 | let pool = { |
384 | poolTitle: p.pool_title, | 399 | poolTitle: p.pool_title, |
385 | poolType: p.pool_type, | 400 | poolType: p.pool_type, |
386 | goodsList: formatCartGoods(p.goods_list), | 401 | goodsList: formatCartGoods(p.goods_list), |
387 | - promotionInfos: formatPoolPromotionInfos(p.promotion_list, giftsList, priceGifts) | 402 | + promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList) |
388 | }; | 403 | }; |
389 | 404 | ||
390 | if (p.sub_pool) { | 405 | if (p.sub_pool) { |
391 | - let goodsWithPromotion = formatSubPromotionPools(p.sub_pool, giftsList, priceGifts); | 406 | + let goodsWithPromotion = formatSubPromotionPools(p.sub_pool, selectedGiftsList); |
392 | 407 | ||
393 | if (_.isArray(goodsWithPromotion) && goodsWithPromotion.length) { | 408 | if (_.isArray(goodsWithPromotion) && goodsWithPromotion.length) { |
394 | pool.goodsList = goodsWithPromotion.concat(pool.goodsList); | 409 | pool.goodsList = goodsWithPromotion.concat(pool.goodsList); |
@@ -403,9 +418,11 @@ module.exports = { | @@ -403,9 +418,11 @@ module.exports = { | ||
403 | transPrice, | 418 | transPrice, |
404 | getShoppingKeyByCookie, | 419 | getShoppingKeyByCookie, |
405 | formatCartGoods, | 420 | formatCartGoods, |
406 | - formatGifts, | 421 | + // formatGifts, |
422 | + formatPriceGiftOne, | ||
407 | formatPriceGifts, | 423 | formatPriceGifts, |
408 | formatShoppingCartData, | 424 | formatShoppingCartData, |
425 | + formatPromotion, | ||
409 | formatPromotionPools, | 426 | formatPromotionPools, |
410 | formatPromotionInfos, | 427 | formatPromotionInfos, |
411 | formatOffShelves, | 428 | formatOffShelves, |
@@ -423,19 +423,24 @@ const getCartData = (uid, shoppingKey, cartDelList) => { | @@ -423,19 +423,24 @@ const getCartData = (uid, shoppingKey, cartDelList) => { | ||
423 | stat: chelper.formatShoppingCartData(_.get(advCartData, 'shopping_cart_data')) | 423 | stat: chelper.formatShoppingCartData(_.get(advCartData, 'shopping_cart_data')) |
424 | }; | 424 | }; |
425 | 425 | ||
426 | - let giftsList = chelper.formatGifts(_.get(ordCartData, 'gift_list')); | 426 | + let giftsList = chelper.formatPriceGifts(_.get(ordCartData, 'gift_list')); |
427 | let priceGifts = chelper.formatPriceGifts(_.get(ordCartData, 'price_gift')); | 427 | let priceGifts = chelper.formatPriceGifts(_.get(ordCartData, 'price_gift')); |
428 | + let goodsList = chelper.formatCartGoods(_.get(ordCartData, 'goods_list'), false, false, false, analysisData); | ||
428 | 429 | ||
429 | result.ordinaryCart = { | 430 | result.ordinaryCart = { |
431 | + // 全场可选的赠品 | ||
430 | gifts: giftsList, // chelper.formatGifts(_.get(ordCartData, 'gift_list')), | 432 | gifts: giftsList, // chelper.formatGifts(_.get(ordCartData, 'gift_list')), |
433 | + // 全场可选的加价购商品列表 | ||
434 | + priceGifts: priceGifts, // chelper.formatPriceGifts(_.get(ordCartData, 'price_gift')), | ||
435 | + // 已选择的全场加价购和赠品 | ||
436 | + goodsList: goodsList, | ||
437 | + | ||
438 | + pools: chelper.formatPromotionPools(_.get(ordCartData, 'goods_pool_list'), goodsList), | ||
431 | 439 | ||
432 | - // 未参加活动的商品 | ||
433 | - goodsList: chelper.formatCartGoods(_.get(ordCartData, 'goods_list'), false, false, false, analysisData), | ||
434 | - pools: chelper.formatPromotionPools(_.get(ordCartData, 'goods_pool_list'), giftsList, priceGifts), | ||
435 | offShelves: chelper.formatOffShelves(_.get(ordCartData, 'off_shelves_goods_list'), false, analysisData), | 440 | offShelves: chelper.formatOffShelves(_.get(ordCartData, 'off_shelves_goods_list'), false, analysisData), |
436 | soldOuts: chelper.formatSoldOuts(_.get(ordCartData, 'sold_out_goods_list'), false, analysisData), | 441 | soldOuts: chelper.formatSoldOuts(_.get(ordCartData, 'sold_out_goods_list'), false, analysisData), |
437 | - priceGifts: priceGifts, // chelper.formatPriceGifts(_.get(ordCartData, 'price_gift')), | ||
438 | - promotionInfos: chelper.formatPromotionInfos(_.get(ordCartData, 'promotion_info'), giftsList, priceGifts), | 442 | + |
443 | + promotionInfos: chelper.formatPromotionInfos(_.get(ordCartData, 'promotion_info'), goodsList), | ||
439 | stat: chelper.formatShoppingCartData(_.get(ordCartData, 'shopping_cart_data')) | 444 | stat: chelper.formatShoppingCartData(_.get(ordCartData, 'shopping_cart_data')) |
440 | }; | 445 | }; |
441 | 446 | ||
@@ -451,6 +456,13 @@ const getCartData = (uid, shoppingKey, cartDelList) => { | @@ -451,6 +456,13 @@ const getCartData = (uid, shoppingKey, cartDelList) => { | ||
451 | result.ordinaryCart = false; | 456 | result.ordinaryCart = false; |
452 | } | 457 | } |
453 | 458 | ||
459 | + // promotionInfos, gifts, priceGifts 放一起展示 | ||
460 | + let hasGifts = result.ordinaryCart.gifts && result.ordinaryCart.gifts.length; | ||
461 | + let hasPrices = result.ordinaryCart.priceGifts && result.ordinaryCart.priceGifts.length; | ||
462 | + let hasPromo = result.ordinaryCart.promotionInfos && result.ordinaryCart.promotionInfos.length; | ||
463 | + | ||
464 | + result.ordinaryCart.hasGlobalBlock = hasGifts || hasPrices || hasPromo; | ||
465 | + | ||
454 | result.stat = { | 466 | result.stat = { |
455 | orderAmount: _.get(advStat, 'orderAmount', 0) + _.get(ordStat, 'orderAmount', 0), | 467 | orderAmount: _.get(advStat, 'orderAmount', 0) + _.get(ordStat, 'orderAmount', 0), |
456 | discountAmount: _.get(advStat, 'discountAmount', 0) + _.get(ordStat, 'discountAmount', 0), | 468 | discountAmount: _.get(advStat, 'discountAmount', 0) + _.get(ordStat, 'discountAmount', 0), |
@@ -829,8 +841,37 @@ const swapGift = (uid, shoppingKey, promotionId, newSkn, newSku) => { | @@ -829,8 +841,37 @@ const swapGift = (uid, shoppingKey, promotionId, newSkn, newSku) => { | ||
829 | return cartApi.swapGift(uid, shoppingKey, promotionId, newSkn, newSku); | 841 | return cartApi.swapGift(uid, shoppingKey, promotionId, newSkn, newSku); |
830 | }; | 842 | }; |
831 | 843 | ||
832 | -const queryPromotionGift = (promotionId) => { | ||
833 | - return cartApi.queryPromotionGift(promotionId); | 844 | +const queryUserPromotionGift = (promotionId, uid, shoppingKey) => { |
845 | + | ||
846 | + return co(function * () { | ||
847 | + let promotionGifts = yield cartApi.queryPromotionGift(promotionId); | ||
848 | + let cartDataRet = yield cartApi.cartData(uid, shoppingKey); | ||
849 | + let selectedGift = chelper.formatCartGoods(_.get(cartDataRet, 'data.ordinary_cart_data.goods_list')); | ||
850 | + | ||
851 | + if(promotionGifts && promotionGifts.code === 200) { | ||
852 | + promotionGifts.data = chelper.formatPriceGiftOne(promotionGifts.data); | ||
853 | + | ||
854 | + // 处理是否选中状态 | ||
855 | + if(selectedGift && selectedGift.length) { | ||
856 | + _.forEach(promotionGifts.data.goodsList, (it) => { | ||
857 | + | ||
858 | + var isSelected = false; | ||
859 | + | ||
860 | + _.forEach(selectedGift, sg => { | ||
861 | + if(it.skn === sg.skn) { | ||
862 | + isSelected = true; | ||
863 | + return true; | ||
864 | + } | ||
865 | + }); | ||
866 | + | ||
867 | + it.isSelected = isSelected; | ||
868 | + }); | ||
869 | + } | ||
870 | + } | ||
871 | + | ||
872 | + return promotionGifts; | ||
873 | + })(); | ||
874 | + | ||
834 | }; | 875 | }; |
835 | 876 | ||
836 | module.exports = { | 877 | module.exports = { |
@@ -846,5 +887,5 @@ module.exports = { | @@ -846,5 +887,5 @@ module.exports = { | ||
846 | getRecommendProduct, | 887 | getRecommendProduct, |
847 | modifyProduct, | 888 | modifyProduct, |
848 | swapGift, | 889 | swapGift, |
849 | - queryPromotionGift | 890 | + queryUserPromotionGift |
850 | }; | 891 | }; |
@@ -41,6 +41,6 @@ router.post('/index/fav', cart.moveToFav); | @@ -41,6 +41,6 @@ router.post('/index/fav', cart.moveToFav); | ||
41 | router.post('/index/checkFav', cart.checkFav); | 41 | router.post('/index/checkFav', cart.checkFav); |
42 | router.get('/index/getProductData', cart.getProductData); | 42 | router.get('/index/getProductData', cart.getProductData); |
43 | router.post('/index/swapGift', cart.swapGift); | 43 | router.post('/index/swapGift', cart.swapGift); |
44 | -router.get('/index/queryPromotionGift', cart.queryPromotionGift); | 44 | +router.get('/index/queryPromotionGift', cart.queryUserPromotionGift); |
45 | 45 | ||
46 | module.exports = router; | 46 | module.exports = router; |
@@ -167,12 +167,6 @@ | @@ -167,12 +167,6 @@ | ||
167 | {{/if}} | 167 | {{/if}} |
168 | {{/pools}} | 168 | {{/pools}} |
169 | 169 | ||
170 | - <!--可选的加价购商品 --> | ||
171 | - <!--priceGifts--> | ||
172 | - <!--可选择的赠品--> | ||
173 | - <!--gifts--> | ||
174 | - | ||
175 | - <!-- --> | ||
176 | {{#if offShelves}} | 170 | {{#if offShelves}} |
177 | <div class="cart-table"> | 171 | <div class="cart-table"> |
178 | <ul class="table"> | 172 | <ul class="table"> |
@@ -205,11 +199,67 @@ | @@ -205,11 +199,67 @@ | ||
205 | </div> | 199 | </div> |
206 | {{/if}} | 200 | {{/if}} |
207 | 201 | ||
208 | - {{#if promotionInfos}} | 202 | + <!--可选的加价购商品 --> |
203 | + <!--priceGifts--> | ||
204 | + <!--可选择的赠品--> | ||
205 | + <!--gifts--> | ||
206 | + | ||
207 | + {{#if hasGlobalBlock}} | ||
209 | <div class="gift-sell mt20"> | 208 | <div class="gift-sell mt20"> |
209 | + {{#gifts}} | ||
210 | + <div class="gift-sell-info" | ||
211 | + data-role="promotion-wrap" | ||
212 | + data-promotionid="{{promotionId}}"> | ||
213 | + <code class="order-pay-mark order-pay-mark-white"> | ||
214 | + {{tag}} | ||
215 | + </code>{{promotionTitle}} | ||
216 | + | ||
217 | + {{#if isGift}} | ||
218 | + <a class="order-pay-link" href="javascript:void(0);" | ||
219 | + data-role="gift-sel-btn">领赠品</a> | ||
220 | + {{/if}} | ||
221 | + | ||
222 | + {{#if isPriceGift}} | ||
223 | + <a href="javascript:void(0);" | ||
224 | + class="order-pay-link" | ||
225 | + data-role="pg-sel-btn">去换购</a> | ||
226 | + | ||
227 | + <a class="btn-clear blue order-pay-link" target="_blank" href="{{promotionPageUrl}}">去凑单 ></a> | ||
228 | + {{/if}} | ||
229 | + | ||
230 | + {{!--{{> cart-sel-gift-tpl }}--}} | ||
231 | + {{!--<textarea data-role="gifts-cansel" class="hide" data-promotionid="{{promotionId}}">{{{giftGoodsListStr}}}</textarea>--}} | ||
232 | + </div> | ||
233 | + {{/gifts}} | ||
234 | + {{#priceGifts}} | ||
235 | + <div class="gift-sell-info" | ||
236 | + data-role="promotion-wrap" | ||
237 | + data-promotionid="{{promotionId}}"> | ||
238 | + <code class="order-pay-mark"> | ||
239 | + {{tag}} | ||
240 | + </code>{{promotionTitle}} | ||
241 | + | ||
242 | + {{#if isGift}} | ||
243 | + <a class="order-pay-link" href="javascript:void(0);" | ||
244 | + data-role="gift-sel-btn">领赠品</a> | ||
245 | + {{/if}} | ||
246 | + | ||
247 | + {{#if isPriceGift}} | ||
248 | + <a href="javascript:void(0);" | ||
249 | + class="order-pay-link" | ||
250 | + data-role="pg-sel-btn">去换购</a> | ||
251 | + | ||
252 | + <a class="btn-clear blue order-pay-link" target="_blank" href="{{promotionPageUrl}}">去凑单 ></a> | ||
253 | + {{/if}} | ||
254 | + | ||
255 | + {{!--{{> cart-sel-gift-tpl }}--}} | ||
256 | + {{!--<textarea data-role="gifts-cansel" class="hide" data-promotionid="{{promotionId}}">{{{giftGoodsListStr}}}</textarea>--}} | ||
257 | + </div> | ||
258 | + {{/priceGifts}} | ||
259 | + | ||
210 | {{#promotionInfos}} | 260 | {{#promotionInfos}} |
211 | - <p class="gift-sell-info"><code>{{tag}}</code>{{promotionTitle}}<a class="btn-clear blue" | ||
212 | - data-together-id="6">去凑单 ></a> | 261 | + <p class="gift-sell-info"><code>{{tag}}</code>{{promotionTitle}} |
262 | + <a class="btn-clear blue" data-together-id="6">去凑单 ></a> | ||
213 | </p> | 263 | </p> |
214 | {{/promotionInfos}} | 264 | {{/promotionInfos}} |
215 | </div> | 265 | </div> |
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | {{#if isChecked}}checked{{/if}}></i> | 13 | {{#if isChecked}}checked{{/if}}></i> |
14 | <a class="pay-pro-icon" href="{{link}}" target="_blank"> | 14 | <a class="pay-pro-icon" href="{{link}}" target="_blank"> |
15 | <img src="{{imgCover}}"> | 15 | <img src="{{imgCover}}"> |
16 | - <span class="incentive red">预售</span> | 16 | + {{#if isAdvance}}<span class="incentive red">预售</span>{{/if}} |
17 | </a> | 17 | </a> |
18 | <p class="pay-pro-info"> | 18 | <p class="pay-pro-info"> |
19 | <a href="{{link}}" target="_blank">{{productTitle}}</a> | 19 | <a href="{{link}}" target="_blank">{{productTitle}}</a> |
1 | <div class="detail-body"> | 1 | <div class="detail-body"> |
2 | <div class="slide-img"> | 2 | <div class="slide-img"> |
3 | - <p class="sell-class-title">选赠品: | ||
4 | - <em class="slide-img-title"><span | ||
5 | - class="active">1元加价购</span> | ||
6 | - <code class="spacing">|</code> | 3 | + <p class="sell-class-title"><!--选赠品:--> |
4 | + <em class="slide-img-title"> | ||
5 | + <span class="active">{{promotionTitle}}</span> | ||
6 | + <!--<code class="spacing">|</code> | ||
7 | <span>59元加价购</span> | 7 | <span>59元加价购</span> |
8 | <code class="spacing">|</code> | 8 | <code class="spacing">|</code> |
9 | - <span>99元加价购</span> | 9 | + <span>99元加价购</span>--> |
10 | </em> | 10 | </em> |
11 | </p> | 11 | </p> |
12 | <div class="side-img-dd"> | 12 | <div class="side-img-dd"> |
13 | <ul class="img-list"> | 13 | <ul class="img-list"> |
14 | - {{#each giftGoodsList}} | ||
15 | - <li class="img-item"> | 14 | + {{#each goodsList}} |
15 | + <li class="img-item" | ||
16 | + data-id="{{id}}" | ||
17 | + data-skn="{{skn}}" | ||
18 | + data-ispricegift="{{isPriceGift}}" | ||
19 | + data-isgift="{{isGift}}"> | ||
16 | <span class="hide goods-id">{{goods_id}}</span> | 20 | <span class="hide goods-id">{{goods_id}}</span> |
17 | <div class="good"> | 21 | <div class="good"> |
18 | <a href="javascript:void(0)" target="_blank"> {{!--{{link}}--}} | 22 | <a href="javascript:void(0)" target="_blank"> {{!--{{link}}--}} |
@@ -28,159 +32,5 @@ | @@ -28,159 +32,5 @@ | ||
28 | </div> | 32 | </div> |
29 | </div> | 33 | </div> |
30 | </div> | 34 | </div> |
31 | - <div class="detail-goods"> | ||
32 | - <div class="detail-bigpic"> | ||
33 | - <div class="bigpic"> | ||
34 | - <img src=""> | ||
35 | - </div> | ||
36 | - <div class="bigpic none"> | ||
37 | - <img src=""> | ||
38 | - </div> | ||
39 | - <div class="bigpic none"> | ||
40 | - <img src=""> | ||
41 | - </div> | ||
42 | - <div class="bigpic none"> | ||
43 | - <img src=""> | ||
44 | - </div> | ||
45 | - <div class="bigpic none"> | ||
46 | - <img src=""> | ||
47 | - </div> | ||
48 | - <div class="bigpic none"> | ||
49 | - <img src=""> | ||
50 | - </div> | ||
51 | - <div class="piclist"> | ||
52 | - <span class="pre"></span> | ||
53 | - <div class="con"> | ||
54 | - <ul> | ||
55 | - <li class="active"><img src=""></li> | ||
56 | - <li><img src=""></li> | ||
57 | - <li><img src=""></li> | ||
58 | - <li><img src=""></li> | ||
59 | - <li><img src=""></li> | ||
60 | - </ul> | ||
61 | - </div> | ||
62 | - <span class="next"></span> | ||
63 | - </div> | ||
64 | - </div> | ||
65 | - <div class="detail-bigpic none"> | ||
66 | - <div class="bigpic"> | ||
67 | - <img src=""> | ||
68 | - </div> | ||
69 | - <div class="bigpic none"> | ||
70 | - <img src=""> | ||
71 | - </div> | ||
72 | - <div class="bigpic none"> | ||
73 | - <img src=""> | ||
74 | - </div> | ||
75 | - <div class="bigpic none"> | ||
76 | - <img src=""> | ||
77 | - </div> | ||
78 | - <div class="bigpic none"> | ||
79 | - <img src=""> | ||
80 | - </div> | ||
81 | - <div class="bigpic none"> | ||
82 | - <img src=""> | ||
83 | - </div> | ||
84 | - <div class="piclist"> | ||
85 | - <span class="pre"></span> | ||
86 | - <div class="con"> | ||
87 | - <ul> | ||
88 | - <li class="active"><img src=""></li> | ||
89 | - <li><img src=""></li> | ||
90 | - <li><img src=""></li> | ||
91 | - <li><img src=""></li> | ||
92 | - <li><img src=""></li> | ||
93 | - </ul> | ||
94 | - </div> | ||
95 | - <span class="next"></span> | ||
96 | - </div> | ||
97 | - </div> | ||
98 | - <div class="detail-info"> | ||
99 | - <div class="title"> | ||
100 | - <h2>哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈{{name}}</h2> | ||
101 | - </div> | ||
102 | - <div class="price"> | ||
103 | - | ||
104 | - <span class="newprice">现价:<b class="promotion-price">¥7777{{salePrice}}</b></span> | ||
105 | - <span class="activityprice">活动价:<b class="promotion-price">¥5555{{marketPrice}}</b></span> | ||
106 | - | ||
107 | - </div> | ||
108 | - <div class="order"> | ||
109 | - <dl> | ||
110 | - <dd class="colorBox">选颜色:</dd> | ||
111 | - <dt> | ||
112 | - <div class="colorBox"> | ||
113 | - <ul> | ||
114 | - <li class="color active"> | ||
115 | - <p class="{{#if focus}}atcive{{/if}}"><span></span><img src=""></p> | ||
116 | - <span>{{name}}</span> | ||
117 | - </li> | ||
118 | - <li class="color"> | ||
119 | - <p class="{{#if focus}}atcive{{/if}}"><span></span><img src=""></p> | ||
120 | - <span>{{name}}</span> | ||
121 | - </li> | ||
122 | - </ul> | ||
123 | - </div> | ||
124 | - </dt> | ||
125 | - </dl> | ||
126 | - <dl> | ||
127 | - <dd class="showSizeBox">选尺码:</dd> | ||
128 | - <dt> | ||
129 | - <div class="showSizeBox"> | ||
130 | - <span data-sku="{{sku}}" data-num="{{num}}" class="disabled">40码{{name}}</span> | ||
131 | - <span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span> | ||
132 | - <span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span> | ||
133 | - <span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span> | ||
134 | - </div> | ||
135 | - <p class="size-p">内长 25.5com</p> | ||
136 | - </dt> | ||
137 | - </dl> | ||
138 | - <dl> | ||
139 | - <dd>选件数:</dd> | ||
140 | - <dt> | ||
141 | - <div class="amount_wrapper"> | ||
142 | - <input type="text" id="num" class="num" value="1" readonly="readonly"> | ||
143 | - <a class="amount cut"><i class="iconfont"></i></a> | ||
144 | - <a class="amount add"><i class="iconfont"></i></a> | ||
145 | - </div> | ||
146 | - </dt> | ||
147 | - </dl> | ||
148 | - </div> | ||
149 | - <div class="submit"> | ||
150 | - <button class="btn-red"><i class="addCart iconfont"></i>添加到购物车</button> | ||
151 | - <button class="btn-favCount"><i class="favCount iconfont"></i>收藏商品</button> | ||
152 | - </div> | ||
153 | - </div> | ||
154 | - <div class="detail-size"> | ||
155 | - <h3>尺码信息(单位:厘米)</h3> | ||
156 | - <table> | ||
157 | - <thead> | ||
158 | - <tr> | ||
159 | - <th width="{{width}}">吊牌吃吗</th> | ||
160 | - <th width="{{width}}">吊牌吃吗 | ||
161 | - </td> | ||
162 | - <th width="{{width}}">吊牌吃吗 | ||
163 | - </td> | ||
164 | - <th width="{{width}}">吊牌吃吗 | ||
165 | - </td> | ||
166 | - <th width="{{width}}">吊牌吃吗 | ||
167 | - </td> | ||
168 | - <th width="{{width}}">吊牌吃吗 | ||
169 | - </td> | ||
170 | - </tr> | ||
171 | - </thead> | ||
172 | - <tbody> | ||
173 | - <tr> | ||
174 | - <td>6666{{.}}</td> | ||
175 | - </tr> | ||
176 | - <tr> | ||
177 | - <td>4444{{.}}</td> | ||
178 | - </tr> | ||
179 | - </tbody> | ||
180 | - </table> | ||
181 | - <div class="size-info"> | ||
182 | - ※ 以上尺寸为实物实际测量,因测量方式不同会有略微误差,相关数据仅作参考,以收到实物为准。 | ||
183 | - </div> | ||
184 | - </div> | ||
185 | - </div> | 35 | + <div class="product-detail-info"></div> |
186 | </div> | 36 | </div> |
public/hbs/cart/cart-product-info-tpl.hbs
0 → 100644
1 | +<div class="detail-goods"> | ||
2 | + <div class="detail-bigpic"> | ||
3 | + <div class="bigpic"> | ||
4 | + <img src=""> | ||
5 | + </div> | ||
6 | + <div class="bigpic none"> | ||
7 | + <img src=""> | ||
8 | + </div> | ||
9 | + <div class="bigpic none"> | ||
10 | + <img src=""> | ||
11 | + </div> | ||
12 | + <div class="bigpic none"> | ||
13 | + <img src=""> | ||
14 | + </div> | ||
15 | + <div class="bigpic none"> | ||
16 | + <img src=""> | ||
17 | + </div> | ||
18 | + <div class="bigpic none"> | ||
19 | + <img src=""> | ||
20 | + </div> | ||
21 | + <div class="piclist"> | ||
22 | + <span class="pre"></span> | ||
23 | + <div class="con"> | ||
24 | + <ul> | ||
25 | + <li class="active"><img src=""></li> | ||
26 | + <li><img src=""></li> | ||
27 | + <li><img src=""></li> | ||
28 | + <li><img src=""></li> | ||
29 | + <li><img src=""></li> | ||
30 | + </ul> | ||
31 | + </div> | ||
32 | + <span class="next"></span> | ||
33 | + </div> | ||
34 | + </div> | ||
35 | + <div class="detail-bigpic none"> | ||
36 | + <div class="bigpic"> | ||
37 | + <img src=""> | ||
38 | + </div> | ||
39 | + <div class="bigpic none"> | ||
40 | + <img src=""> | ||
41 | + </div> | ||
42 | + <div class="bigpic none"> | ||
43 | + <img src=""> | ||
44 | + </div> | ||
45 | + <div class="bigpic none"> | ||
46 | + <img src=""> | ||
47 | + </div> | ||
48 | + <div class="bigpic none"> | ||
49 | + <img src=""> | ||
50 | + </div> | ||
51 | + <div class="bigpic none"> | ||
52 | + <img src=""> | ||
53 | + </div> | ||
54 | + <div class="piclist"> | ||
55 | + <span class="pre"></span> | ||
56 | + <div class="con"> | ||
57 | + <ul> | ||
58 | + <li class="active"><img src=""></li> | ||
59 | + <li><img src=""></li> | ||
60 | + <li><img src=""></li> | ||
61 | + <li><img src=""></li> | ||
62 | + <li><img src=""></li> | ||
63 | + </ul> | ||
64 | + </div> | ||
65 | + <span class="next"></span> | ||
66 | + </div> | ||
67 | + </div> | ||
68 | + <div class="detail-info"> | ||
69 | + <div class="title"> | ||
70 | + <h2>{{name}}</h2> | ||
71 | + </div> | ||
72 | + <div class="price"> | ||
73 | + <span class="newprice">现价:<b class="promotion-price">{{salePrice}}</b></span> | ||
74 | + <span class="activityprice">活动价:<b class="promotion-price">{{marketPrice}}</b></span> | ||
75 | + </div> | ||
76 | + <div class="order"> | ||
77 | + <dl> | ||
78 | + <dd class="colorBox">选颜色:</dd> | ||
79 | + <dt> | ||
80 | + <div class="colorBox"> | ||
81 | + <ul> | ||
82 | + {{#each colors}} | ||
83 | + <li class="color active"> | ||
84 | + <p class="{{#if focus}}atcive{{/if}}"> | ||
85 | + <span></span> | ||
86 | + <img src="{{src}}"> | ||
87 | + </p> | ||
88 | + <span>{{name}}</span> | ||
89 | + </li> | ||
90 | + {{/each}} | ||
91 | + </ul> | ||
92 | + </div> | ||
93 | + </dt> | ||
94 | + </dl> | ||
95 | + <dl> | ||
96 | + <dd class="showSizeBox">选尺码:</dd> | ||
97 | + <dt> | ||
98 | + {{#each colors}} | ||
99 | + <div class="showSizeBox"> | ||
100 | + {{#each size}} | ||
101 | + <span data-sku="{{sku}}" data-num="{{num}}" class="disabled">{{name}}</span> | ||
102 | + {{/each}} | ||
103 | + </div> | ||
104 | + {{/each}} | ||
105 | + <!--<p class="size-p">内长 25.5com</p>--> | ||
106 | + </dt> | ||
107 | + </dl> | ||
108 | + <dl> | ||
109 | + <dd>选件数:</dd> | ||
110 | + <dt> | ||
111 | + <div class="amount_wrapper"> | ||
112 | + <input type="text" id="num" class="num" value="1" readonly="readonly"> | ||
113 | + <a class="amount cut"><i class="iconfont"></i></a> | ||
114 | + <a class="amount add"><i class="iconfont"></i></a> | ||
115 | + </div> | ||
116 | + </dt> | ||
117 | + </dl> | ||
118 | + </div> | ||
119 | + <div class="submit"> | ||
120 | + <button class="btn-red"><i class="addCart iconfont"></i>添加到购物车</button> | ||
121 | + <button class="btn-favCount"><i class="favCount iconfont"></i>收藏商品</button> | ||
122 | + </div> | ||
123 | + </div> | ||
124 | + <div class="detail-size"> | ||
125 | + <h3>尺码信息(单位:厘米)</h3> | ||
126 | + <table> | ||
127 | + <thead> | ||
128 | + <tr> | ||
129 | + <th width="{{width}}">吊牌吃吗</th> | ||
130 | + <th width="{{width}}">吊牌吃吗 | ||
131 | + </td> | ||
132 | + <th width="{{width}}">吊牌吃吗 | ||
133 | + </td> | ||
134 | + <th width="{{width}}">吊牌吃吗 | ||
135 | + </td> | ||
136 | + <th width="{{width}}">吊牌吃吗 | ||
137 | + </td> | ||
138 | + <th width="{{width}}">吊牌吃吗 | ||
139 | + </td> | ||
140 | + </tr> | ||
141 | + </thead> | ||
142 | + <tbody> | ||
143 | + <tr> | ||
144 | + <td>6666{{.}}</td> | ||
145 | + </tr> | ||
146 | + <tr> | ||
147 | + <td>4444{{.}}</td> | ||
148 | + </tr> | ||
149 | + </tbody> | ||
150 | + </table> | ||
151 | + <div class="size-info"> | ||
152 | + ※ 以上尺寸为实物实际测量,因测量方式不同会有略微误差,相关数据仅作参考,以收到实物为准。 | ||
153 | + </div> | ||
154 | + </div> | ||
155 | +</div> |
@@ -14,7 +14,8 @@ var $cartnewTips = $('.cartnew-tips'), | @@ -14,7 +14,8 @@ var $cartnewTips = $('.cartnew-tips'), | ||
14 | CART_ITEM_DEL_URL = '/cart/index/remove', | 14 | CART_ITEM_DEL_URL = '/cart/index/remove', |
15 | CART_ITEM_FAV_URL = '/cart/index/fav', | 15 | CART_ITEM_FAV_URL = '/cart/index/fav', |
16 | selColorWinTpl = require('hbs/cart/select-color-panel.hbs'), | 16 | selColorWinTpl = require('hbs/cart/select-color-panel.hbs'), |
17 | - giftsWinTpl = require('hbs/cart/cart-gifts-win-tpl.hbs'); | 17 | + giftsWinTpl = require('hbs/cart/cart-gifts-win-tpl.hbs'), |
18 | + productInfoTpl = require('hbs/cart/cart-product-info-tpl.hbs'); | ||
18 | 19 | ||
19 | // 关闭温馨提示 | 20 | // 关闭温馨提示 |
20 | $cartnewTips.find('.btn_close').click(function() { | 21 | $cartnewTips.find('.btn_close').click(function() { |
@@ -308,6 +309,20 @@ function getProductByPromotionId(promotionId) { | @@ -308,6 +309,20 @@ function getProductByPromotionId(promotionId) { | ||
308 | }); | 309 | }); |
309 | } | 310 | } |
310 | 311 | ||
312 | +function bindGiftWinAction($el) { | ||
313 | + | ||
314 | + $el.on('click', '.slide-img .img-list .img-item', function(){ | ||
315 | + | ||
316 | + var id = $(this).data('id'); | ||
317 | + var skn = $(this).data('skn'); | ||
318 | + | ||
319 | + getProductInfo(id, skn).then(res => { | ||
320 | + | ||
321 | + $el.find('.product-detail-info').empty().append(productInfoTpl(res)); | ||
322 | + }); | ||
323 | + }); | ||
324 | +}; | ||
325 | + | ||
311 | function renderAndShowGiftWin(plist) { | 326 | function renderAndShowGiftWin(plist) { |
312 | 327 | ||
313 | var d = new Dialog({ | 328 | var d = new Dialog({ |
@@ -316,6 +331,8 @@ function renderAndShowGiftWin(plist) { | @@ -316,6 +331,8 @@ function renderAndShowGiftWin(plist) { | ||
316 | }); | 331 | }); |
317 | 332 | ||
318 | d.show(); | 333 | d.show(); |
334 | + | ||
335 | + bindGiftWinAction(d.$el); | ||
319 | } | 336 | } |
320 | 337 | ||
321 | var Cart = { | 338 | var Cart = { |
@@ -632,25 +649,30 @@ var Cart = { | @@ -632,25 +649,30 @@ var Cart = { | ||
632 | var $this = $(this); | 649 | var $this = $(this); |
633 | var $wrap = $this.closest('[data-role="promotion-wrap"]'); | 650 | var $wrap = $this.closest('[data-role="promotion-wrap"]'); |
634 | var promotionid = $wrap.data('promotionid'); | 651 | var promotionid = $wrap.data('promotionid'); |
635 | - var productList = $wrap.data('_giftList'); | 652 | + var promotionInfo = $wrap.data('_promotionInfo'); |
636 | 653 | ||
637 | console.log($this); | 654 | console.log($this); |
638 | console.log($wrap); | 655 | console.log($wrap); |
639 | console.log(promotionid); | 656 | console.log(promotionid); |
640 | - if(!productList) { | ||
641 | - getProductByPromotionId(promotionid).done(function(plist) { | 657 | + if(!promotionInfo) { |
658 | + getProductByPromotionId(promotionid).done(function(pinfo) { | ||
659 | + | ||
642 | 660 | ||
643 | - productList = plist; | 661 | + if(!pinfo && pinfo.code !== 200) { |
662 | + return new Alert('获取商品失败,请稍后再试!').show(); | ||
663 | + } | ||
664 | + | ||
665 | + promotionInfo = pinfo.data; | ||
644 | 666 | ||
645 | - $wrap.data('_giftList', productList); | ||
646 | - renderAndShowGiftWin(productList); | 667 | + $wrap.data('_promotionInfo', promotionInfo); |
668 | + renderAndShowGiftWin(promotionInfo); | ||
647 | }).fail(function() { | 669 | }).fail(function() { |
648 | new Alert('获取商品失败,请稍后再试!').show(); | 670 | new Alert('获取商品失败,请稍后再试!').show(); |
649 | }); | 671 | }); |
650 | return; | 672 | return; |
651 | } | 673 | } |
652 | 674 | ||
653 | - renderAndShowGiftWin(productList); | 675 | + renderAndShowGiftWin(promotionInfo); |
654 | }, | 676 | }, |
655 | submit: function() { | 677 | submit: function() { |
656 | /* understock = ''; | 678 | /* understock = ''; |
@@ -711,7 +733,6 @@ $payWapper.on('click', 'li[data-role="pitem"] .button-sure', Cart.editColorOrSiz | @@ -711,7 +733,6 @@ $payWapper.on('click', 'li[data-role="pitem"] .button-sure', Cart.editColorOrSiz | ||
711 | $payWapper.find('li[data-role="pitem"]').on('click', '.goods-choose-box .choose-color .dt', Cart.selectColor); | 733 | $payWapper.find('li[data-role="pitem"]').on('click', '.goods-choose-box .choose-color .dt', Cart.selectColor); |
712 | $payWapper.find('li[data-role="pitem"]').on('click', '.goods-choose-box .choose-size .dt', Cart.selectSize); | 734 | $payWapper.find('li[data-role="pitem"]').on('click', '.goods-choose-box .choose-size .dt', Cart.selectSize); |
713 | 735 | ||
714 | - | ||
715 | /** 赠品加价购弹窗 **/ | 736 | /** 赠品加价购弹窗 **/ |
716 | // 显示赠品 | 737 | // 显示赠品 |
717 | var giftBtn = ['[data-role=gift-view-btn]', | 738 | var giftBtn = ['[data-role=gift-view-btn]', |
@@ -720,7 +741,7 @@ var giftBtn = ['[data-role=gift-view-btn]', | @@ -720,7 +741,7 @@ var giftBtn = ['[data-role=gift-view-btn]', | ||
720 | '[data-role=pg-sel-btn]', | 741 | '[data-role=pg-sel-btn]', |
721 | '[data-role=pg-resel-btn]']; | 742 | '[data-role=pg-resel-btn]']; |
722 | 743 | ||
723 | -$payWapper.on('click', giftBtn.join(','), Cart.showGiftWin); | 744 | +$payWapper./*find('li[data-role="pitem"]').*/on('click', giftBtn.join(','), Cart.showGiftWin); |
724 | /* | 745 | /* |
725 | $('.shop-cart').on('click', giftBtn.join(','), function() { | 746 | $('.shop-cart').on('click', giftBtn.join(','), function() { |
726 | 747 |
-
Please register or login to post a comment