<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('货币兑换', 2)">{{ $t('货币兑换') }}</div>
|
<div @click="changeType('外汇交易', 1)">{{ $t('外汇交易') }}</div>
|
</div>
|
</div>
|
</div>
|
|
|
<transition-group :name="type" tag="div">
|
<div>
|
<van-cell v-for="item in listData" :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>
|
import { List, Cell } from 'vant'
|
import { mapGetters, mapActions } from 'vuex'
|
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";
|
// import { useI18n } from "vue-i18n";
|
// const t = useI18n()
|
export default {
|
name: 'ListQuotation',
|
data() {
|
return {
|
fixDate,
|
HOST_URL,
|
active: 0,
|
isTopShow: false,
|
topTitle: this.$t('货币兑换'),
|
topValue: 2,
|
type: 'left' //left 从左往右 right 从有王座
|
}
|
},
|
props: {
|
showMore: {
|
type: Boolean,
|
default: true
|
},
|
listData: {
|
type: Array,
|
default() {
|
return []
|
}
|
},
|
tabActive: {
|
type: Number,
|
default: 0
|
},
|
},
|
computed: {
|
...mapGetters({ currency: 'home/currency' }),
|
},
|
components: {
|
[List.name]: List,
|
[Cell.name]: Cell,
|
ExTabs
|
},
|
mounted() {
|
this.SET_CURRENCY()
|
},
|
methods: {
|
...mapActions('home', [SET_CURRENCY]),
|
changeType(tit, val) {
|
this.topTitle = tit
|
this.topValue = val
|
this.$emit('onfetchQList', val)
|
},
|
toggleDropdown() {
|
if (this.isTopShow) {
|
this.isTopShow = false
|
} else {
|
this.isTopShow = true
|
}
|
},
|
onItemClick(item) {
|
if (this.topValue == 2) { //现货
|
setStorage('symbol', item.symbol)
|
this.$router.push({
|
path: `/cryptos/perpetualContract/${item.symbol}`,
|
query: { selectIndex: 2 }
|
});
|
} else {
|
setStorage('symbol', item.symbol)
|
this.$router.push({
|
path: `/cryptos/trade/${item.symbol}`,
|
});
|
}
|
},
|
handleImage(url) {
|
return new URL(url, import.meta.url).href
|
},
|
onTabs(val) {
|
if (this.active < val) {
|
this.type = 'right'
|
} else {
|
this.type = 'left'
|
}
|
this.active = val
|
if (val == 0) {
|
this.showList = [...this.listData];
|
} else if (val == 1) {
|
this.showList = [...this.listData].sort(this.compare("change_ratio_str", 'up'))
|
} else if (val == 2) {
|
this.showList = [...this.listData].sort(this.compare("change_ratio_str", 'down'))
|
} else if (val == 3) {
|
this.showList = [...this.listData].sort(this.compare("volume", 'up'))
|
}
|
},
|
compare(p, type) { //这是比较函数
|
return function (m, n) {
|
var a = m[p];
|
var b = n[p];
|
if (a == b) {
|
return
|
}
|
if (type == 'up') {
|
return b - a; //升序
|
} else if (type == 'down') {
|
return a - b; //降序
|
} else {
|
return a - b;
|
}
|
}
|
}
|
},
|
watch: {
|
listData() {
|
if (this.active == 0) {
|
this.showList = [...this.listData];
|
} else if (this.active == 1) {
|
this.showList = [...this.listData].sort(this.compare("change_ratio_str", 'up'))
|
} else if (this.active == 2) {
|
this.showList = [...this.listData].sort(this.compare("change_ratio_str", 'down'))
|
} else if (this.active == 3) {
|
this.showList = [...this.listData].sort(this.compare("volume", 'up'))
|
}
|
this.$forceUpdate()
|
}
|
}
|
}
|
</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>
|