orderDisplay.helpers.js
1.01 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
const hasDisplayValue = value =>
value !== null &&
value !== undefined &&
(typeof value !== 'string' || value.trim() !== '')
const preferCustomerValue = (customerValue, orderValue) =>
hasDisplayValue(customerValue) ? customerValue : orderValue
/**
* 将订单详情接口的嵌套客户、支付信息展开为页面展示对象。
* 客户对象中的手机号和车牌号是权威值,避免被订单顶层空值覆盖。
*/
export function buildOrderDisplayInfo(order = {}) {
const customer = order.customer || {}
return {
...customer,
...(order.payOrder || {}),
...order,
customerPhone: preferCustomerValue(
customer.customerPhone,
order.customerPhone
),
plateNumber: preferCustomerValue(
customer.plateNumber,
order.plateNumber
)
}
}
export function resolveConstructionButton(confirmFlag) {
if (Number(confirmFlag) === 1) {
return {
showBtn: '确认订单是否施工',
btnName: 'confirmConstruction'
}
}
return { showBtn: false }
}