Authored by 沈志敏

修改商品详情接口

... ... @@ -52,6 +52,17 @@ const component = {
res.json(result);
}).catch(next);
},
brand(req, res, next) {
const brandId = req.params[0];
model.brand({
uid: req.user.uid || 0,
brand_id: brandId,
gender: req.query.gender || '1,2,3'
}).then(result => {
res.json(result);
}).catch(next);
},
/**
* 加入购物车接口
... ... @@ -153,4 +164,4 @@ const component = {
}
};
module.exports = component;
module.exports = component;
\ No newline at end of file
... ...
... ... @@ -41,6 +41,11 @@ const model = {
method: 'h5.product.intro'
}, params));
},
brand(params) {
return api.get('', Object.assign({
method: 'app.shop.queryShopsByBrandId'
}, params)).then(camelCase);
},
/**
* 加入购物车接口
... ... @@ -83,4 +88,4 @@ const model = {
}
};
module.exports = model;
module.exports = model;
\ No newline at end of file
... ...
... ... @@ -45,6 +45,7 @@ const detail = require(`${cRoot}/detail`);
router.get(/\/product\/pro_([\d]+)_([\d]+)\/(.*).html/, detail.index); // 商品详情routers
router.get(/\/product\/product_([\d]+)\.json/, detail.product);
router.get(/\/product\/intro_([\d]+)\.json/, detail.intro);
router.get(/\/product\/brand_([\d]+)\.json/, detail.brand);
router.post(/\product\/cart.json/, detail.addToCart);
router.post(/\product\/favorite.json/, detail.favorite);
router.get(/\/product\/cart-count.json/, detail.getCartCount);
... ... @@ -66,4 +67,4 @@ router.get('/search.json', search.fetchProducts); // ajax
module.exports = router;
module.exports = router;
\ No newline at end of file
... ...
... ... @@ -520,8 +520,6 @@
return;
}
this.entity = result.data;
this.brand = result.data.brandInfo;
if (this.entity.storage === 0 || this.entity.status === 0) {
this.isSoldOut = true;
}
... ... @@ -556,6 +554,12 @@
$.get(`/product/product/intro_${pid}.json`, {skn: data.productSkn}).then(intro => {
this.intro = intro;
});
if (data.brandInfo && data.brandInfo.brandId) {
$.get(`/product/product/brand_${data.brandInfo.brandId}.json`).then(brand => {
this.brand = brand.data && brand.data.length ? brand.data[0] : {};
});
}
}
})
.always(() => {
... ...