1
李凌
2025-09-12 0cf2a49d80c8d4ffba2df32f530f498a2c94458e
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
<template>
    <div class="assets">
        <van-field v-model="searchValue" :placeholder="$t('search')" class="assets_search" left-icon="search" />
 
        <div class="assets_1">
            <div class="price_box-tit">{{ $t('总资产估值') }}</div>
 
            <div class="price_box-text assets_money font-bold mt-5 flex justify-center items-end">
                {{ currency.currency_symbol }}{{ forexAssets?.money_contract ?
                    (forexAssets?.money_contract * (currency.rate ?? 0)).toFixed(2) : '0.00' }}
 
                <div class="pricing_jj ml-5">
                    {{ pricing }}
                </div>
                <van-dropdown-menu>
                    <van-dropdown-item v-model="pricing" :options="pricingList" @change="changePricing">
                        <div @click="toPage('/cryptos/exchangeRate')" class="text-center">{{ $t('更多') }}</div>
                    </van-dropdown-item>
                </van-dropdown-menu>
            </div>
 
            <div class="price-bot">
                <div>
                    <div class="price-bot-tit mb-3">{{ $t('ProfitDay') }}</div>
                    <div class="price-bot-text">
                        {{ currency.currency_symbol }}{{
                            forexAssets?.money_contract_profit_today ?
                                (forexAssets?.money_contract_profit_today * (currency.rate ?? 0)).toFixed(2) :
                                '--' }}
                    </div>
                </div>
            </div>
        </div>
 
        <div class="assets_2 flex justify-between items-center">
            <div class="flex justify-center items-center" v-for="i in tabList1" :key="i.key" @click="toPage(i.path)">
                <img :src="i.icon" alt="">
                <span>{{ i.name }}</span>
            </div>
        </div>
 
        <van-collapse v-model="activeNames" class="mt-10">
            <van-collapse-item :title="$t('分布')" name="1">
                <div class="percentage flex just-between items-center">
                    <div :style="`width:${assetObj.capital / (assetObj.capital + assetObj.contract) * 100}%`">
                    </div>
                    <div class="flex-1">
                    </div>
                </div>
                <div class="assets_item flex justify-start items-center mt-14 font-bold">
                    <div class="icon" style="background-color: #8A90FE;"></div>
                    <span class="ml-5 flex-1">{{ $t('资金账户') }}</span>
                    <span class="mr-5">{{ assetObj.capital }}</span>
                    <van-icon name="arrow" />
                </div>
                <div class="assets_item flex justify-start items-center mt-14 font-bold">
                    <div class="icon" style="background-color: #f7b600;"></div>
                    <span class="ml-5 flex-1">{{ $t('交易账户') }}</span>
                    <span class="mr-5">{{ assetObj.contract }}</span>
                    <van-icon name="arrow" />
                </div>
            </van-collapse-item>
        </van-collapse>
 
        <!-- <div class="assets_title">{{ $t('总资产估值') }}</div>
        <div class="assets_money font-bold mt-5 flex justify-start items-end">
            {{ currency.currency_symbol }}{{ forexAssets?.money_contract ?
                (forexAssets?.money_contract * (currency.rate ?? 0)).toFixed(2) : '0.00' }}
 
            <div class="pricing_jj ml-5">
                {{ pricing }}
            </div>
            <van-dropdown-menu>
                <van-dropdown-item v-model="pricing" :options="pricingList" @change="changePricing">
                    <div @click="toPage('/cryptos/exchangeRate')" class="text-center">{{ $t('更多') }}</div>
                </van-dropdown-item>
            </van-dropdown-menu>
        </div>
        <div class="assets_revenue mt-5">
            <span>{{ $t('ProfitDay') }}</span>
            {{ currency.currency_symbol }}{{ forexAssets?.money_contract_profit_today ?
                (forexAssets?.money_contract_profit_today * (currency.rate ?? 0)).toFixed(2) :
                '--' }}
        </div>
 
        <div class="tabbers flex justify-between mt-20 pl-1 pr-1">
            <div class="item" v-for="item in tabList" :key="item.key" @click="toPage(item.path)">
                <img style="width: 100px;" :src="item.icon" alt="">
                <div class="mt-3 text-center">{{ item.name }}</div>
            </div>
        </div>
 
        <van-collapse v-model="activeNames" class="mt-10">
            <van-collapse-item :title="$t('分布')" name="1">
                <div class="percentage flex just-between items-center">
                    <div :style="`width:${assetObj.capital / (assetObj.capital + assetObj.contract) * 100}%`">
                    </div>
                    <div class="flex-1">
                    </div>
                </div>
                <div class="assets_item flex justify-start items-center mt-14 font-bold">
                    <div class="icon" style="background-color: #8A90FE;"></div>
                    <span class="ml-5 flex-1">{{ $t('资金账户') }}</span>
                    <span class="mr-5">{{ assetObj.capital }}</span>
                    <van-icon name="arrow" />
                </div>
                <div class="assets_item flex justify-start items-center mt-14 font-bold">
                    <div class="icon" style="background-color: #f7b600;"></div>
                    <span class="ml-5 flex-1">{{ $t('交易账户') }}</span>
                    <span class="mr-5">{{ assetObj.contract }}</span>
                    <van-icon name="arrow" />
                </div>
            </van-collapse-item>
        </van-collapse>
 
        <div class="assets_item flex font-bold justify-between items-center mt-14 mb-10">
            <span>{{ $t('资产') }}</span>
            <van-icon name="exchange" size="3rem" />
        </div> -->
 
        <div class="assets_3 mt-10">
            <div class="assets_item flex justify-start items-center mb-10 font-bold" v-for="item in assetListCopy"
                :key="item.id">
                <img :src="`${HOST_URL}/symbol/${item.symbol_data}.png`" />
 
                <span class="ml-5 flex-1">{{ item.symbol_data.toUpperCase() }}/USDT</span>
 
                <div class="mr-3">
                    <!-- <div class="text-right">0</div>
                <div class="assets_item_light text-right">0.00</div> -->
                    <div class="text-right" v-if="item.symbol == 'btc'">
                        {{ item.volume ? Number(item.volume).toFixed(8) : '0.0' }}
                    </div>
                    <div class="text-right" v-else-if="item.symbol == 'eth'">
                        {{ item.volume ? Number(item.volume).toFixed(8) : '0.0' }}
                    </div>
                    <div class="text-right" v-else-if="item.symbol == 'usdt'">
                        {{ item.volume ? Number(item.volume).toFixed(2) : '0.0' }}
                    </div>
                    <div class="text-right" v-else>
                        {{ item.volume ? Number(item.volume).toFixed(8) : '0.0' }}
                    </div>
                    <div class="assets_item_light text-right">
                        ≈{{ currency.currency_symbol }}
                        {{ item.usdt ? Number(item.usdt).toFixed(2) : '0.0' }}
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
 
