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
<script setup>
import { onMounted, ref, watch } from 'vue'
import request from '@/utils/request'
import AppHeader from '@/components/AppHeader.vue'
// 响应式数据
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 range = ref([
{ text: '银行储蓄金', value: 1 },
{ text: '我的股权', value: 2 },
// { text: "每日分红", value: 3 },
{ text: '银行卡余额', value: 5 },
])
// 添加一个新的 ref 用于 tab 的索引控制
const currentTabIndex = ref(0)
const active = ref(Number(window.location.search.split('=')[1]) || 1)
// 重置列表状态
function resetList() {
list.value = []
pageNum.value = 1
finished.value = false
loading.value = true // 改为 true,避免 van-list 立即触发 load
total.value = 0
emptyTipsShow.value = false
getList() // 直接在重置后调用获取列表
}
async function getList() {
if (loading.value) { // 添加loading检查,避免重复请求
try {
const data = {
balanceType: active.value,
beginDate: '',
}
const res = await request.post(`/ops/walletdetail/list?pageNum=${pageNum.value}&pageSize=${pageSize.value}`, {
...data,
})
if (res.code === 200) {
list.value = [...list.value, ...(res.rows || [])]
total.value = res.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(error.msg || '加载失败,请重试')
}
finally {
loading.value = false
}
}
}
// 初始化时设置正确的 tab 索引
onMounted(() => {
const index = range.value.findIndex(item => item.value === active.value)
currentTabIndex.value = index >= 0 ? index : 0
resetList()
})
// 修改 handleClick
function handleClick(item) {
if (active.value === item.value)
return
active.value = item.value
resetList()
}
</script>
<template>
<AppHeader title="资金明细"/>
<div class="wallet-detail">
<var-tabs v-model:active="currentTabIndex" class="fixed-tabs">
<var-tab v-for="item in range" :key="item.value" @click="handleClick(item)">
{{ item.text }}
</var-tab>
</var-tabs>
<div class="content-wrapper">
<van-list
v-model:loading="loading"
:finished="finished"
finished-text="没有更多了"
:immediate-check="true"
@load="getList"
>
<div v-for="(item, index) in list" :key="index" class="detail-item">
<!-- 头部信息 -->
<div class="item-header">
<div class="type-info">
<div class="amount" :class="{ negative: item.type === '2' }">
{{ item.type === '1' ? '+' : '-' }}{{ item.changeAmount }}
{{ item.balanceType === 2 || item.balanceType === 1 ? '元' : '' }}
</div>
<span class="type-text">
{{ item?.source }}
<!-- {{
item.balanceType == 1 ? '银行储蓄金' :
item.balanceType == 2 ? '我的股权' :
item.balanceType == 3 ? '每日分红' :
item.balanceType == 5 ? '银行卡余额' : ''
}} -->
</span>
</div>
</div>
<!-- 交易信息 -->
<!-- <div class="item-content">
<div class="transaction-info">
<template v-if="item.balanceType && item.bankName">
<div v-if="item.status == '0' || item.status == '1'" class="processing">
审核中
</div>
<div v-else-if="item.status == '2'" class="success">
{{ item.source }}
</div>
<div v-else-if="item.status == '3'" class="failed">
{{ item.source }}
</div>
</template>
<template v-else>
{{ item.source }}
<span v-if="item.bankName">至 {{ item.bankName }}{{ item.bankNum.slice(-4) }}</span>
</template>
</div>
<div class="balance">
剩余:{{ item.amount }}{{ item.balanceType === 2 || item.balanceType === 1 ? '元' : '' }}
</div>
</div> -->
<div class="item-footer">
<time>{{ item.time }}</time>
</div>
</div>
</van-list>
</div>
</div>
</template>
<style lang="scss" scoped>
.wallet-detail {
min-height: 100vh;
background: url('@/static/common/commonbg.png') no-repeat;
background-size: 100% 100%;
font-family: pingfang;
padding-top: 60px;
.fixed-tabs {
position: fixed;
top: 52px;
left: 0;
right: 0;
z-index: 10;
}
.content-wrapper {
margin: 0 10px 0; // 上边距要考虑 fixed-tabs 的高度
background: rgba($color: #fff, $alpha: 0.8);
border-radius: 8px;
height: calc(100vh - 140px); // 减去顶部间距和底部预留空间
overflow-y: auto;
-webkit-overflow-scrolling: touch;
padding: 15px;
margin-top: 50px;
}
.detail-item {
padding: 5px;
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>