...
|
...
|
@@ -14,6 +14,7 @@ exports.index = (req, res) => { |
|
|
const uid = req.user.uid || null;
|
|
|
|
|
|
cartModel.getCartData(shoppingKey, uid).then((result) => {
|
|
|
// console.log(JSON.stringify(result, '', 4))
|
|
|
if (result.code === 200) {
|
|
|
res.display('cart', _.merge({
|
|
|
module: 'shopping',
|
...
|
...
|
@@ -31,37 +32,6 @@ exports.index = (req, res) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
// 检查库存
|
|
|
exports.checkInventory = (req, res) => {
|
|
|
let chkResult,
|
|
|
invalidProIds = [],
|
|
|
productId = req.query.productId,
|
|
|
result = {};
|
|
|
|
|
|
if (productId === 'ALL') {
|
|
|
chkResult = false;
|
|
|
invalidProIds.push('286143');
|
|
|
} else {
|
|
|
if (req.query.productId === '286143') {
|
|
|
chkResult = false;
|
|
|
} else {
|
|
|
chkResult = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (invalidProIds.length) {
|
|
|
_.merge(result, {
|
|
|
invalidProIds: invalidProIds
|
|
|
});
|
|
|
}
|
|
|
|
|
|
_.merge(result, {
|
|
|
valid: chkResult
|
|
|
});
|
|
|
|
|
|
res.json(result);
|
|
|
};
|
|
|
|
|
|
|
|
|
// 修改数量
|
|
|
exports.changeProductNum = (req, res) => {
|
...
|
...
|
@@ -71,13 +41,15 @@ exports.changeProductNum = (req, res) => { |
|
|
const uid = req.user.uid;
|
|
|
const shoppingKey = req.cookies._SPK;
|
|
|
const sku = req.body.sku;
|
|
|
const goodTpye = req.body.goodType;
|
|
|
|
|
|
if (changeType === 'INCREASE') {
|
|
|
cartModel.modifyProductNum({
|
|
|
increaseNum: 1, // 默认是1
|
|
|
uid,
|
|
|
shoppingKey,
|
|
|
sku
|
|
|
sku,
|
|
|
goodTpye
|
|
|
}).then(result => {
|
|
|
console.log('changeProductNum-INCREASE-result:', result);
|
|
|
if (result.code === 200) {
|
...
|
...
|
@@ -102,7 +74,8 @@ exports.changeProductNum = (req, res) => { |
|
|
decreaseNum: 1, // 默认是1
|
|
|
uid,
|
|
|
shoppingKey,
|
|
|
sku
|
|
|
sku,
|
|
|
goodTpye
|
|
|
}).then(result => {
|
|
|
console.log('changeProductNum-DECREASE-result:', result);
|
|
|
if (result.code === 200) {
|
...
|
...
|
@@ -199,6 +172,7 @@ exports.addToCart = (req, res) => { |
|
|
shoppingKey: req.cookies._SPK || null,
|
|
|
uid: req.user.uid
|
|
|
}).then((result) => {
|
|
|
res.cookie('_SPK', result.data.shopping_key);
|
|
|
res.json(result);
|
|
|
});
|
|
|
};
|
...
|
...
|
@@ -234,39 +208,5 @@ exports.toggleSelectGoods = (req, res) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
// 购物车商品选择与取消选择
|
|
|
exports.modifyProductNum = (req, res) => {
|
|
|
const uid = req.user.uid;
|
|
|
const shoppingKey = req.cookies._SPK;
|
|
|
const changeType = req.body.changeType;
|
|
|
const changeNum = req.body.changeNum;
|
|
|
const sku = req.body.sku;
|
|
|
|
|
|
let params = {
|
|
|
uid,
|
|
|
shoppingKey,
|
|
|
sku
|
|
|
};
|
|
|
|
|
|
if (changeType === 'INCREASE') {
|
|
|
_.merge(params, {
|
|
|
increaseNum: changeNum
|
|
|
});
|
|
|
} else if (changeType === 'DECREASE') {
|
|
|
_.merge(params, {
|
|
|
decreaseNum: changeNum
|
|
|
});
|
|
|
} else {
|
|
|
|
|
|
// TODO
|
|
|
// CHANGE
|
|
|
}
|
|
|
|
|
|
cartModel.modifyProductNum(params).then(result => {
|
|
|
res.json(_.merge(cartModel.filterCartData(result, uid), {code: result.code, message: result.message}));
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
...
|
...
|
|