Authored by OF1706

Merge branch 'feature/shoppingCart' of http://git.yoho.cn/fe/yohobuy-node into feature/shoppingCart

... ... @@ -60,8 +60,6 @@ const setShoppingCookie = (req, res) => {
_r: 1
});
}
}).finally(() => {
return;
});
};
... ... @@ -151,12 +149,10 @@ const cartAdd = (req, res) => {
}
if (result && result.code === 200) {
return setShoppingCookie(req, res).then(() => {
return res.send(result);
});
} else {
res.send(result);
yield setShoppingCookie(req, res);
}
res.send(result);
})();
};
... ... @@ -179,7 +175,7 @@ const cartTotal = (req, res) => {
/**
* 购物车商品选择与取消
*/
const selectProduct = (req, res) => {
const selectProduct = (req, res, next) => {
let uid = req.user.uid;
let productId = req.body.skuList;
... ... @@ -190,11 +186,7 @@ const selectProduct = (req, res) => {
service.selectGoods(uid, productId, shoppingKey, hasPromotion, cartDelList)
.then(ret => {
res.send(ret);
}).catch(() => {
res.send({
code: 400
});
});
}).catch(next);
};
/**
... ... @@ -241,11 +233,6 @@ const removeProduct = (req, res) => {
if (ret && ret.code === 200) {
yield setShoppingCookie(req, res);
/* res.cookie('cart-del-list', cartDelList, {
domain: '.yohobuy.com',
path: '/'
});*/
}
return res.send(ret);
... ... @@ -321,12 +308,6 @@ const getTogetherProduct = (req, res) => {
co(function * () {
let page = req.query.page;
/* let ret = {
code: 200,
message: '凑单商品'
};*/
let ret = yield service.getTogetherProduct(page);
return res.send(ret);
... ... @@ -363,12 +344,6 @@ const getIncreasePurchase = (req, res) => {
co(function * () {
let page = req.query.page;
/* let ret = {
code: 200,
message: '凑单商品'
};*/
let ret = yield service.getTogetherProduct(page);
return res.send(ret);
... ...
... ... @@ -207,9 +207,8 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
}
// 商品链接
let cnAlphaBet = it.cn_alphabet ? it.cn_alphabet : md5(it.product_name);
goods.link = helpers.urlFormat(`/product/pro_${it.product_id}_${it.goods_id}/${cnAlphaBet}.html`, null, 'item');
// let cnAlphaBet = it.cn_alphabet ? it.cn_alphabet : md5(it.product_name);
goods.link = helpers.getUrlBySkc(it.product_id, it.goods_id, it.cn_alphabet);
return goods;
});
... ... @@ -307,10 +306,8 @@ const formatPriceGiftOne = (it) => {
// 商品链接
if (g.goods_id) {
let cnAlphaBet = g.cn_alphabet ? g.cn_alphabet : md5(g.product_name);
goods.subjoinLink = helpers.urlFormat(`/product/pro_${g.product_id}_${g.goods_id}/${cnAlphaBet}.html`,
null, 'item');
// let cnAlphaBet = g.cn_alphabet ? g.cn_alphabet : md5(g.product_name);
goods.subjoinLink = helpers.getUrlBySkc(g.product_id, g.goods_id, g.cn_alphabet);
} else {
let uri = `/product/show_${g.product_id}_${g.product_skn}/${makeToken(g.product_skn)}.html`;
... ...
... ... @@ -11,7 +11,8 @@ const co = Promise.coroutine;
const _ = require('lodash');
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const md5 = require('md5');
// const md5 = require('md5');
const ERROR_400_MESSAGE = '系统繁忙,请稍候再试!';
const productAPI = require('./product-api');
... ... @@ -743,11 +744,11 @@ const getRecommendProduct = (channel, uid, udid, page) => {
};
// 商品链接
let cnAlphaBet = it.cn_alphabet ? it.cn_alphabet : md5(it.product_name);
// let cnAlphaBet = it.cn_alphabet ? it.cn_alphabet : md5(it.product_name);
let firstGoods = it.goods_list && it.goods_list[0];
let productSkc = firstGoods && firstGoods.product_skc;
item.href = helpers.url(`/product/pro_${it.product_id}_${productSkc}/${cnAlphaBet}.html`, null, 'item');
item.href = helpers.getUrlBySkc(it.product_id, productSkc, it.cn_alphabet);
if (it.sales_price !== it.market_price) {
it.marketPrice = chelper.transPrice(it.market_price);
... ... @@ -973,10 +974,8 @@ const getMiniCartData = (uid, shoppingKey) => {
product_sku: g.product_sku,
promotion_id: g.promotion_id
};
let cnAlphaBet = g.cn_alphabet ? g.cn_alphabet : md5(g.product_name);
let uri = `/product/pro_${g.product_id}_${g.goods_id}/${cnAlphaBet}.html`;
goods.product_url = helpers.urlFormat(uri, null, 'item');
goods.product_url = helpers.getUrlBySkc(g.product_id, g.goods_id, g.cn_alphabet);
return goods;
});
... ...
... ... @@ -90,7 +90,7 @@
{{#ordinaryCart}}
{{#pools}}
<div class="promotion-pool" data-role="promotion-pool">
<div class="promotion-pool {{#unless @first}}mt20{{/unless}}" data-role="promotion-pool">
{{#if promotionInfos}}
<div class="gift-sell mt20">
{{#promotionInfos}}
... ...
... ... @@ -196,7 +196,7 @@ Cart = {
if (!$.isEmptyObject(selectArray)) {
var content = '<div><i class="iconfont">&#xe684;</i>清除失效商品</div><p>确定要清除失效商品吗?</p>'; // eslint-disable-line
new RConfirm(content, function() { // eslint-disable-line
capi.cartItemDel(selectArray, true, PromotionArray);
capi.cartItemDel(selectArray, true);
}).show();
} else {
var content = '<div class="alert-main"><i class="iconfont">&#xe6cc;</i>购物车中没有失效商品!</div>'; // eslint-disable-line
... ...
... ... @@ -242,7 +242,7 @@ function addcart(data, cookieList) {
});
}
} else {
new Alert(d.message === '' ? '加入购物车失败哦~~' : d.message).show();
new Alert(!d.message ? '加入购物车失败哦~~' : d.message).show();
}
});
}
... ...