Authored by yyq

未登录限制加入购物车

... ... @@ -136,7 +136,7 @@ const delCartGoods = (req, res, next) => {
* @param int isEdit 是否是编辑商品SKU,0表示不是编辑
* @return json
*/
const cartAddIndex = (req, res) => {
const cartAddIndex = (req, res, next) => {
co(function * () {
let uid = req.user.uid;
... ... @@ -176,7 +176,7 @@ const cartAddIndex = (req, res) => {
}
res.send(result);
})();
})().catch(next);
};
/**
... ...
... ... @@ -18,7 +18,7 @@ const ensure = require(`${cRoot}/order-ensure`);
const ticket = require(`${cRoot}/ticket`);
router.get('/index/getProductInfo', cart.getProductInfo);
router.post('/cart/detailAdd', cart.cartAddIndex); // 加入购物车 商品详情页
router.post('/cart/detailAdd', auth, cart.cartAddIndex); // 加入购物车 商品详情页
router.get('/coupon/list', cart.getCoupons); // 优惠券列表
... ... @@ -57,6 +57,6 @@ router.get('/cart/togetherProduct', cart.getTogetherProduct);
router.get('/cart/recommendProduct', cart.getRecommendProductAction);
router.get('/cart/minicart', cart.miniCart);
router.get('/cart/del', cart.delCartGoods);
router.post('/cart/addBundle', cart.addBundle);
router.post('/cart/addBundle', auth, cart.addBundle);
module.exports = router;
... ...
... ... @@ -10,7 +10,7 @@ const _ = require('lodash');
const helpers = global.yoho.helpers;
module.exports = (req, res, next) => {
let refer = req.method === 'GET' ? req.get('Referer') : '';
let refer = req.get('Referer') || '';
let loginAPI = helpers.urlFormat('/passport/login', {refer: refer});
... ...
... ... @@ -52,6 +52,7 @@ exports.serverError = () => {
if (err && err.code === 401) {
if (req.xhr) {
err.data = {refer: helpers.urlFormat('/signin.html', {refer: req.get('Referer') || ''})};
return res.json(err);
} else {
return res.redirect(helpers.urlFormat('/signin.html', {refer: req.fullUrl()}));
... ...
... ... @@ -152,6 +152,10 @@ function addCart() {
return $.Deferred().resolve().promise(); // eslint-disable-line
} else if (code === 400 || code === 401) {
if (data.data && data.data.refer) {
location.href = data.data.refer;
}
} else if (code === 500) {
if (deposit) {
... ...