list.js 1.38 KB
/*
 * @Author: Targaryen
 * @Date:   2016-05-21 10:59:20
 * @Last Modified by:   Targaryen
 * @Last Modified time: 2016-06-02 15:17:03
 */

'use strict';
const headerModel = require('../../../doraemon/models/header');
const mRoot = '../models';

// list 页 model
const list = require(`${mRoot}/list`);

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

    res.jsonp();
};

/**
 * 商品列表页
 * @param  {[type]} req [description]
 * @param  {[type]} res [description]
 * @return {[type]}     [description]
 */
exports.index = (req, res) => {
    let params = Object.assign({
        saleType: 2,
        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 = {};

    headerModel.requestHeaderData().then(headerData => {
        responseData = headerModel.setHeaderData(headerData.data, 'vip');
        responseData.module = 'product';
        responseData.page = 'sale';

        // responseData.footerTop = true;
        responseData.devEnv = true;

        list.getSaleOthersData(params, channel).then((result) => {
            responseData.saleList = result;
            responseData.resultShow = JSON.stringify(result, null, 4);

            res.render('sale/other', responseData);
        });

    }).catch(() => {
        res.render('error', { devEnv: true, pageErr: true });
    });

};