Express.js
4.19 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
135
136
137
138
139
140
141
const {
mockDeliveryInfoData
} = require("./mock.js");
const LOGISTICS_STATUS = {
1000: '待揽件',
1001: '已揽件',
1002: '运输中',
1003: '已签收',
1004: '拒收'
};
Component({
properties: {
expressInfo: {
type: Object,
value: {},
observer: function (val) {
this.setData({
logisticsData: this.processExpressInfo(val)
})
}
},
showExpress: {
type: Boolean,
value: false
},
height: {
type: String,
value: '256rpx'
}
},
data: {
logisticsData: {},
// timelineData: [
// {
// time: "2021-02-02 10:30:30",
// tips: ["这是主要内容部分"],
// title: "已发货",
// type: 'active',// 高亮显示
// },
// {
// time: "2021-02-02 10:30:30",
// tips: ["这是主要内容部分"],
// title:'运输中',
// type: 'small',// 小点显示
// },
// {
// time: "2021-02-02 10:30:30",
// tips: ["这是主要内容部分11111111111",
// "这是主要内容部分11111111111",
// "这是主要内容部分11111111111"
// ],
// title:'运输中',
// type: 'normal',
// },
// {
// title:'收货地址',
// tips: ["这是主要内容部分"],
// type: 'special' // 地址节点,使用专门的样式
// }
// ],
},
methods: {
processShipmentTrack(shipmentTrack, logisticsStatus) {
if (!this.data.showExpress) {
shipmentTrack = shipmentTrack ? shipmentTrack.slice(0, 2) : []
}
return shipmentTrack.map((track, index) => {
let status = 1000;
let statusDesc = '待揽件';
const content = track.content;
const operateTime = track.operateTime;
const isLast = index === 0;
// 根据内容判断状态
if (content.includes('已签收') || content.includes('签收人')) {
status = 1003;
statusDesc = '已签收';
} else if (content.includes('拒收') || content.includes('退回')) {
status = 1004;
statusDesc = '拒收';
} else if (content.includes('派件') || content.includes('驿站') || content.includes('暂存')) {
status = 1002;
statusDesc = '运输中';
} else if (content.includes('转运中心') || content.includes('发往') || content.includes('到达')) {
status = 1002;
statusDesc = '运输中';
} else if (content.includes('已收件') || content.includes('揽收')) {
status = 1001;
statusDesc = '已揽件';
} else if (content.includes('已发往')) {
status = 1001;
statusDesc = '已揽件';
}
// 根据整体物流状态进行最终调整
if (logisticsStatus < status) {
// 如果整体状态低于当前轨迹状态,说明该轨迹尚未完成
statusDesc = LOGISTICS_STATUS[logisticsStatus] + '(进行中)';
}
return {
...track,
type: isLast ? 'active' : 'small',
status,
statusDesc
};
}).filter(track => {
// 根据整体物流状态过滤轨迹
switch (logisticsStatus) {
case 1000: // 待揽件 - 只显示收件相关记录
return track.status === 1000;
case 1001: // 已揽件 - 显示揽件和发往记录
return track.status <= 1001;
case 1002: // 运输中 - 显示所有运输中的记录
return track.status <= 1002;
case 1003: // 已签收 - 显示所有记录
return track.status <= 1003;
case 1004: // 拒收 - 显示所有记录
return track.status <= 1004;
default:
return true;
}
});
},
processExpressInfo(expressInfo) {
const {
logisticsStatus,
shipmentTrack,
...rest
} = expressInfo;
const processedTrack = this.processShipmentTrack(shipmentTrack, logisticsStatus);
return {
...rest,
logisticsStatus,
logisticsStatusDesc: LOGISTICS_STATUS[logisticsStatus],
shipmentTrack: processedTrack
};
}
}
});