<!-- 货币列表 -->
<template>
    <div class="list-item" v-for="(item, index) in props.list" :key="index">
        <div class="item-title">
            <img class="icon" :src="item.chainInfo.iconPath" />
            {{item.chainInfo.chainName}}
        </div>
        <div class="item-detail" @click="selectCurrency(item)">
            <div class="left">
                <img class="icon-currency" :src="item.iconPath" />
                <div class="currency-info">
                    <div class="name">{{ item.currencyCode == 'USD' ? 'USD' : item.tokenSymbol }}</div>
                    <div class="desc">{{ item.currencyCode == 'USD' ? 'Paypal' : item.currencyName }}</div>
                </div>
            </div>
            <div class="right">
                <div class="num">
                    <a-tooltip :title="item.balance">
                        {{ getBit(item.balance) }}
                    </a-tooltip>
                </div>
                <div class="amount" v-if="item.currencyType == 2">
                    <a-tooltip :title="'$'+item.usdEstimateBalance">
                        ${{ getBit(item.usdEstimateBalance) }}
                    </a-tooltip>
                </div>
            </div>
        </div>
    </div>
    
</template>

<script setup>
import { defineProps, defineEmits } from 'vue';
import { getBit } from "@/uilts/help";

let props = defineProps({
    list: {
        type: Array,
        default: [],
    }
})
let emits = defineEmits(['selectCurrency']);
let selectCurrency = (params) => {
    emits('selectCurrency', params);
}
</script>

<style scoped lang="scss">
.list-item {
    .item-title {
        display: flex;
        align-items: center;
        height: 42px;
        padding: 0 10px;
        box-sizing: border-box;
        background: #f7f7f7;
        font-weight: 500;
        font-size: 14px;
        color: #a2a2a2;

        .icon {
            width: 24px;
            height: 24px;
            margin-right: 6px;
        }
    }
    .item-detail {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 20px;
        box-sizing: border-box;
        cursor: pointer;

        .left {
            display: flex;

            .icon-currency {
                width: 24px;
                height: 24px;
                margin-right: 12px;
            }

            .currency-info {
                .name {
                    font-weight: 500;
                    font-size: 15px;
                    margin-bottom: 5px;
                }

                .desc {
                    font-weight: 400;
                    font-size: 12px;
                    color: #a2a2a2;
                }
            }
        }

        .right {
            text-align: right;
            max-width: calc(100% - 150px);
            
            .num, .amount {
                word-break: break-all;
            }

            .num {
                font-weight: 500;
                font-size: 15px;
                margin-bottom: 5px;
            }

            .amount {
                font-weight: 400;
                font-size: 12px;
                color: #a2a2a2;
            }
        }
    }
}
</style>
