Authored by 郭成尧

add-to-cart-success

... ... @@ -132,9 +132,16 @@ const del = (req, res, next) => {
* [加入购物车]
*/
const add = (req, res, next) => {
if (!req.xhr) {
return next();
}
// for guang
let allowOrigin = _.get(req, 'headers.origin', null) ?
req.headers.origin : req.protocol + '://guang.' + req.headers.host;
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
// if (!req.xhr) {
// return next();
// }
let shoppingKey = req.cookies._SPK || '',
uid = req.user && req.user.uid;
let productSku = req.body.productSku,
... ...
... ... @@ -322,10 +322,17 @@ exports.index = (req, res, next) => {
* @return {[type]} [description]
*/
exports.indexData = (req, res, next) => {
if (!req.xhr) {
return next();
}
if (!req.body.id) {
// for guang
let allowOrigin = _.get(req, 'headers.origin', null) ?
req.headers.origin : req.protocol + '://guang.' + req.headers.host;
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
// if (!req.xhr) {
// return next();
// }
if (!req.body.id && !req.body.productSkn) {
return next();
}
let uid = req.user.uid || 0;
... ...
... ... @@ -2,21 +2,24 @@
* @Author: Targaryen
* @Date: 2017-05-08 09:43:20
* @Last Modified by: Targaryen
* @Last Modified time: 2017-05-08 10:41:36
* @Last Modified time: 2017-05-08 10:59:37
*/
const $ = require('yoho-jquery');
const chosePanel = require('common/chose-panel-new');
const detailFuns = require('product/detail/functions');
let $addToCart = $('.add-to-cart');
$addToCart.on('click', function(e) {
let $this = $(e.currentTarget);
let productSkn = $this.data('skn');
$.post(location.protocol + '//m.yohobuy.com/product/detail/info',
{
productSkn: $this.data('skn')
}, function(data) {
chosePanel.show({data});
$.post(location.protocol + '//m.yohobuy.com/product/detail/info', {
productSkn: productSkn
}, function(data) {
chosePanel.show({data}).then(result => {
detailFuns.addToCart(result.sku.skuId, productSkn, result.buyNum);
});
});
});
... ...
... ... @@ -82,7 +82,7 @@ let functions = {
}
$.ajax({
method: 'POST',
url: '/cart/index/add',
url: '//m.yohobuy.com/cart/index/add',
data: {
productSku: sku,
new_product_skn: skn,
... ...