outletsList.js 1.25 KB
/*
 * @Author: Targaryen
 * @Date:   2016-05-21 10:59:20
 * @Last Modified by:   Targaryen
 * @Last Modified time: 2016-06-08 13:37:17
 */

'use strict';
const mRoot = '../models';

// list 页 model
const list = require(`${mRoot}/outletsList`);
const headerModel = require('../../../doraemon/models/header');

exports.getProductPic = (req, res) => {

    res.jsonp();
};

/**
 * 商品列表页
 * @param  {[type]} req [description]
 * @param  {[type]} res [description]
 * @return {[type]}     [description]
 */
exports.index = (req, res, next) => {
    let params = Object.assign({
        order: 's_t_asc,s_s_asc'
    }, req.query);

    let channel = req.query.channel || req.cookies._Channel || 'boys';

    params.uid = req.user.uid || 0;

    let responseData = {
        module: 'product',
        page: 'sale',
        footerTop: true
    };

    let headerData = {};

    headerModel.requestHeaderData(channel).then(result => {
        headerData = result.headerData;
    });

    req.ctx(list).getListData(params, channel).then((result) => {
        responseData.saleList = result;
        responseData.resultShow = JSON.stringify(result, null, 4);
        responseData.headerData = headerData;
        res.render('sale/other', responseData);
    }).catch(next);

};