MyWallet.ets
9.1 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
import { getOrderList, getOrderSource, getOrderState, getRecordList } from '../api/originalRecords'
import { recordParams, orderParams, orderTest, orderRow, recordTest, recordRow } from '../api/recordsType'
import { quarterType, quarterTest } from '../api/options/optionsType'
import { getCompanyWallet, getPay, beanType } from '../api/user'
import { companyWalletTest, companyWalletRow } from '../api/userType'
import preferencesUtils from '../utils/preferences'
import { AxiosResponse } from '@ohos/axios'
import orderItem from '../components/orderItem'
import { router } from '@kit.ArkUI'
import FilterOrderDialog from '../dialog/FilterOrderDialog'
import FilterRecordDialog from '../dialog/FilterRecordDialog'
let companyId = preferencesUtils.get('XF_COMPANY_ID', '') as number
@Entry
@Component
struct MyWallet {
@State params: orderParams = {
pageNum: 1,
pageSize: 10,
companyId: companyId
}
@State recordParams: recordParams = {
pageNum: 1,
pageSize: 10,
companyId: companyId
}
@State searchKey: string = ''
@State sourceList: quarterType[] = []
@State stateList: quarterType[] = []
private controller: TabsController = new TabsController()
@State currentIndex: number = 0
@State searchTip: string = '请输入订单编号'
@State totalAll: number = 0
@State orderList: orderRow[] = []
@State recordList: recordRow[] = []
@State recordTotal: number = 0
@State loadingText: string = '点击加载更多'
@State loadingText2: string = '点击加载更多'
@State walletData: companyWalletRow | null = null
@State isShowPay: boolean = false
getList = async () => {
const personRes: AxiosResponse<orderTest> = await getOrderList(this.params)
this.orderList = personRes.data.rows
this.totalAll = personRes.data.total
}
getRecordData = async () => {
const personRes: AxiosResponse<recordTest> = await getRecordList(this.recordParams)
this.recordList = personRes.data.rows
this.recordTotal = personRes.data.total
}
// 获取支付来源列表
getSourceList = async () => {
const sourceRes: AxiosResponse<quarterTest> = await getOrderSource()
this.sourceList = sourceRes.data.data
}
// 获取订单状态列表
getStateList = async () => {
const stateRes: AxiosResponse<quarterTest> = await getOrderState()
this.stateList = stateRes.data.data
}
// 获取报告豆余额
getWalletInfo = async () => {
const walletInfo: AxiosResponse<companyWalletTest> = await getCompanyWallet({pageNum: 1, pageSize: 10, companyId: Number(companyId)})
this.walletData = walletInfo.data.rows[0]
}
async aboutToAppear(){
Promise.all([
this.getList(),
this.getRecordData(),
this.getSourceList(),
this.getStateList(),
this.getWalletInfo()
])
}
// 订单查询筛选
dialogOrderController: CustomDialogController = new CustomDialogController({
builder: FilterOrderDialog({
params: this.params,
sourceList: this.sourceList,
stateList: this.stateList,
confirm: () => {
this.getList()
},
reset: () => {
this.getList()
this.searchKey = ''
}
}),
alignment: DialogAlignment.Center,
customStyle: false,
cornerRadius: 10
})
// 消费记录查询筛选
dialogRecordController: CustomDialogController = new CustomDialogController({
builder: FilterRecordDialog({
recordParams: this.recordParams,
confirm: () => {
this.getRecordData()
},
reset: () => {
this.getRecordData()
this.searchKey = ''
}
}),
alignment: DialogAlignment.Center,
customStyle: false,
cornerRadius: 10
})
// 加载更多订单数据
private async loadMoreData(){
if(this.params.pageSize >= this.totalAll) {
this.loadingText = '已加载全部数据'
}else {
this.params.pageSize += 10
await this.getList()
}
}
// 加载更多消耗数据
private async loadMoreRecordData(){
if(this.recordParams.pageSize >= this.recordTotal) {
this.loadingText2 = '已加载全部数据'
}else {
this.recordParams.pageSize += 10
await this.getRecordData()
}
}
build() {
Column(){
// 顶部搜索
Row(){
Image($r('app.media.back_light')).width(20).onClick(() => {
router.back()
})
Search({ placeholder: this.searchTip, value: $$this.searchKey })
.searchButton('搜索', {
fontSize: 12
})
.width('95%')
.height(30)
.backgroundColor('#fff')
.borderWidth(1)
.placeholderColor(Color.Grey)
.placeholderFont({ size: 12, weight: 400 })
.textFont({ size: 12, weight: 400 })
.layoutWeight(1)
.onChange((value: string) => {
this.currentIndex == 0 ? this.params.orderNo = value : this.recordParams.reportNo = value
})
.onSubmit(() => {
this.currentIndex == 0 ? this.getList() : this.getRecordData()
})
Row(){
Image($r('app.media.filter')).width(20).onClick(() => {
this.currentIndex == 0 ? this.dialogOrderController.open() : this.dialogRecordController.open()
})
}.width(40).padding({left:5, right: 5}).justifyContent(FlexAlign.SpaceAround)
}.padding({left: 5, right: 5})
// 我的余额
Row(){
Column({space: 10}){
Text('余额(豆)').fontSize(14).fontColor('#fff')
Text(this.walletData?.bean.toString()).fontSize(24).fontColor('#fff').fontWeight(600).fontStyle(FontStyle.Italic)
Text('开票信息').padding({top: 5, bottom: 5, left: 15, right: 15})
.backgroundColor('#fff').borderRadius(30).fontSize(14).fontColor('#13ce66')
.onClick(() => {
router.pushUrl({
url: 'pages/BillingInformation'
})
})
}.height(150).justifyContent(FlexAlign.Center).padding(20)
Column(){
Text('充值').borderWidth(2).borderColor('#fff').borderRadius(30)
.padding({top: 5, bottom: 5, left: 15, right: 15}).fontSize(14).fontColor('#fff')
.onClick(() => {
router.pushUrl({
url: 'pages/Recharge'
})
})
}.height(150).alignItems(HorizontalAlign.Center).padding(20)
.visibility(this.isShowPay ? Visibility.Visible : Visibility.None)
}.height(150).borderRadius(10).backgroundColor('#13ce66')
.width('100%').justifyContent(FlexAlign.SpaceBetween)
// 订单导航
Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) {
TabContent() {
List(){
ForEach(this.orderList, (item: orderRow) => {
ListItem(){
orderItem({
orderInfo: item,
sourceList: this.sourceList,
stateList: this.stateList
})
}
})
ListItem(){
Row({space: 5}){
Text().width(20).height(1).backgroundColor('#999')
Text(this.loadingText).fontSize(12).fontColor('#999')
Text().width(20).height(1).backgroundColor('#999')
}.width('100%').padding({top: 10, bottom: 10}).justifyContent(FlexAlign.Center)
.onClick(async () => {
this.loadMoreData()
})
}.width('100%')
}.height('100%').width('100%')
}.tabBar('充值订单')
TabContent() {
List(){
ForEach(this.recordList, (item: recordRow) => {
ListItem(){
Row(){
Column({space: 10}){
Text(`原始记录编号:${item.reportNo}`).fontSize(14).fontColor('#000').fontWeight(600)
Text(`时间:${item.createTime}`).fontSize(12).fontColor('#999')
}.alignItems(HorizontalAlign.Start)
Text(`-${item.costBean}`).fontStyle(14).fontStyle(FontStyle.Italic).fontColor('#ff4949').fontWeight(600)
}.padding({top: 20, bottom: 20, left: 10, right: 10}).width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'}).width('100%')
}
})
ListItem(){
Row({space: 5}){
Text().width(20).height(1).backgroundColor('#999')
Text(this.loadingText2).fontSize(12).fontColor('#999')
Text().width(20).height(1).backgroundColor('#999')
}.width('100%').padding({top: 10, bottom: 10}).justifyContent(FlexAlign.Center)
.onClick(async () => {
this.loadMoreRecordData()
})
}.width('100%')
}.height('100%').width('100%')
}.tabBar('消耗记录')
}
.vertical(false)
.barMode(BarMode.Fixed)
.onChange((index: number) => {
// currentIndex控制TabContent显示页签
this.currentIndex = index
this.searchTip = index == 0 ? '请输入订单编号' : '请输入【原始记录编号】'
})
.layoutWeight(1)
}.height('100%').width('100%').padding(10)
}
}