orderList.vue
12.8 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
<template>
<view class="order-page">
<!-- 顶部角色Tab -->
<view class="role-tab-bar">
<view
v-for="(tab, index) in roleTabs"
:key="index"
class="role-tab-item"
:class="{ active: currentRoleTab === index }"
@click="switchRoleTab(index)"
>
{{ tab.name }}
</view>
</view>
<!-- 订单列表Tab -->
<view class="tab-bar">
<view
v-for="(tab, index) in orderTabs"
:key="index"
class="tab-item"
:class="{ active: currentTab === index }"
@click="switchTab(index)"
>
{{ tab.name }}
</view>
</view>
<!-- 订单列表 -->
<scroll-view
scroll-y
class="order-list-scroll"
:show-scrollbar="false"
@scrolltolower="loadMore"
lower-threshold="200"
>
<view class="order-list">
<view v-if="list.length > 0">
<view
class="order-card"
v-for="(item, index) in list"
:key="index"
>
<!-- 卡片头部:日期 + 状态 -->
<view class="card-header">
<view class="date">
<image :src="config.baseUrl_api + '/fs/static/calendar@2x.png'" v-if="item.payTime" mode="widthFix" style="width:30rpx;height:30rpx;"/>
<text class="date-text" v-if="item.payTime">{{ item.payTime }}</text>
</view>
<view class="status-tags">
<view class="status-tag" :class="getPayStatusClass(item.payStatus)">
{{ getPayStatusText(item.payStatus) }}
</view>
<view class="status-tag ml-10" :class="getAuditStatusClass(item.auditStatus)">
{{ getAuditStatusText(item.auditStatus) }}
</view>
</view>
</view>
<!-- 订单编号、缴费编号 -->
<view class="info-row">
<text class="label">订单编号:</text>
<text class="value">{{ item.tradeNo || '--' }}</text>
</view>
<view class="info-row">
<text class="label">缴费编号:</text>
<text class="value">{{ item.wfCode || '--' }}</text>
</view>
<!-- 人员/年限信息 -->
<view class="info-section">
<!-- 个人/单位会员 -->
<template v-if="currentRoleTab === 0 || currentRoleTab === 1">
<view class="info-item">
<text class="item-label">年限合计</text>
<text class="item-value">{{ item.content?.yearCount || 0 }}</text>
</view>
<view class="info-line"></view>
<view class="info-item">
<text class="item-label">新会员</text>
<text class="item-value">{{ item.content?.newPersonCount || 0 }}</text>
</view>
<view class="info-line"></view>
<view class="info-item">
<text class="item-label">续费</text>
<text class="item-value">{{ item.content?.renewPersonCount || 0 }}</text>
</view>
</template>
<!-- 级位/段位/越段考试 -->
<template v-else>
<view class="info-item">
<text class="item-label">人数合计</text>
<text class="item-value">{{ item.content?.allPersonCount || 0 }}</text>
</view>
<view class="info-line"></view>
<view class="info-item">
<text class="item-label">新会员</text>
<text class="item-value">{{ item.content?.newPersonCount || 0 }}</text>
</view>
<view class="info-line"></view>
<view class="info-item">
<text class="item-label">续费</text>
<text class="item-value">{{ item.content?.renewPersonCount || 0 }}</text>
</view>
</template>
</view>
<!-- 费用信息 -->
<view class="price-section">
<view class="price-row">
<text class="price-label">费用合计</text>
<text class="price-value">¥{{ (Number(item.price) || 0).toFixed(2) }}</text>
</view>
<view class="price-row">
<text class="price-label">缴费方式</text>
<text class="price-value">民生付</text>
</view>
<view class="price-row">
<text class="price-label">订单状态</text>
<text class="price-value" :class="item.effect == 1 ? 'text-success' : 'text-warning'">
{{ item.effect == 1 ? '已生效' : '未生效' }}
</text>
</view>
</view>
<!-- 按钮组 -->
<view class="btn-group">
<button class="btn btn-invoice" @click="makeInvoice(item)" :disabled="item.invoiceStatus === 1 || item.auditStatus !== 2">
{{ item.invoiceStatus === 1 ? '已开票' : '开票' }}
</button>
<button class="btn btn-detail" @click="viewDetail(item)">查看详情</button>
</view>
</view>
</view>
<!-- 空状态 -->
<view v-else class="empty">
<image class="empty-img" mode="aspectFit" :src="config.baseUrl_api + '/fs/static/nodata.png'"></image>
<text class="empty-text">暂无订单记录</text>
</view>
<!-- 加载/无更多提示 -->
<view class="loading-tip" v-if="loading">加载中...</view>
<view class="no-more" v-if="!loading && !hasMore && list.length > 0">没有更多了</view>
</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import * as api from '@/common/api.js';
import config from '@/config.js'
// 角色Tab配置
const roleTabs = [
{ name: '个人会员', type: '0' },
{ name: '单位会员', type: '1' },
{ name: '级位考试', type: '2' },
{ name: '段位考试', type: '3' },
{ name: '越段考试', type: '4' }
];
// 订单Tab配置(与myCenter/order.vue一致)
const orderTabs = [
{ name: '全部', type: '' },
{ name: '待缴费', type: '0' },
{ name: '缴费成功', type: '1' },
{ name: '已取消', type: '2' }
];
const currentRoleTab = ref(0);
const currentTab = ref(0);
const list = ref([]);
const loading = ref(false);
const hasMore = ref(true);
const pageNum = ref(1);
const pageSize = ref(10);
// 查询参数
const queryParams = computed(() => ({
pageNum: pageNum.value,
pageSize: pageSize.value,
type: roleTabs[currentRoleTab.value].type,
queryType: '1',
payStatus: orderTabs[currentTab.value].type
}));
onLoad((option) => {
if (option.type) {
const typeIndex = roleTabs.findIndex(tab => tab.type === option.type);
if (typeIndex !== -1) {
currentRoleTab.value = typeIndex;
}
}
initData();
});
onMounted(() => {
initData();
});
// 切换角色Tab
const switchRoleTab = (index) => {
currentRoleTab.value = index;
pageNum.value = 1;
list.value = [];
hasMore.value = true;
initData();
};
// 切换订单Tab
const switchTab = (index) => {
currentTab.value = index;
pageNum.value = 1;
list.value = [];
hasMore.value = true;
initData();
};
// 上拉加载更多
const loadMore = () => {
console.log("触发上拉加载");
if (loading.value || !hasMore.value) return;
pageNum.value++;
initData();
};
// 获取订单列表
const initData = async () => {
loading.value = true;
try {
const res = await api.orderList(queryParams.value);
console.log("接口返回:", res);
if (!res || !res.rows || res.rows.length === 0) {
hasMore.value = false;
loading.value = false;
return;
}
// 解析content字段
res.rows.forEach(item => {
if (item.content) {
try {
item.content = JSON.parse(item.content);
} catch (e) {
item.content = null;
}
}
});
// 第一页覆盖,后面页数追加
if (pageNum.value === 1) {
list.value = res.rows;
} else {
list.value.push(...res.rows);
}
// 关键修复:只要返回条数 < pageSize 就说明没有更多了
hasMore.value = res.rows.length === pageSize.value;
} catch (e) {
console.error('订单加载异常:', e);
uni.showToast({ title: '加载失败', icon: 'none' });
hasMore.value = false;
} finally {
loading.value = false;
}
};
// 缴费状态文本
const getPayStatusText = (status) => {
const map = { 0: '待缴费', 1: '缴费成功', 2: '订单取消' };
return map[status] || '未知';
};
const getPayStatusClass = (status) => {
const map = { 0: 'pending', 1: 'success', 2: 'danger' };
return map[status] || '';
};
// 审核状态文本
const getAuditStatusText = (status) => {
const map = { 0: '待提交', 1: '审核中', 2: '审核通过', 3: '审核拒绝' };
return map[status] || '未知';
};
const getAuditStatusClass = (status) => {
const map = { 0: 'warning', 1: 'pending', 2: 'success', 3: 'danger' };
return map[status] || '';
};
// 开票
const makeInvoice = (item) => {
if (item.payStatus !== 1 || item.invoiceStatus === 1 || item.auditStatus !== 2) return;
uni.navigateTo({
url: `/pages/invoice/apply?orderId=${item.id}&amount=${item.price}`
});
};
// 查看详情
const viewDetail = (item) => {
uni.navigateTo({
url: `/pages/exam/paymentDetail?orderId=${item.id}`
});
};
</script>
<style lang="scss" scoped>
.order-page {
height: 100vh;
background: #f5f7fa;
display: flex;
flex-direction: column;
}
// 角色Tab栏
.role-tab-bar {
display: flex;
background: linear-gradient(135deg, #1561cb 0%, #1e7de1 100%);
padding: 20rpx 0;
.role-tab-item {
flex: 1;
text-align: center;
font-size: 26rpx;
color: rgba(255, 255, 255, 0.7);
padding: 16rpx 0;
position: relative;
&.active {
color: #fff;
font-weight: 600;
&::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
height: 4rpx;
background: #fff;
border-radius: 2rpx;
}
}
}
}
// 订单Tab栏
.tab-bar {
display: flex;
background: #fff;
border-bottom: 1rpx solid #eee;
flex-shrink: 0;
.tab-item {
flex: 1;
text-align: center;
padding: 24rpx 0;
font-size: 28rpx;
color: #666;
position: relative;
&.active {
color: #e4393c;
font-weight: 500;
&::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 60rpx;
height: 4rpx;
background: linear-gradient(90deg, #FF755A, #F51722);
border-radius: 2rpx;
}
}
}
}
// 滚动列表容器
.order-list-scroll {
flex: 1;
height: auto;
overflow: auto;
}
.order-list {
padding: 20rpx;
}
.order-card {
background: #fff;
margin-bottom: 20rpx;
padding: 24rpx;
border-radius: 12rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
border-top: 6rpx solid transparent;
background-clip: padding-box, border-box;
background-origin: padding-box, border-box;
background-image: linear-gradient(#fff, #fff), linear-gradient(90deg, #FF755A, #F51722);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 20rpx;
margin-bottom: 20rpx;
border-bottom: 1rpx dashed #eee;
.date {
display: flex;
align-items: center;
gap: 8rpx;
.date-text {
font-size: 26rpx;
color: #666;
}
}
.status-tags {
display: flex;
gap: 10rpx;
}
.status-tag {
font-size: 22rpx;
padding: 6rpx 16rpx;
border-radius: 20rpx;
&.success {
background: #e6f7ef;
color: #52c41a;
}
&.danger {
background: #fff1f0;
color: #ff4d4f;
}
&.pending {
background: #f5f5f5;
color: #999;
}
&.warning {
background: #fff7e6;
color: #faad14;
}
&.ml-10 {
margin-left: 10rpx;
}
}
}
.info-row {
display: flex;
align-items: center;
margin-bottom: 16rpx;
font-size: 26rpx;
.label {
color: #999;
flex-shrink: 0;
min-width: 140rpx;
}
.value {
color: #333;
word-break: break-all;
}
}
.info-section {
display: flex;
align-items: center;
background: #f3f6fc;
padding: 16rpx 20rpx;
margin: 16rpx 0;
border-radius: 8rpx;
.info-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
.item-label {
font-size: 24rpx;
color: #999;
}
.item-value {
font-size: 28rpx;
color: #333;
font-weight: 500;
margin-top: 8rpx;
}
}
.info-line {
width: 1rpx;
height: 60rpx;
background: #ddd;
}
}
.price-section {
border-top: 1rpx dashed #eee;
padding-top: 16rpx;
margin-top: 8rpx;
.price-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8rpx 0;
.price-label {
font-size: 26rpx;
color: #333;
}
.price-value {
font-size: 26rpx;
color: #666;
&.text-success {
color: #52c41a;
}
&.text-warning {
color: #faad14;
}
}
}
}
.btn-group {
display: flex;
justify-content: flex-end;
align-items: center;
gap: 16rpx;
margin-top: 20rpx;
padding-top: 20rpx;
border-top: 1rpx solid #f0f0f0;
.btn {
padding: 12rpx 32rpx;
border-radius: 40rpx;
font-size: 24rpx;
line-height: 1.5;
border: none;
background: transparent;
&::after {
border: none;
}
&.btn-invoice {
background: #fff;
color: #e4393c;
border: 1rpx solid #e4393c;
}
&.btn-detail {
background: linear-gradient(90deg, #FF755A, #F51722);
color: #fff;
}
&:disabled {
opacity: 0.5;
}
}
}
.loading-tip,
.no-more {
text-align: center;
padding: 20rpx 0;
color: #999;
font-size: 26rpx;
}
</style>