<template>
|
<div class="list-quatation">
|
<van-list>
|
<!-- 热门 -->
|
<div class="flex items-end justify-between" style="margin: 14px 0;">
|
<div class="block text-22 font-medium">{{ t('Market') }}</div>
|
<div class="relative text-13" @click="toggleDropdown">
|
<div class="flex px-20 justify-between rounded-full bg-black text-white min-w-140 box-border">
|
<div class="block">{{ t(topTitle) }}</div>
|
<van-icon name="play" style="align-content:center;transform: rotate(90deg);" />
|
</div>
|
<div
|
class="px-16 py-20 bg-black text-white flex flex-col absolute min-w-140 box-border top-25 rounded-11 leading-28"
|
style="z-index:999;margin-top: 0.8rem;" v-show="isTopShow">
|
<div @click="changeType(t('货币兑换'), 2)">{{ t('货币兑换') }}</div>
|
<div @click="changeType(t('外汇交易'), 1)">{{ t('外汇交易') }}</div>
|
</div>
|
</div>
|
</div>
|
|
|
<transition-group :name="type" tag="div">
|
<div>
|
<van-cell v-for="item in showList" :key="item.id" style="background-color: #f0f0f0;margin-bottom: 10px;">
|
<ul class="flex justify-between w-full items-center" @click="onItemClick(item)">
|
<li class="flex items-center left">
|
<img
|
:src="item.symbol ? `${HOST_URL}/symbol/${item.symbol_data}.png` : handleImage('@/assets/loading-default.png')"
|
alt="logo" class="w-72 h-72 mr-16" />
|
<p class="flex flex-col">
|
<span class="flex items-end font-32 flex items-center">
|
<span class="textColor font-600 font-30">{{ item.name || '--'
|
}}</span>
|
</span>
|
<span class="font-24 text-grey text-left">{{ (item.amount * 1).toFixed(2) }}</span>
|
</p>
|
</li>
|
<li class="flex flex-col items-end mid">
|
<p class="textColor font-32 font-600">{{ item.close || '--' }}</p>
|
</li>
|
<li class="right flex items-center justify-end">
|
<p class="w-153 font-31 h-71 text-white border-0 text-center btn"
|
:class="item.change_ratio > 0 ? 'bg-green' : 'bg-red'">
|
{{ item.change_ratio === 0 ? 0 : item.change_ratio }}%
|
</p>
|
</li>
|
</ul>
|
</van-cell>
|
</div>
|
</transition-group>
|
</van-list>
|
</div>
|
</template>
|
<script setup>
|
import { ref, computed, onMounted, watch } from 'vue';
|
import { useStore } from 'vuex';
|
import { useI18n } from 'vue-i18n';
|
import { useRouter } from 'vue-router';
|
import { List, Cell, Icon } from 'vant';
|
import { fixDate, setStorage } from "@/utils";
|
import ExTabs from "@/components/Transform/ex-tabs/index.vue";
|
import { HOST_URL } from '@/config';
|
import { SET_CURRENCY } from "@/store/const.store";
|
|
// 状态定义
|
const isTopShow = ref(false);
|
const topTitle = ref('');
|
const topValue = ref(2);
|
const type = ref('left');
|
const active = ref(0);
|
const showList = ref([]);
|
|
// 依赖注入
|
const store = useStore();
|
const { t } = useI18n();
|
const router = useRouter();
|
|
// Props定义
|
const props = defineProps({
|
showMore: {
|
type: Boolean,
|
default: true
|
},
|
listData: {
|
type: Array,
|
default: () => []
|
},
|
tabActive: {
|
type: Number,
|
default: 0
|
}
|
});
|
|
// Emits定义
|
const emit = defineEmits(['onfetchQList']);
|
|
// 计算属性
|
const currency = computed(() => store.getters['home/currency']);
|
|
// 生命周期
|
onMounted(() => {
|
topTitle.value = t('货币兑换');
|
store.dispatch('home/' + SET_CURRENCY);
|
showList.value = [...props.listData];
|
});
|
|
// 方法定义
|
const changeType = (tit, val) => {
|
topTitle.value = tit;
|
topValue.value = val;
|
emit('onfetchQList', val);
|
};
|
|
const toggleDropdown = () => {
|
isTopShow.value = !isTopShow.value;
|
};
|
|
const onItemClick = (item) => {
|
setStorage('symbol', item.symbol);
|
if (topValue.value === 2) {
|
router.push({
|
path: `/cryptos/perpetualContract/${item.symbol}`,
|
query: { selectIndex: 2 }
|
});
|
} else {
|
router.push({
|
path: `/cryptos/trade/${item.symbol}`
|
});
|
}
|
};
|
|
const handleImage = (url) => {
|
return new URL(url, import.meta.url).href;
|
};
|
|
const onTabs = (val) => {
|
type.value = active.value < val ? 'right' : 'left';
|
active.value = val;
|
sortListData(val);
|
};
|
|
const compare = (p, sortType) => {
|
return (m, n) => {
|
const a = m[p];
|
const b = n[p];
|
if (a === b) return 0;
|
return sortType === 'up' ? b - a : a - b;
|
};
|
};
|
|
const sortListData = (val) => {
|
switch(val) {
|
case 0:
|
showList.value = [...props.listData];
|
break;
|
case 1:
|
showList.value = [...props.listData].sort(compare('change_ratio_str', 'up'));
|
break;
|
case 2:
|
showList.value = [...props.listData].sort(compare('change_ratio_str', 'down'));
|
break;
|
case 3:
|
showList.value = [...props.listData].sort(compare('volume', 'up'));
|
break;
|
}
|
};
|
|
// 监听器
|
watch(
|
() => props.listData,
|
() => {
|
sortListData(active.value);
|
},
|
{ deep: true }
|
);
|
</script>
|
<style lang="scss" scoped>
|
@import "@/assets/init.scss";
|
@import '@/assets/css/deepseek_css_20250625_30ff932.css';
|
|
#cryptos {
|
|
.left-enter-active,
|
.left-leave-active,
|
.right-enter-active,
|
.right-leave-active {
|
will-change: transform;
|
transition: all 250ms;
|
}
|
|
.left-leave-active,
|
.right-leave-active {
|
display: none;
|
}
|
|
.left-enter {
|
opacity: 0;
|
transform: translate3d(-100%, 0, 0);
|
}
|
|
.left-leave {
|
opacity: 0;
|
transform: translate3d(0%, 0, 0)
|
}
|
|
.right-enter {
|
opacity: 0;
|
transform: translate3d(100%, 0, 0);
|
}
|
|
.right-leave {
|
opacity: 0;
|
transform: translate3d(0%, 0, 0)
|
}
|
|
.btn {
|
border-radius: 9px;
|
line-height: 71px;
|
}
|
|
.left {
|
width: 382px
|
}
|
|
.mid {
|
width: 185px;
|
}
|
|
.right {
|
width: 182px;
|
margin-left: 38px;
|
}
|
|
}
|
|
.textColor {
|
color: #242629;
|
}
|
|
.text-grey {
|
// color: #8c8c8c;
|
}
|
|
#cryptos .list-quatation .van-cell {
|
padding: 24px !important;
|
border-radius: 1rem;
|
}
|
|
.list-quatation {
|
margin: 0 20px;
|
}
|
</style>
|