Index.js 1.11 KB
'use strict';

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

const OrderData = require('../models/OrderData');
const IndexModel = require('../models/IndexModel');


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

    co(function * () {
        let pall = yield Promise.all([OrderData.closeReasons(), IndexModel.getInfoNumData($uid, $udid), IndexModel.getFooterBanner(), IndexModel.latestOrders($uid), IndexModel.homeData()]);
        let $cancelReason = pall[0].data ? pall[0].data : '';
        res.render('home/index/index', {
            cancelReason: $cancelReason,
            content: [
                {messages: pall[1]},
                {
                    latestOrders: pall[3],
                    favBrand: {
                        more: '/brands',
                        brands: pall[4].brand
                    },
                    newArrival: pall[4].new,
                    banner: pall[2]
                }
            ],
            helpUsUrl: ''
        });
    })().catch(next);
};

module.exports = {
    index
};