Authored by 刘传洋

m

... ... @@ -337,6 +337,31 @@ const modifyProduct = (req, res, next) => {
}).catch(next);
};
const swapGift = (req, res, next) => {
let uid = req.user && req.user.uid;
let shoppingKey = helper.getShoppingKeyByCookie(req);
let promotionId = req.body.promotionId;
let newSkn = req.body.new_skn;
let newSku = req.body.new_sku;
service.swapGift(uid, shoppingKey, promotionId, newSkn, newSku)
.then(ret => {
res.send(ret);
}).catch(next);
};
const queryPromotionGift = (req, res, next) => {
let promotionId = req.query.promotionId;
service.queryPromotionGift(promotionId)
.then(ret => {
res.send(ret);
}).catch(next);
};
module.exports = {
getProductInfo,
getProductData,
... ... @@ -352,5 +377,7 @@ module.exports = {
getTogetherProduct,
getRecommendProductAction,
getIncreasePurchase,
modifyProduct
modifyProduct,
swapGift,
queryPromotionGift
};
... ...
... ... @@ -596,6 +596,50 @@ const modifyProduct = (options) => {
return api.get('', params);
};
/**
* 更换加价购,赠品商品
* @function modifyProduct
* @param { Number } uid 用户ID
* @param { String } swapData 商品修改信息
* @param { String } shoppingKey 未登录用户唯一识别码
* @return { Object } 接口返回单个商品修改结果
*/
const swapGift = (uid, shoppingKey, promotionId, newSkn, newSku) => {
let param = {
method: 'app.Shopping.swapGift',
promotion_id: promotionId,
new_product_skn: newSkn,
new_product_sku: newSku
};
if (uid) {
param.uid = uid;
}
if (shoppingKey) {
param.shopping_key = shoppingKey;
}
return api.get('', param);
};
/**
* 查询所有可选的赠品或者加价购的商品
* @param promotionId
* @returns {*}
*/
const queryPromotionGift = (promotionId) => {
let param = {
method: 'app.Shopping.queryPromotionGift',
promotion_id: promotionId
};
return api.get('', param);
};
module.exports = {
cartData,
addToCart,
... ... @@ -619,5 +663,7 @@ module.exports = {
addTicket,
checkUserIsFavProductList,
newPreference,
modifyProduct
modifyProduct,
swapGift,
queryPromotionGift
};
... ...
... ... @@ -825,6 +825,14 @@ const modifyProduct = (param) => {
return cartApi.modifyProduct(param);
};
const swapGift = (uid, shoppingKey, promotionId, newSkn, newSku) => {
return cartApi.swapGift(uid, shoppingKey, promotionId, newSkn, newSku);
};
const queryPromotionGift = (promotionId) => {
return cartApi.queryPromotionGift(promotionId);
};
module.exports = {
getProductInfoAsync, // 获取某一个商品详情主页面
getCartData,
... ... @@ -836,5 +844,7 @@ module.exports = {
addToFav,
checkUserIsFav,
getRecommendProduct,
modifyProduct
modifyProduct,
swapGift,
queryPromotionGift
};
... ...
... ... @@ -39,5 +39,7 @@ router.post('/index/remove', cart.removeProduct);
router.post('/index/fav', cart.moveToFav);
router.post('/index/checkFav', cart.checkFav);
router.get('/index/getProductData', cart.getProductData);
router.post('/index/swapGift', cart.swapGift);
router.get('/index/queryPromotionGift', cart.queryPromotionGift);
module.exports = router;
... ...
... ... @@ -108,7 +108,9 @@
<div class="gift-sell mt40">
{{#promotionInfos}}
<div class="gift-sell-info" data-role="promotion-wrap">
<div class="gift-sell-info"
data-role="promotion-wrap"
data-promotionid="{{promotionId}}">
<code class="order-pay-mark
{{#unless isReach}}order-pay-mark-white{{/unless}}">
{{tag}}
... ... @@ -147,7 +149,7 @@
{{/if}}
{{/if}}
{{> cart-sel-gift-tpl }}
{{!--{{> cart-sel-gift-tpl }}--}}
{{!--<textarea data-role="gifts-cansel" class="hide" data-promotionid="{{promotionId}}">{{{giftGoodsListStr}}}</textarea>--}}
</div>
{{/promotionInfos}}
... ...
<div class="detail-body">
<div class="slide-img">
<p class="sell-class-title">选赠品:
<em class="slide-img-title"><span
class="active">1元加价购</span>
<code class="spacing">|</code>
<span>59元加价购</span>
<code class="spacing">|</code>
<span>99元加价购</span>
</em>
</p>
<div class="side-img-dd">
<ul class="img-list">
{{#each giftGoodsList}}
<li class="img-item">
<span class="hide goods-id">{{goods_id}}</span>
<div class="good">
<a href="javascript:void(0)" target="_blank"> {{!--{{link}}--}}
<img class="lazy" src="{{imgCover}}"/>
</a>
</div>
</li>
{{/each}}
</ul>
<div class="img-brand-switch">
<a class="prev iconfont" href="javascript:;">&#xe609;</a>
<a class="next iconfont" href="javascript:;">&#xe608;</a>
</div>
</div>
</div>
<div class="detail-goods">
<div class="detail-bigpic">
<div class="bigpic">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="piclist">
<span class="pre"></span>
<div class="con">
<ul>
<li class="active"><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
</ul>
</div>
<span class="next"></span>
</div>
</div>
<div class="detail-bigpic none">
<div class="bigpic">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="piclist">
<span class="pre"></span>
<div class="con">
<ul>
<li class="active"><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
</ul>
</div>
<span class="next"></span>
</div>
</div>
<div class="detail-info">
<div class="title">
<h2>哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈{{name}}</h2>
</div>
<div class="price">
<span class="newprice">现价:<b class="promotion-price">¥7777{{salePrice}}</b></span>
<span class="activityprice">活动价:<b class="promotion-price">¥5555{{marketPrice}}</b></span>
</div>
<div class="order">
<dl>
<dd class="colorBox">选颜色:</dd>
<dt>
<div class="colorBox">
<ul>
<li class="color active">
<p class="{{#if focus}}atcive{{/if}}"><span></span><img src=""></p>
<span>{{name}}</span>
</li>
<li class="color">
<p class="{{#if focus}}atcive{{/if}}"><span></span><img src=""></p>
<span>{{name}}</span>
</li>
</ul>
</div>
</dt>
</dl>
<dl>
<dd class="showSizeBox">选尺码:</dd>
<dt>
<div class="showSizeBox">
<span data-sku="{{sku}}" data-num="{{num}}" class="disabled">40码{{name}}</span>
<span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span>
<span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span>
<span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span>
</div>
<p class="size-p">内长&nbsp;25.5com</p>
</dt>
</dl>
<dl>
<dd>选件数:</dd>
<dt>
<div class="amount_wrapper">
<input type="text" id="num" class="num" value="1" readonly="readonly">
<a class="amount cut"><i class="iconfont">&#xe6c0;</i></a>
<a class="amount add"><i class="iconfont">&#xe6c1;</i></a>
</div>
</dt>
</dl>
</div>
<div class="submit">
<button class="btn-red"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
<button class="btn-favCount"><i class="favCount iconfont">&#xe68f;</i>收藏商品</button>
</div>
</div>
<div class="detail-size">
<h3>尺码信息(单位:厘米)</h3>
<table>
<thead>
<tr>
<th width="{{width}}">吊牌吃吗</th>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
</tr>
</thead>
<tbody>
<tr>
<td>6666{{.}}</td>
</tr>
<tr>
<td>4444{{.}}</td>
</tr>
</tbody>
</table>
<div class="size-info">
※ 以上尺寸为实物实际测量,因测量方式不同会有略微误差,相关数据仅作参考,以收到实物为准。
</div>
</div>
</div>
</div>
... ...
... ... @@ -3,7 +3,7 @@
<div class="dl choose-color">
<div class="dd">颜色:</div>
{{#each colors}}
<div class="dt {{#if focus}} active current-color{{/if}} {{#if disable}} disabled{{/if}}"
<div class="dt {{#if active}} active current-color{{/if}} {{#if disable}} disabled{{/if}}"
data-pic="{{image pic 100 134}}"
data-pid="{{pid}}"
{{!--data-target="{{proId}}-color-{{@index}}"
... ... @@ -17,10 +17,10 @@
<div class="dl choose-size">
<div class="dd">尺码:</div>
{{#each colors}}
<div class="size-row {{#unless focus}} hide{{/unless}}">
<div class="size-row {{#unless active}} hide{{/unless}}">
<div class="choose-size-detail">
{{#each sizes}}
<div class="dt {{#if sizeFocus}}active{{/if}}"
<div class="dt {{#if sizeActive}}active{{/if}}"
{{#unless num}}class="disable"{{/unless}}
data-sku="{{sku}}"
data-num="{{num}}"
... ... @@ -52,7 +52,7 @@
</div>
<div class="goods-info-bigImg">
{{# colors}}
<div class="bigImg {{#unless focus}} hide{{/unless}}">
<div class="bigImg {{#unless active}} hide{{/unless}}">
{{#if pic}}
<img src="{{image pic 100 134}}" />
{{else}}
... ...
... ... @@ -3,17 +3,18 @@
*/
var $ = require('yoho-jquery');
// var Dialog = require('../common/dialog').Dialog;
var Alert = require('../common/dialog').Alert;
var Confirm = require('../common/dialog').Confirm;
var dialog = require('../common/dialog');
var Dialog = dialog.Dialog;
var Alert = dialog.Alert;
var Confirm = dialog.Confirm;
var $cartnewTips = $('.cartnew-tips'),
$payWapper = $('.pay-wapper'),
$cartnewSum = $('.cartnew-sum'),
CART_ITEM_DEL_URL = '/cart/index/remove',
CART_ITEM_FAV_URL = '/cart/index/fav',
selColorWinTpl = require('hbs/cart/select-color-panel.hbs');
selColorWinTpl = require('hbs/cart/select-color-panel.hbs'),
giftsWinTpl = require('hbs/cart/cart-gifts-win-tpl.hbs');
// 关闭温馨提示
$cartnewTips.find('.btn_close').click(function() {
... ... @@ -188,6 +189,7 @@ function addcart(data, cookieList) {
}
function parseProductInfo(productInfo, defaultInfo) {
var index = 0;
var colors;
var colorsLen;
... ... @@ -230,7 +232,6 @@ function parseProductInfo(productInfo, defaultInfo) {
// 默认选中用户选择的sku,若已售罄或下架,则选中列表中第一个非售罄的sku
for (index = 0; index < filterSet.length; index++) {
curColor = filterSet[index];
if (!hasActiveColor && String(curColor.name) === String(defaultInfo.color)) {
curColor.active = true;
curColor.hasActiveColor = hasActiveColor = true;
... ... @@ -241,9 +242,10 @@ function parseProductInfo(productInfo, defaultInfo) {
curSize = curColor.sizes;
for (sizeIdx = 0; sizeIdx < curSize.length; sizeIdx++) {
if (curColor.hasActiveColor && curSize[sizeIdx].sku === defaultInfo.sku) {
// console.log(curSize[sizeIdx]);
curSize[sizeIdx].sizeFocus = true;
curSize[sizeIdx].sizeActive = true;
break;
}
}
... ... @@ -294,6 +296,28 @@ function renderAndShowSelWin($item, pinfo) {
$selWin.show();
}
function getProductByPromotionId(promotionId) {
return $.ajax({
type: 'GET',
url: '/cart/index/queryPromotionGift',
data: {
promotionId: promotionId
}
}).done(function(res) {
return res;
});
}
function renderAndShowGiftWin(plist) {
var d = new Dialog({
content: giftsWinTpl(plist),
className: 'cart-togetherGoods'
});
d.show();
}
var Cart = {
addToCart: function(params) {
... ... @@ -580,7 +604,7 @@ var Cart = {
},
selectColor: function() {
var $this = $(this);
var index = $this.index('.dt');
var index = $this.index($this.parent().find('.dt'));
var $srows = $this.closest('.goods-info').find('.choose-size .size-row');
var $bigImgs = $this.closest('.goods-choose-box').find('.goods-info-bigImg .bigImg');
... ... @@ -603,6 +627,31 @@ var Cart = {
$this.siblings('.dt').removeClass('active');
$this.addClass('active');
},
showGiftWin: function () {
var $this = $(this);
var $wrap = $this.closest('[data-role="promotion-wrap"]');
var promotionid = $wrap.data('promotionid');
var productList = $wrap.data('_giftList');
console.log($this);
console.log($wrap);
console.log(promotionid);
if(!productList) {
getProductByPromotionId(promotionid).done(function(plist) {
productList = plist;
$wrap.data('_giftList', productList);
renderAndShowGiftWin(productList);
}).fail(function() {
new Alert('获取商品失败,请稍后再试!').show();
});
return;
}
renderAndShowGiftWin(productList);
},
submit: function() {
/* understock = '';
if ($('.pay-wapper input:checked').parents('tr').find('.tipNoStore').length > 0) {
... ... @@ -659,8 +708,9 @@ $('.btn_account').on('click', Cart.submit); // 结算
$payWapper.on('click', 'li[data-role="pitem"] .pay-pro-detail', Cart.showColorSizePanel);
$payWapper.on('click', 'li[data-role="pitem"] .button-cancel', Cart.hideColorSizePanel);
$payWapper.on('click', 'li[data-role="pitem"] .button-sure', Cart.editColorOrSize);
$payWapper.on('click', 'li[data-role="pitem"] .goods-choose-box .choose-color .dt', Cart.selectColor);
$payWapper.on('click', 'li[data-role="pitem"] .goods-choose-box .choose-size .dt', Cart.selectSize);
$payWapper.find('li[data-role="pitem"]').on('click', '.goods-choose-box .choose-color .dt', Cart.selectColor);
$payWapper.find('li[data-role="pitem"]').on('click', '.goods-choose-box .choose-size .dt', Cart.selectSize);
/** 赠品加价购弹窗 **/
// 显示赠品
... ... @@ -670,6 +720,8 @@ var giftBtn = ['[data-role=gift-view-btn]',
'[data-role=pg-sel-btn]',
'[data-role=pg-resel-btn]'];
$payWapper.on('click', giftBtn.join(','), Cart.showGiftWin);
/*
$('.shop-cart').on('click', giftBtn.join(','), function() {
var $this = $(this);
... ... @@ -681,4 +733,4 @@ $('.shop-cart').on('click', giftBtn.join(','), function() {
$('.shop-cart').on('click', '[data-role="cart-gift-win"] .close', function() {
$(this).closest('[data-role="cart-gift-win"]').hide();
});
});*/
... ...