Authored by Aiden Xu

商品详情

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