index.js 1.26 KB
/**
 * 个人中心二维码 controller
 * @author: weiqingting<qingting.wei@yoho.cn>
 * @date: 2016/05/16
 */
'use strict';

const Promise = require('bluebird');
const co = Promise.coroutine;

const OrderData = require('../models/order-data');
const IndexModel = require('../models/index-model');


const index = (req, res, next)=>{
    let $uid = '8041246';// req.user.uid;
    let $udid = 'abcdrf';// req.sessionID;

    co(function*() {
        let items = yield Promise.all([OrderData.closeReasons(),
            IndexModel.getInfoNumData($uid, $udid),
            IndexModel.getFooterBanner(),
            IndexModel.latestOrders($uid),
            IndexModel.homeData()]);

        let cancelReason = items[0].data ? items[0].data : '';
        res.render('index', {
            cancelReason: cancelReason,
            content: [
                {messages: items[1]},
                {
                    latestOrders: items[3],
                    favBrand: {
                        more: '/brands',
                        brands: items[4].brand
                    },
                    newArrival: items[4].new,
                    banner: items[2]
                }
            ],
            helpUsUrl: ''
        });
    })().catch(next);
};

module.exports = {
    index
};