Blame view

apps/home/controllers/returns.js 1.59 KB
陈轩 authored
1 2 3 4
/**
 *  个人中心 退换货
 *  @author 陈轩 <xuan.chen@yoho.cn>
 */
陈轩 authored
5 6 7 8
'use strict';

const cookie = global.yoho.cookie;
const returnsModel = require('../models/returns');
陈轩 authored
9 10 11 12

/*
    我的退换货-列表页
 */
yyq authored
13
const index = (req, res, next) => {
陈轩 authored
14 15 16 17 18 19 20 21 22 23
    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);
陈轩 authored
24
陈轩 authored
25 26 27 28
            res.render('returns/returns', viewData);
        })
        .catch(next);
};
陈轩 authored
29 30 31 32

/*
    我的订单-退货申请页
 */
yyq authored
33
const refundApply = (req, res, next) => {
陈轩 authored
34
    const orderCode = req.query.orderCode;
yyq authored
35
    const uid = req.user.uid;
陈轩 authored
36
yyq authored
37 38 39 40 41
    returnsModel.getOrderRefund(orderCode, uid).then(result => {
        res.render('returns/returns-apply', result);
    }).catch(next);
};
yyq authored
42 43 44 45 46 47 48 49 50 51 52 53
/*
    我的订单-退货申请页
 */
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);
};
yyq authored
54 55 56 57 58 59 60 61 62 63 64 65
/*
    我的订单-换货申请页
 */
const exchangeApply = (req, res, next) => {
    const orderCode = req.query.orderCode;
    const uid = req.user.uid;

    returnsModel.getOrderExchange(orderCode, uid).then(result => {
        res.render('returns/returns-apply', result);
    }).catch(next);
};
yyq authored
66 67
module.exports = {
    index,
yyq authored
68
    refundApply,
yyq authored
69 70
    refundDetail,
    exchangeApply
陈轩 authored
71
};