order.js 1.39 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');

/**
 * 订单页面
 * @param req
 * @param res
 * @param next
 */
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 || 8039759 // TODO 待删除
    };

    orderModel.order(params).then(result => {
        res.render('order', {
            module: 'home',
            page: 'order',
            pageHeader: headerModel.setNav({
                navTitle: '我的订单'
            }),
            title: 'Yoho!Buy 有货',
            order: result
        });
    }).catch(next);
};

/**
 * 获取订单
 * @param req
 * @param res
 * @param next
 */
exports.getOrders = (req, res, next) => {
    orderModel.getOrders({
        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 || 8039759 // TODO 待删除
    }).then(result => {
        res.render('order-content', {
            layout: false,
            orders: result
        });
    }).catch(next);
};