Authored by Aiden Xu

商品详情

... ... @@ -10,6 +10,7 @@
// const helpers = global.yoho.helpers;
const api = global.yoho.API;
const _ = require('lodash');
const model = require('../models/detail');
/**
* 商品详情
... ... @@ -30,22 +31,20 @@ const component = {
let params = {
productId: _.toString(pid),
method: 'h5.product.data',
uid: req.user.uid || 8050378 // TODO: fix this hard coded uid
};
api.get('', params).then(result => {
model.product(params).then(result => {
res.json(result);
}).catch(next);
},
intro(req, res, next) {
let params = {
method: 'h5.product.intro',
productskn: req.query.skn,
udid: 'f528764d624db129b32c21fbca0cb8d6'
};
api.get('', params).then(result => {
model.intro(params).then(result => {
res.json(result);
}).catch(next);
},
... ... @@ -56,7 +55,6 @@ const component = {
*/
addToCart(req, res, next) {
let params = {
method: 'app.Shopping.add',
product_sku: req.body.productSku, // 商品SKU
buy_number: req.body.buyNumber, // 购买数量
goods_type: req.body.goodsType || 0, // 商品类型,0表示普通商品,1表示加价购商品
... ... @@ -67,7 +65,7 @@ const component = {
shopping_key: global.yoho.cookie.getShoppingKey(req)
};
api.get('', params).then(result => {
model.addToCart(params).then(result => {
if (result.code === 200) {
// 将 shopping_key 写入Cookie
res.cookie('_SPK', result.data.shopping_key, {maxAge: 86400 * 360});
... ... @@ -97,7 +95,7 @@ const component = {
params.method = 'app.favorite.cancel';
}
api.get('', params).then(result => {
model.favorite(params).then(result => {
res.json(result);
}).catch(next);
},
... ...
/**
*
* @author: Aiden Xu<aiden.xu@yoho.cn>
* @date: 2016/07/19
*/
'use strict';
// const _ = require('lodash');
// const helpers = global.yoho.helpers;
const api = global.yoho.API;
/**
* 商品详情
*/
const model = {
product(params) {
return api.get('', Object.assign({
method: 'h5.product.data'
}, params));
},
intro(params) {
return api.get('', Object.assign({
method: 'h5.product.intro'
}, params));
},
/**
* 加入购物车接口
*
*/
addToCart(params) {
return api.get('', Object.assign({
method: 'app.Shopping.add'
}, params));
},
/**
* 添加收藏/取消收藏
*
* @param params
*/
favorite(params) {
let method = '';
if (params.operation === 'add') {
method = 'app.favorite.add';
} else if (params.operation === 'remove') {
method = 'app.favorite.cancel';
}
return api.get('', Object.assign({
method: method
}, params));
},
/**
* 获取购物车数量
*
* @param params
*/
getCartCount: (params) => {
return api.get('', Object.assign({
method: 'app.Shopping.count'
}, params));
}
};
module.exports = model;
... ...
... ... @@ -14,7 +14,7 @@
</div>
</show-box>
<show-box>
<show-box v-if="entity.brand">
<div class="brand">
<img :src="entity.brand.brandIco | resize 110 68" width="55" height="34"/>
... ... @@ -157,11 +157,11 @@
<show-box :is-last="true">
<h2>商品详情</h2>
<i>DETAILS</i>
<p>
<p v-if="entity.brand && entity.brand.brandIntro">
{{{entity.brand.brandIntro}}}
</p>
<p v-if="intro.productIntroBo">
<p v-if="entity.brand && intro.productIntroBo">
{{{intro.productIntroBo.productIntro}}}
</p>
</show-box>
... ...