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
<script setup>
import { ref, watch } from 'vue'
import request from '@/utils/request'
const route = useRoute()
// 响应式数据
const list = ref([])
const pageSize = ref(10)
const pageNum = ref(1)
const total = ref(0)
const finished = ref(false)
const loading = ref(false)
const emptyTipsShow = ref(false)
const userInfo = ref(JSON.parse(sessionStorage.getItem('userInfo')))
// 下拉选项
const range = ref([
{ text: "结算收益", value: 'q15' },
{ text: "结算余额", value: 'q1' },
])
// 获取路由参数中的tab
const active = ref(Number(route.query.tab) || 'q15')
// 重置列表状态
const resetList = () => {
list.value = []
pageNum.value = 1
finished.value = false
loading.value = false
total.value = 0
emptyTipsShow.value = false
}
watch(active, () => {
resetList()
})
const getList = async () => {
try {
const data = {
walletCode: active.value,
beginDate: "",
userId: userInfo.value.sysUser.id
}
const res = await request.get(`/business/businessWalletDetail/list?pageNum=${pageNum.value}&pageSize=${pageSize.value}`,{params:data})
if (res.code === 200) {
let result = res.result
list.value = [...list.value, ...(result.records || [])]
total.value = result.total || 0
if (list.value.length >= total.value) {
finished.value = true
} else {
pageNum.value++
}
} else {
showFailToast(res.msg || '加载失败')
finished.value = true
}
} catch (error) {
console.error('获取列表失败:', error)
showFailToast('加载失败,请重试')
} finally {
loading.value = false
}
}
// Tab 点击处理
const handleClick = (item) => {
if (active.value === item.value) return
active.value = item.value
resetList()
}
</script>
<template>
<div class="wallet-detail">
<!-- Tabs -->
<var-tabs v-model:active="active" class="fixed-tabs">
<var-tab v-for="item in range" :key="item.value" @click="handleClick(item)">
{{ item.text }}
</var-tab>
</var-tabs>
<!-- List -->
<van-list class="list-container" v-model:loading="loading" :finished="finished" finished-text="没有更多了"
@load="getList">
<div v-for="(item, index) in list" :key="index" class="detail-item">
<!-- 头部信息 -->
<div class="item-header">
<div class="type-info">
<span class="type-text">
{{ item.changeNote }}
</span>
</div>
<div class="amount" :class="{ negative: item.type === '2' }">
{{ item.tradeType === '1' ? '+' : '-' }}{{ item.changeAmount }}元
</div>
</div>
<!-- 交易信息 -->
<div class="item-content">
<div class="transaction-info">{{ item.createTime }}</div>
<div class="balance">
剩余:{{ item.afterChangeAmount }}{{ item.balanceType === 2 || item.balanceType === 1 ? '元' : '' }}
</div>
</div>
<div class="item-footer">
<time>{{ item.time }}</time>
</div>
</div>
</van-list>
</div>
</template>
<style lang="scss" scoped>
.wallet-detail {
height: calc(100vh - 54px);
background: #fff;
font-family: pingfang;
overflow-y: hidden;
.fixed-tabs {
position: fixed;
top: 52px;
left: 0;
right: 0;
z-index: 10;
background: #fff;
}
.list-container {
margin-top: 50px;
height: calc(100vh - 100px);
overflow-y: auto;
padding: 0 15px;
}
.detail-item {
padding: 15px;
border-bottom: 1px solid #eee;
.item-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
.type-text {
font-size: 14px;
color: #333;
}
.amount {
font-size: 14px;
color: #f44336;
&.negative {
color: #4caf50;
}
}
}
.item-content {
display: flex;
justify-content: space-between;
font-size: 13px;
color: #666;
margin-bottom: 5px;
.processing {
color: #ff9800;
}
.success {
color: #4caf50;
}
.failed {
color: #f44336;
}
}
.item-footer {
font-size: 12px;
color: #999;
}
}
.loading-text,
.finished-text {
padding: 15px 0;
text-align: center;
color: #999;
font-size: 14px;
}
.empty-tips {
text-align: center;
padding: 100px 0;
color: #999;
font-size: 14px;
}
}
</style>