Authored by Aiden Xu

商品详情

... ... @@ -25,9 +25,9 @@ router.post('/list', productList.getProducts);
// 商品详情controller
const detail = require(`${cRoot}/detail`);
router.get(/\/pro_([\d]+)_([\d]+)\/(.*)/, detail.index); // 商品详情routers
router.get(/\/product_([\d]+)_([\d]+)\.json/, detail.product);
router.get(/\/intro\.json/, detail.intro);
router.get(/\/([\d]+)(.*)/, detail.index); // 商品详情routers
router.get(/\/product_([\d]+)\.json/, detail.product);
router.get(/\/intro_([\d]+)\.json/, detail.intro);
router.post(/cart.json/, detail.addToCart);
router.post(/favorite.json/, detail.favorite);
router.get(/cart-count.json/, detail.getCartCount);
... ...
... ... @@ -32,8 +32,8 @@ module.exports = {
* @param result
*/
onAddToCart: (result)=> {
// TODO: 库存不足
// TODO: 商品已下架
// TODO: 库存不足 后台暂未实现
// TODO: 商品已下架 后台暂未实现
if (result.code === 200) {
this.cartCount = result.data.goods_count;
this.showFeatureSelector = false;
... ... @@ -91,6 +91,7 @@ module.exports = {
},
created() {
const self = this;
const pid = app.data('pid');
// 显示商品特征选择组件
this.$on('feature.close', function() {
... ... @@ -98,13 +99,13 @@ module.exports = {
});
// 读取基础数据
$.get(`/product/product_${app.data('pid')}_${app.data('goodsId')}.json`).then((result) => {
$.get(`/product/product_${pid}.json`).then((result) => {
// TODO: 异常处理
this.entity = result;
return result;
}).then((result)=> {
// 读取商品详情
return $.get('/product/product/intro.json', {skn: result.productPriceBo.productSkn});
return $.get(`/product/product/intro_${pid}.json`, {skn: result.productPriceBo.productSkn});
}).then(result => {
this.intro = result;
}).fail(err => {
... ...