order.js 1.2 KB
/**
 * 个人中心-订单列表 controller
 * @author: jing.li<jing.li@yoho.cn>
 * @date: 2016/08/15
 */

'use strict';

// const headerModel = require('../../../doraemon/models/header'); // 头部model
const orderModel = require('../models/order');

exports.order = (req, res, next) => {
    let params = {
        type: req.query.type || 1,
        page: req.query.page || 1,
        gender: req.query.gender || '1,3',
        yh_channel: req.query.channel || 1,
        uid: req.user.uid || 20000266
    };

    orderModel.order(params).then(result => {
        res.render('order', {
            module: 'home',
            page: 'order',
            title: 'Yoho!Buy 有货',
            order: result
        });
    }).catch(next);
};

exports.getOrders = (req, res, next) => {
    let params = {
        type: req.query.type || 1,
        page: req.query.page || 1,
        gender: req.query.gender || '1,3',
        yh_channel: req.query.channel || 1,
        uid: req.user.uid || 20000266
    };

    orderModel.order(params).then(result => {
        res.render('order-template', {
            layout: false,
            order: result,
            resultOut: JSON.stringify(result, 0, 4)
        });
    }).catch(next);
};