deliveryList.js
4.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import newApi from '~/packageUsedCar/api'
// packageUsedCar/pages/deliveryNote/deliveryList/deliveryList.js
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
Component({
/**
* 组件的属性列表
*/
properties: {
navBarHeight: {
type: Number,
value: 0,
}
},
/**
* 组件的初始数据
*/
data: {
IMG_URL,
typeList: [
{ text: '全部', count: 0, keyNum: 'count', key: '' },
{ text: '待交付', count: 0, keyNum: 'count', key: '0' },
{ text: '交付中', count: 0, keyNum: 'count', key: '1' },
{ text: '已完成', count: 0, keyNum: 'count', key: '2' }
],
tabIndex: 0,
flag: true,
searchText: '',
list: [],
PAYMENT_STATUS: {
0: '待支付',
1: '已结清'
},
ORDER_STATUS: {
0: '待交付',
1: '交付中',
2: '交付完成'
}
},
/**
* 组件的方法列表
*/
methods: {
input(e) {
let {
value
} = e.detail
this.setData({
searchText: value
})
},
// 搜索清空
handleReset() {
this.setData({
searchText: ''
}, () => {
this.search()
})
},
onLoad() {
// 添加埋点
wx.$track.setTrackData(0, 'delivery_management', {}, '', 7)
this.setData({
searchText: ''
}, () => {
this.searchConfirm()
})
},
async getStatByStatus() {
const { searchText, createdStartDate, createdEndDate } = this.data,
data = await newApi.getDeliveryOrderListCount({
searchText,
createdStartDate,
createdEndDate
})
this.setData({
['typeList[0].count']: data.deliveryNum || 0,
['typeList[1].count']: data.deliveryWaitingNum || 0,
['typeList[2].count']: data.deliveringNum || 0,
['typeList[3].count']: data.deliveryEndNum || 0
})
},
searchConfirm() {
this.search()
},
tabClick(e) {
this.setData({
orderStatus: e?.detail || ''
}, () => {
this.search()
})
},
search() {
this.setData({
currentPage: 1,
nothing: false,
flag: false,
list: []
}, () => {
this.getList(true)
this.getStatByStatus()
})
},
searchScreen(e) {
this.back()
this.setData({
createdStartDate: e.detail?.createdStartDate || '',
createdEndDate: e.detail?.createdEndDate || ''
}, () => {
this.searchConfirm()
this.getStatByStatus()
})
},
async getList(isReset = false) {
let { searchText, orderStatus, createdStartDate, createdEndDate, currentPage, nothing } = this.data
if (nothing) return
wx.$util.showLoading('加载中')
const res = await newApi.getDeliveryOrderPageList({
t: { searchText, orderStatus, createdStartDate, createdEndDate },
currentPage: currentPage,
pageSize: 10
})
wx.hideLoading()
if (res.data.code == 0) {
this.setData({
[`list[${currentPage - 1}]`]: res.data.data.records,
currentPage: currentPage + 1,
nothing: currentPage == res.data.data.pages,
triggered: false,
flag: true,
})
if (isReset) {
this.setData({
scrollTop: 0,
})
}
} else {
this.setData({
list: [],
nothing: false,
flag: true,
});
wx.$util.showToast(res.data.msg || '请求失败')
}
},
onBottomRefresh() {
this.getList()
},
// 筛选
showConfirm() {
const thisPage = wx.$router.getPageInstance();
thisPage.setData({ // 顶部状态栏title显示
showScreen: true
})
this.setData({
showRendering: true,
show_confirm: true
})
},
// 筛选返回
back() {
this.setData({
show_confirm: false
})
const thisPage = wx.$router.getPageInstance();
thisPage.setData({
showScreen: false
})
},
// 跳转详情
toDetail(e) {
let { target } = e.currentTarget.dataset
wx.navigateTo({
url: `/packageUsedCar/pages/deliveryNote/deliveryDetail/deliveryDetail?id=${target.id}`,
})
}
}
})