Authored by 郝肖肖

订单详情页按钮组

@@ -117,122 +117,84 @@ const _getOrderData = (params) => { @@ -117,122 +117,84 @@ const _getOrderData = (params) => {
117 * @private 117 * @private
118 */ 118 */
119 const _getOrderStatus = (order, showLogistics) => { 119 const _getOrderStatus = (order, showLogistics) => {
120 - let result = {}; 120 + let orderBtn = [];
121 121
122 - result.useLimitCode = order.use_limit_code === 'Y';  
123 - if (order.is_cancel === 'Y') {  
124 - return Object.assign(result, {  
125 - canceled: true  
126 - }); 122 + if (!order) {
  123 + return {};
127 } 124 }
128 125
129 - // 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)  
130 - // 支付方式为非货到付款时,计算订单状态。  
131 - if (parseInt(order.payment_type, 10) !== 2) {  
132 - switch (order.status) {  
133 - case -1: 126 + if (parseInt(order.attribute, 10) === 9) {
  127 + /* 预售商品,不能进行任何操作 */
  128 + orderBtn.push({
  129 + isAdvance: true
  130 + });
  131 + return {orderBtn: orderBtn};
  132 + }
134 133
135 - /* 预售商品,不能进行任何操作 */  
136 - Object.assign(result, {  
137 - isAdvance: true 134 + _.each(order.links, function(val) {
  135 + switch (val) {
  136 + case 'refundApply':// 申请退款
  137 + orderBtn.push({
  138 + refundApply: true
138 }); 139 });
139 break; 140 break;
140 - case 0:  
141 -  
142 - /* 待付款 */  
143 - Object.assign(result, {  
144 - unpaid: true,  
145 - payUrl: helpers.urlFormat('/home/orders/paynew', {order_code: order.order_code}) 141 + case 'modifyAddress':// 修改收货地址
  142 + orderBtn.push({
  143 + modifyAddress: true,
  144 + link: helpers.urlFormat('/home/orders/addressModify', {
  145 + orderCode: order.order_code,
  146 + areaCode: _.get(order, 'delivery_address.area_code', ''),
  147 + provinceAreaCode: order.is_support_change_province !== 'Y' &&
  148 + !_.get(order, 'delivery_address.province_area_code', false) ?
  149 + _.get(order, 'delivery_address.province_area_code', '') : ''// 如果不允许修改省
  150 + })
146 }); 151 });
147 break; 152 break;
148 - case 1:  
149 - case 2:  
150 - case 3:  
151 -  
152 - /* 已付款状态不给查看物流 URL */  
153 - Object.assign(result, {  
154 - unreceived: true 153 + case 'buyNow':// 立即付款
  154 + orderBtn.push({
  155 + buyNow: true,
  156 + link: helpers.urlFormat('/home/orders/paynew', {order_code: order.order_code}),
155 }); 157 });
156 break; 158 break;
157 - case 4:  
158 - case 5:  
159 -  
160 - /* 已发货状态,给查看物流或二维码URL */  
161 - Object.assign(result, {  
162 - unreceived: true 159 + case 'closeOrder':// 取消订单
  160 + orderBtn.push({
  161 + closeOrder: true
163 }); 162 });
164 -  
165 - /* 是否门票 */  
166 - if (order.virtual_type && parseInt(order.virtual_type, 10) === 3) {  
167 - Object.assign(result, {  
168 - qrcode: helpers.urlFormat(`/home/QRcode/${order.order_code}`)  
169 - });  
170 - } else {  
171 - Object.assign(result, _assignExpressInfo(showLogistics, order));  
172 - }  
173 break; 163 break;
174 - case 6:  
175 -  
176 - /* 已成功订单,给查看物流或二维码URL */  
177 - Object.assign(result, {  
178 - completed: true  
179 - });  
180 -  
181 - /* 是否门票 */  
182 - if (order.virtual_type && parseInt(order.virtual_type, 10) === 3) {  
183 - Object.assign(result, {  
184 - qrcode: helpers.urlFormat(`/home/QRcode/${order.order_code}`)  
185 - });  
186 - } else {  
187 - Object.assign(result, _assignExpressInfo(showLogistics, order));  
188 - } 164 + case 'confirm':// 订单确认
189 break; 165 break;
190 - default: 166 + case 'getExpress':// 查看物流
  167 + orderBtn.push(Object.assign(
  168 + {getExpress: true},
  169 + _assignExpressInfo(showLogistics, order)
  170 + ));
191 break; 171 break;
192 - }  
193 - } else {  
194 -  
195 - /* 订单为货到付款订单时,计算订单状态。(货到付款没有待付款状态) */  
196 - switch (order.status) {  
197 - case 0:  
198 -  
199 - /* 备货中 */  
200 - Object.assign(result, {  
201 - unpaid: true  
202 - }); 172 + case 'shareOrder':// 晒单评价
203 break; 173 break;
204 - case 1:  
205 - case 2:  
206 - case 3:  
207 -  
208 - /* 已付款状态不给查看物流URL */  
209 - Object.assign(result, {  
210 - unreceived: true 174 + case 'delOrder':// 删除订单
  175 + orderBtn.push({
  176 + delOrder: true,
211 }); 177 });
212 break; 178 break;
213 - case 4:  
214 - case 5:  
215 -  
216 - /* 待收货状态,给查看物流 url */  
217 - Object.assign(result, {  
218 - unreceived: true 179 + case 'lookQrcode':// 查看二维码
  180 + orderBtn.push({
  181 + lookQrcode: true,
  182 + link: helpers.urlFormat(`/home/QRcode/${order.order_code}`),
219 }); 183 });
220 - Object.assign(result, _assignExpressInfo(showLogistics, order));  
221 break; 184 break;
222 - case 6:  
223 -  
224 - /* 待收货状态,给查看物流 url */  
225 - Object.assign(result, {  
226 - completed: true 185 + case 'afterService':// 售后服务
  186 + break;
  187 + case 'readd':// 再次购买
  188 + orderBtn.push({
  189 + readd: true
227 }); 190 });
228 - Object.assign(result, _assignExpressInfo(showLogistics, order));  
229 break; 191 break;
230 default: 192 default:
231 break; 193 break;
232 } 194 }
233 - } 195 + });
234 196
235 - return result; 197 + return {orderBtn: orderBtn};
236 }; 198 };
237 199
238 /** 200 /**
@@ -319,29 +281,6 @@ const getOrders = (params) => { @@ -319,29 +281,6 @@ const getOrders = (params) => {
319 /* 是否是虚拟商品 */ 281 /* 是否是虚拟商品 */
320 let isTickets = order.virtual_type && parseInt(order.virtual_type, 10) === 3; 282 let isTickets = order.virtual_type && parseInt(order.virtual_type, 10) === 3;
321 283
322 - /* 修改地址按钮控制 */  
323 - let modifyAddress = {  
324 - modifyAddress: false,  
325 - modifyAddressUrl: ''  
326 - };  
327 -  
328 - if (_.find(value.links, o => {  
329 - return o === 'modifyAddress';  
330 - })) {  
331 - modifyAddress.modifyAddress = true;  
332 - modifyAddress.modifyAddressUrl = helpers.urlFormat('/home/orders/addressModify', {  
333 - orderCode: value.order_code,  
334 - areaCode: _.get(value, 'delivery_address.area_code', '')  
335 - });  
336 -  
337 - // 如果不允许修改省  
338 - if (value.is_support_change_province !== 'Y' &&  
339 - !_.get(value, 'delivery_address.province_area_code', false)) {  
340 - modifyAddress.modifyAddressUrl += '&provinceAreaCode=' +  
341 - _.get(value, 'delivery_address.province_area_code', '');  
342 - }  
343 - }  
344 -  
345 Object.assign(perOrder, { 284 Object.assign(perOrder, {
346 orderNum: value.order_code, 285 orderNum: value.order_code,
347 orderStatus: value.status_str, 286 orderStatus: value.status_str,
@@ -349,9 +288,7 @@ const getOrders = (params) => { @@ -349,9 +288,7 @@ const getOrders = (params) => {
349 goods: _formatOrderGoods(value.order_goods, count, false, isTickets), 288 goods: _formatOrderGoods(value.order_goods, count, false, isTickets),
350 detailUrl: helpers.urlFormat('/home/orderdetail', {order_code: value.order_code}), 289 detailUrl: helpers.urlFormat('/home/orderdetail', {order_code: value.order_code}),
351 count: value.buy_total, 290 count: value.buy_total,
352 - isVirtual: isTickets,  
353 - isDepositAdvance: value.attribute * 1 === 9, // 定金预售  
354 - modifyAddress: modifyAddress 291 + isVirtual: isTickets
355 }); 292 });
356 293
357 /* 如果运费大于0,会显示运费 */ 294 /* 如果运费大于0,会显示运费 */
@@ -13,80 +13,41 @@ @@ -13,80 +13,41 @@
13 {{#shippingCost}}(含运费¥{{.}}){{/shippingCost}} 13 {{#shippingCost}}(含运费¥{{.}}){{/shippingCost}}
14 </footer> 14 </footer>
15 15
16 - {{!-- 对应订单状态的操作逻辑 --}}  
17 - {{#if isDepositAdvance}}  
18 - <div class="order-opt">  
19 - <span class="order-opt-info">请到App完成订单相关操作</span>  
20 - </div>  
21 - {{^}}  
22 - {{!-- 完成和取消订单显示删除按钮 --}}  
23 - {{#unless isAdvance}}  
24 - {{#unless unpaid}}  
25 - <div class="order-opt">  
26 - {{#unless unreceived}}  
27 - <span class="btn del">删除订单</span>  
28 - {{#if isVirtual}}  
29 - <!--虚拟商品-->  
30 - {{else}}  
31 - {{#unless useLimitCode}}<span class="btn rebuy">再次购买</span>{{/unless}}  
32 - {{/if}}  
33 - {{/unless}} 16 + <div class="order-opt">
  17 + {{#if isAdvance}}
  18 + <span class="order-opt-info">*定金预售订单只能在APP端操作</span>
  19 + {{else each orderBtn}}
  20 + {{#if refundApply}}
  21 + <span class="btn refund">申请退款</span>
  22 + {{else if modifyAddress}}
  23 + <a class="btn" href="{{link}}">
  24 + <span>修改地址</span>
  25 + </a>
  26 + {{else if buyNow}}
  27 + <a class="locHref" href="{{link}}">
  28 + <span class="btn pay">立即付款</span>
  29 + </a>
  30 + {{else if closeOrder}}
  31 + <span class="btn cancel">取消订单</span>
  32 + {{else if confirm}}
34 33
35 - {{#if qrcode}}  
36 - <a class="locHref" href="{{qrcode}}">  
37 - <span class="btn check-logistics">查看二维码</span>  
38 - </a>  
39 - {{/if}} 34 + {{else if getExpress}}
  35 + <a class="locHref" href="{{logisticsUrl}}">
  36 + <span class="btn check-logistics">查看物流</span>
  37 + </a>
  38 + {{else if shareOrder}}
40 39
41 - {{!-- 申请退款 --}}  
42 - {{#if refundApply}}  
43 - <span class="btn refund">申请退款</span>  
44 - {{/if}}  
45 - {{!-- 修改地址 --}}  
46 - {{#if modifyAddress.modifyAddress}}  
47 - <a class="btn" href="{{modifyAddress.modifyAddressUrl}}">  
48 - <span>修改地址</span>  
49 - </a>  
50 - {{/if}}  
51 - </div>  
52 - {{/unless}}  
53 - {{/unless}} 40 + {{else if delOrder}}
  41 + <span class="btn del">删除订单</span>
  42 + {{else if lookQrcode}}
  43 + <a class="locHref" href="{{link}}">
  44 + <span class="btn check-logistics">查看二维码</span>
  45 + </a>
  46 + {{else if afterService}}
54 47
55 - {{#unless isAdvance}}  
56 - {{#if unpaid}}  
57 - <div class="order-opt">  
58 - <ul class="count-down hide">  
59 - <li>  
60 - <span class="iconfont count-down-icon">&#xe64a;</span>  
61 - </li>  
62 - <li>  
63 - <span class="hours">{{leftTime}}</span>  
64 - </li>  
65 - </ul>  
66 - <span class="btn cancel">取消订单</span>  
67 - {{#if payUrl}}  
68 - <a class="locHref" href="{{payUrl}}">  
69 - <span class="btn pay">立即付款</span>  
70 - </a>  
71 - {{/if}}  
72 - </div>  
73 - {{/if}}  
74 - {{^}}  
75 - <div class="order-opt">  
76 - *定金预售订单只能在APP端操作  
77 - </div>  
78 - {{/unless}}  
79 -  
80 - {{!-- 包含未发货和已发货状态,未发货不传logisticsUrl --}}  
81 - {{#if unreceived}}  
82 - {{#if logisticsUrl}}  
83 - <div class="order-opt">  
84 - <a class="locHref" href="{{logisticsUrl}}">  
85 - <span class="btn check-logistics">查看物流</span>  
86 - </a>  
87 - </div> 48 + {{else if readd}}
  49 + <span class="btn rebuy">再次购买</span>
88 {{/if}} 50 {{/if}}
89 {{/if}} 51 {{/if}}
90 -  
91 - {{/if}} 52 + </div>
92 </div> 53 </div>