Authored by biao

update for get user id

@@ -12,10 +12,10 @@ const orderModel = require('../models/order'); @@ -12,10 +12,10 @@ const orderModel = require('../models/order');
12 /** 12 /**
13 * 我的订单 13 * 我的订单
14 */ 14 */
15 -const index = (req, res, next) => { 15 +const index = (req, res) => {
16 const type = req.query.type; 16 const type = req.query.type;
17 const page = req.query.page; 17 const page = req.query.page;
18 - const uid = global.yoho.uid || '7394907'; 18 + const uid = req.user.uid || '13549567';
19 19
20 orderModel.getOrderData(uid, type, page).then(result => { 20 orderModel.getOrderData(uid, type, page).then(result => {
21 res.display('index', { 21 res.display('index', {
@@ -27,12 +27,12 @@ const index = (req, res, next) => { @@ -27,12 +27,12 @@ const index = (req, res, next) => {
27 banner: 'http://placehold.it/{width}x{height}' 27 banner: 'http://placehold.it/{width}x{height}'
28 }, result) 28 }, result)
29 }); 29 });
30 - }).catch(next); 30 + });
31 }; 31 };
32 32
33 -const detail = (req, res, next) => { 33 +const detail = (req, res) => {
34 const code = req.query.code; 34 const code = req.query.code;
35 - const uid = global.yoho.uid || '7394907'; 35 + const uid = req.user.uid || '7394907';
36 36
37 orderModel.getOrderDetail(uid, code).then(result => { 37 orderModel.getOrderDetail(uid, code).then(result => {
38 res.display('index', { 38 res.display('index', {
@@ -44,13 +44,13 @@ const detail = (req, res, next) => { @@ -44,13 +44,13 @@ const detail = (req, res, next) => {
44 banner: 'http://placehold.it/{width}x{height}' 44 banner: 'http://placehold.it/{width}x{height}'
45 }, result) 45 }, result)
46 }); 46 });
47 - }).catch(next); 47 + });
48 }; 48 };
49 49
50 -const getOrderList = (req, res, next) => { 50 +const getOrderList = (req, res) => {
51 const type = req.query.type; 51 const type = req.query.type;
52 const page = req.query.page; 52 const page = req.query.page;
53 - const uid = global.yoho.uid || '7394907'; 53 + const uid = req.user.uid || '7394907';
54 54
55 orderModel.getOrderData(uid, type, page).then(result => { 55 orderModel.getOrderData(uid, type, page).then(result => {
56 res.display('order-table', { 56 res.display('order-table', {
@@ -58,16 +58,14 @@ const getOrderList = (req, res, next) => { @@ -58,16 +58,14 @@ const getOrderList = (req, res, next) => {
58 page: 'order', 58 page: 'order',
59 isMe: true, 59 isMe: true,
60 orderList: result.order.orderList, 60 orderList: result.order.orderList,
61 - paginationOpts: result.order.paginationOpts,  
62 - emptyMsg: result.order.emptyMsg,  
63 - showEmptyEn: result.order.showEmptyEn 61 + paginationOpts: result.order.paginationOpts
64 }); 62 });
65 - }).catch(next); 63 + });
66 }; 64 };
67 65
68 -const getOrderTotal = (req, res, next) => { 66 +const getOrderTotal = (req, res) => {
69 const type = req.query.type; 67 const type = req.query.type;
70 - const uid = global.yoho.uid || '7394907'; 68 + const uid = req.user.uid || '7394907';
71 69
72 70
73 orderModel.getOrderData(uid, type).then(result => { 71 orderModel.getOrderData(uid, type).then(result => {
@@ -76,44 +74,44 @@ const getOrderTotal = (req, res, next) => { @@ -76,44 +74,44 @@ const getOrderTotal = (req, res, next) => {
76 total: result.order.total, 74 total: result.order.total,
77 type: result.order.type 75 type: result.order.type
78 }); 76 });
79 - }).catch(next); 77 + });
80 }; 78 };
81 79
82 -const cancelOrder = (req, res, next) => {  
83 - const uid = global.yoho.uid || '7394907';  
84 - const data = req.query; 80 +const cancelOrder = (req, res) => {
  81 + const uid = req.user.uid || '7394907';
  82 + const code = req.query.orderCode;
85 83
86 - orderModel.cancelOrder(uid, data).then(result => { 84 + orderModel.cancelOrder(uid, code).then(result => {
87 res.json(result); 85 res.json(result);
88 - }).catch(next); 86 + });
89 }; 87 };
90 88
91 -const deleteOrder = (req, res, next) => {  
92 - const uid = global.yoho.uid || '7394907'; 89 +const deleteOrder = (req, res) => {
  90 + const uid = req.user.uid || '7394907';
93 const code = req.query.orderCode; 91 const code = req.query.orderCode;
94 92
95 orderModel.deleteOrder(uid, code).then(result => { 93 orderModel.deleteOrder(uid, code).then(result => {
96 res.json(result); 94 res.json(result);
97 - }).catch(next); 95 + });
98 }; 96 };
99 97
100 -const getExpressInfo = (req, res, next) => {  
101 - const uid = global.yoho.uid || '7394907'; 98 +const getExpressInfo = (req, res) => {
  99 + const uid = req.user.uid || '7394907';
102 const code = req.query.orderCode; 100 const code = req.query.orderCode;
103 101
104 orderModel.getExpressInfo(uid, code).then(result => { 102 orderModel.getExpressInfo(uid, code).then(result => {
105 res.json(result); 103 res.json(result);
106 - }).catch(next); 104 + });
107 }; 105 };
108 106
109 -const getCancelOrderReason = (req, res, next) => { 107 +const getCancelOrderReason = (req, res) => {
110 orderModel.getCancelOrderReason().then(result => { 108 orderModel.getCancelOrderReason().then(result => {
111 res.json(result); 109 res.json(result);
112 - }).catch(next); 110 + });
113 }; 111 };
114 112
115 const editOrder = (req, res) => { 113 const editOrder = (req, res) => {
116 - const uid = global.yoho.uid || '7394907'; 114 + const uid = req.user.uid || '7394907';
117 const query = req.query; 115 const query = req.query;
118 116
119 query.uid = uid; 117 query.uid = uid;
@@ -123,16 +121,6 @@ const editOrder = (req, res) => { @@ -123,16 +121,6 @@ const editOrder = (req, res) => {
123 }); 121 });
124 }; 122 };
125 123
126 -const reAddCart = (req, res) => {  
127 - const uid = global.yoho.uid || '7394907';  
128 - const code = req.query.orderCode;  
129 -  
130 - orderModel.reAddCart(uid, code).then(result => {  
131 - res.json(result);  
132 - });  
133 -  
134 -};  
135 -  
136 module.exports = { 124 module.exports = {
137 index: index, 125 index: index,
138 detail: detail, 126 detail: detail,
@@ -142,6 +130,5 @@ module.exports = { @@ -142,6 +130,5 @@ module.exports = {
142 deleteOrder: deleteOrder, 130 deleteOrder: deleteOrder,
143 editOrder: editOrder, 131 editOrder: editOrder,
144 getExpressInfo: getExpressInfo, 132 getExpressInfo: getExpressInfo,
145 - getCancelOrderReason: getCancelOrderReason,  
146 - reAddCart: reAddCart 133 + getCancelOrderReason: getCancelOrderReason
147 }; 134 };