detail.js 1.14 KB
/**
 *
 * @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 _ = require('lodash');

/**
 * 商品详情
 */
const component = {
    index: (req, res) => {
        const pid = req.params[0], goodsId = req.params[1];

        res.render('detail', {
            module: 'product',
            page: 'detail',
            pid: pid,
            goodsId: goodsId
        });
    },
    product: (req, res, next) => {
        const pid = req.params[0];// , goodsId = req.params[1];

        let params = {
            productId: _.toString(pid),
            method: 'h5.product.data'
        };

        api.get('', 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 => {
            res.json(result);
        }).catch(next);
    }
};

module.exports = component;