returns.js 1.28 KB
/**
 *  个人中心 退换货
 *  @author 陈轩 <xuan.chen@yoho.cn>
 */
'use strict';

const cookie = global.yoho.cookie;
const returnsModel = require('../models/returns');

/*
    我的退换货-列表页
 */
const index = (req, res, next) => {
    const uid = cookie.getUid(req);
    const page = req.query.page;

    returnsModel.getReturnsList(uid, page /* ,limit=10*/)
        .then(data => {
            const viewData = Object.assign({
                module: 'home',
                page: 'returns',
                meReturnsPage: true
            }, data);

            res.render('returns/returns', viewData);
        })
        .catch(next);
};

/*
    我的订单-退货申请页
 */
const refundApply = (req, res, next) => {
    const orderCode = req.query.orderCode;
    const uid = req.user.uid;

    returnsModel.getOrderRefund(orderCode, uid).then(result => {
        res.render('returns/returns-apply', result);
    }).catch(next);
};

/*
    我的订单-退货申请页
 */
const refundDetail = (req, res, next) => {
    const code = req.query.id;
    const uid = req.user.uid;

    returnsModel.getRefundDetail(code, uid).then(result => {
        res.render('returns/returns-detail', result);
    }).catch(next);
};

module.exports = {
    index,
    refundApply,
    refundDetail
};