order.js
3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* [个人中心]首页/我的订单
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/07/04
*/
'use strict';
const mcHandler = require('../models/menu-crumb-handler');
const orderModel = require('../models/order');
/**
* 我的订单
*/
const index = (req, res) => {
const type = req.query.type;
const page = req.query.page;
const uid = req.user.uid || '10931021';
orderModel.getOrderData(uid, type, page).then(result => {
res.display('index', {
page: 'order',
isMe: true,
content: Object.assign({
nav: mcHandler.getMeCrumb(),
navigation: mcHandler.getSideMenu('我的订单'),
banner: 'http://placehold.it/{width}x{height}'
}, result)
});
});
};
const detail = (req, res) => {
const code = req.query.code;
const uid = req.user.uid || '10931021';
orderModel.getOrderDetail(uid, code).then(result => {
res.display('index', {
isMe: true,
page: 'order-detail',
content: Object.assign({
nav: mcHandler.getMeCrumb(),
navigation: mcHandler.getSideMenu('订单详情'),
banner: 'http://placehold.it/{width}x{height}'
}, result)
});
});
};
const getOrderList = (req, res) => {
const type = req.query.type;
const page = req.query.page;
const uid = req.user.uid || '10931021';
orderModel.getOrderData(uid, type, page).then(result => {
res.display('order-table', {
layout: false,
page: 'order',
isMe: true,
orderList: result.order.orderList,
paginationOpts: result.order.paginationOpts
});
});
};
const getOrderTotal = (req, res) => {
const type = req.query.type;
const uid = req.user.uid || '10931021';
orderModel.getOrderData(uid, type).then(result => {
res.json({
total: result.order.total,
type: result.order.type
});
});
};
const cancelOrder = (req, res) => {
const uid = req.user.uid || '10931021';
const code = req.query.orderCode;
orderModel.cancelOrder(uid, code).then(result => {
res.json(result);
});
};
const deleteOrder = (req, res) => {
const uid = req.user.uid || '10931021';
const code = req.query.orderCode;
orderModel.deleteOrder(uid, code).then(result => {
res.json(result);
});
};
const getExpressInfo = (req, res) => {
const uid = req.user.uid || '10931021';
const code = req.query.orderCode;
orderModel.getExpressInfo(uid, code).then(result => {
res.json(result);
});
};
const getCancelOrderReason = (req, res) => {
orderModel.getCancelOrderReason().then(result => {
res.json(result);
});
};
const editOrder = (req, res) => {
const uid = req.user.uid || '10931021';
const query = req.query;
query.uid = uid;
orderModel.editOrder(query).then(result => {
res.json(result);
});
};
module.exports = {
index: index,
detail: detail,
getOrderList: getOrderList,
getOrderTotal: getOrderTotal,
cancelOrder: cancelOrder,
deleteOrder: deleteOrder,
editOrder: editOrder,
getExpressInfo: getExpressInfo,
getCancelOrderReason: getCancelOrderReason
};