<script setup>
import { ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from 'vue-router';
import { _getExchangeRate } from '@/service/cryptos.api'
import { _exchangerateuserconfig } from "@/service/trade.api";
import store from '@/store/store'
import { useStore } from "vuex"
import {
    _getContractBySymbolType
} from "@/service/etf.api";
import { SET_CURRENCY } from "@/store/const.store";
import { _getassets } from "@/service/user.api.js";
import { _getAllWallet } from '@/service/fund.api';
import { HOST_URL } from '@/config';
 
const router = useRouter()
const { t } = useI18n()
const activeNames = ref(['1'])
const { dispatch } = useStore();
 
const tabList = [
    { key: 1, name: t('充值'), icon: new URL('@/assets/imgs/assets/chonbi.png', import.meta.url), path: '/cryptos/recharge/rechargeList?isForeign=true' },
    { key: 2, name: t('提现'), icon: new URL('@/assets/imgs/assets/tibi.png', import.meta.url), path: '/cryptos/Withdraw/withdrawPage' },
    { key: 3, name: t('划转'), icon: new URL('@/assets/imgs/assets/huazhuan.png', import.meta.url), path: '/my/transfer' },
    { key: 4, name: t('账单'), icon: new URL('@/assets/imgs/assets/zd.png', import.meta.url), path: '/cryptos/accountChange' },
]
 
const tabList1 = [
    { key: 1, name: t('充值'), icon: new URL('@/assets/imgs/assets/cz.png', import.meta.url), path: '/cryptos/recharge/rechargeList?isForeign=true' },
    { key: 2, name: t('提现'), icon: new URL('@/assets/imgs/assets/tx.png', import.meta.url), path: '/cryptos/Withdraw/withdrawPage' },
    { key: 3, name: t('划转'), icon: new URL('@/assets/imgs/assets/hz.png', import.meta.url), path: '/my/transfer' },
]
 
// 计价切换
const pricing = ref('')
const pricingList = [
    { text: 'USD', value: 'USD', key: 'USD_in' },
    { text: 'EUR', value: 'EUR', key: 'EUR_in' },
    { text: 'JPY', value: 'JPY', key: 'JPY_in' },
]
const changePricing = (e) => {
    let item = pricingList.find((item) => item.value == e)
 
    _exchangerateuserconfig({ rateId: item.key }).then((res) => {
        dispatch(`home/${SET_CURRENCY}`)
        getCurrency()
        getContractBySymbolType()
    })
}
 
// 跳转页面
const toPage = (path) => {
    if (!path) return
    router.push(path)
}
 
// 资产信息获取
const currency = ref({})
const forexAssets = ref({})
const symbolType = ref('cryptos') //默认etf
const getCurrency = async () => {
    _getExchangeRate({
        token: store.state.user.userInfo.token
    }).then(res => {
        currency.value = res
        pricing.value = res.currency
    }).catch(err => Promise.reject(err))
}
const getContractBySymbolType = () => {
    _getContractBySymbolType(symbolType.value)
        .then(res => {
            forexAssets.value = res
        })
}
const assetObj = ref({})
const getassets = () => { // 获取资产
    _getassets().then(res => {
        assetObj.value = res
    })
}
 
// 获取资产列表
const assetList = ref([])
const assetListCopy = ref([])
const getList = () => {
    _getAllWallet({
        symbolType: 'cryptos'
    }).then((res) => {
        assetList.value = res.extends
        assetListCopy.value = res.extends
        // console.log("资产列表", assetList.value);
    });
}
 
// 资产列表筛选
const searchValue = ref('')
watch(searchValue, (newVal) => {
    assetListCopy.value = assetList.value.filter(item => item.name.toLowerCase().includes(newVal.trim().toLowerCase()))
})
 
 
getList()
getassets()
getCurrency()
getContractBySymbolType()
</script>
 
<style lang="scss" scoped>
.assets {
    min-height: 100vh;
    padding: 2.8rem 2rem 10rem 2rem;
    color: $text_color;
 
    :deep(.van-cell) {
        padding-left: 0;
        padding-right: 0;
    }
 
    :deep(.van-cell:after) {
        display: none;
    }
 
    :deep(.van-collapse-item__content) {
        padding-left: 0;
        padding-right: 0;
    }
 
    :deep(.van-cell__title) {
        font-size: 2.1rem;
        font-weight: 600;
    }
 
    .assets_search {
        background-color: $input_background;
        width: 100%;
        border-radius: 2.5rem;
        padding: .5rem 2rem;
    }
 
    .assets_1 {
        background: url('@/assets/image/assets-center/as_bg.png');
        background-size: 100% 100%;
        padding: 2rem 2rem 2.375rem;
        margin: 2.5rem 0 5rem 0;
        border-radius: 1.125rem;
 
        .price_box-tit {
            font-size: 2.2rem;
            margin-bottom: 1.4rem;
            display: flex;
            justify-content: center;
        }
 
        .price_box-text {
            margin-bottom: 1.4rem;
            font-size: 3.2rem;
        }
 
        .price-bot {
            display: flex;
            justify-content: space-around;
            background: rgba(0, 0, 0, .4);
            border-radius: .75rem;
            padding: .75rem;
 
            .price-bot-tit {
                text-align: center;
                font-size: 2rem;
            }
 
            .price-bot-text {
                font-weight: 500;
                color: #fb7171;
                font-size: 3.2rem;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
            }
        }
    }
 
    .assets_2 {
        margin-bottom: 2.2rem;
        // padding: 0 1rem;
 
        &>div {
            width: 14.625rem;
            height: 5rem;
            background-color: $input_background;
            font-size: 1.6562rem;
            border-radius: .55rem;
 
            img {
                width: 2.5rem;
                height: 2.5rem;
                margin-right: 1.375rem;
            }
        }
    }
 
    .assets_3 {
        background-color: $input_background;
        width: 100%;
        background: #212121;
        border-radius: 3rem;
        padding: 2.7rem;
        box-sizing: border-box;
    }
 
    .assets_title {
        font-size: 2.1rem;
    }
 
    .assets_money {
        color: $text_color3;
        font-size: 3.4rem;
 
        .pricing_jj {
            font-size: 1.6rem;
            margin-right: -8px;
        }
 
        :deep(.van-dropdown-menu__bar) {
            height: auto;
            box-shadow: none;
        }
 
        :deep(.van-dropdown-menu__title--down:after) {
            margin-top: -14px !important;
        }
 
        :deep(.van-dropdown-menu__title:after) {
            margin-top: -16px;
        }
 
        :deep(.van-ellipsis) {
            display: none;
        }
 
        :deep(.van-popup--top) {
            padding: 10px 20px;
            font-size: 2rem;
        }
    }
 
    .assets_revenue {
        font-size: 2rem;
        color: $text_color3;
        font-weight: 600;
 
        span {
            color: $text_color3;
            text-decoration: underline dotted;
            font-weight: 400;
        }
    }
 
    .tabbers {
        .item {
            $item_width: 8.3rem;
            width: $item_width;
            font-size: 1.8rem;
            color: $text_color3;
 
            img {
                height: $item_width;
                border-radius: 50%;
            }
        }
    }
 
    .percentage {
        div {
            height: 1rem;
            border-radius: 0.5rem;
        }
 
        &>div:last-child {
            background: $bg_yellow;
        }
 
        &>div:first-child {
            background: #8A90FE;
            margin-right: 0.2rem;
        }
    }
 
    .assets_item {
        color: $text_color3;
        font-size: 2.1rem;
        padding: 1.5rem 0;
        border-bottom: #555 solid 1px;
 
        .icon {
            width: 1.8rem;
            height: 1.8rem;
            border-radius: 50%;
            background: $icon-bg;
        }
 
        img {
            width: 2.8rem;
            height: 2.8rem;
            border-radius: 50%;
        }
 
        .assets_item_light {
            color: $text_color3;
            font-weight: 300;
        }
    }
}
</style>