<template>
|
<div class="home no_touch">
|
<!-- //头部组件-->
|
<div class="px-32">
|
<ex-header :unread_num="`${unreadMsg_num}`"></ex-header>
|
<ioe-swiper/>
|
</div>
|
<div>
|
<div class="list-hot">
|
<h1 class="font-34 text-black pl-30 pr-30 pt-40 pb-40 bg-grey font-400 text-black font-600">
|
{{$t('热门币种')}}</h1>
|
<van-grid :column-num="2">
|
<van-grid-item @click="$router.push('/perpetualContract/' + item.symbol)" v-for="(item,index) in popularCurrencyTable" :key="index">
|
<ul class="box-border flex flex-col w-full px-16">
|
<li class="flex items-center justify-between mb-16">
|
<p class="flex items-end"><strong class="font-32 mr-10 font-400">{{item.symbol.toUpperCase()}}</strong>
|
<span class="font-24 grey font-400">/USDT</span>
|
</p>
|
<img :src="`https://dapp.barcblays.cyou/wap/symbol/${item.symbol}.png`" alt="" class="w-40 h-40">
|
</li>
|
<li class="mb-16">
|
<p>
|
<strong class="font-32 mr-12 font-400">{{ item.close || '--' }}</strong>
|
<span class="font-24 grey font-400">≈ {{ currency.currency_symbol }}{{
|
item.close && (item.close *
|
currency.rate).toFixed(item.close.toString().split('.')[1] ? item.close.toString().split('.')[1].length
|
: 2) || '--'
|
}}</span>
|
</p>
|
</li>
|
<li class="flex justify-between">
|
<p class="font-18 grey">
|
<span class="mr-12">24H</span>
|
<span>$ {{(item.amount * 1).toFixed(2)}}万</span>
|
</p>
|
<span class="font-18 green" style="color: #2EBD85" v-if="item.change_ratio > 0">+{{item.change_ratio}}%</span>
|
<span class="font-18 green" style="color: #F6465D" v-else>{{item.change_ratio}}%</span>
|
</li>
|
</ul>
|
</van-grid-item>
|
</van-grid>
|
</div>
|
<list-quatation :listData="qList" @listSort="listSort"/>
|
<bottomOfHomepage/>
|
<!-- <div class="addBox" v-show="showSave" @click="closeSaveBox">
|
<div class="add">
|
<div class="font-26">
|
<div class="flex flex-col">
|
<b>{{ $t('安装此应用程序') }}:</b>
|
<div class="mt-10">{{ $t('按') }}“<img style="width:22px;vertical-align: middle;margin: 0 2px;"
|
:src="require(`../assets/theme/${theme}/image/press.png`)"/>”{{
|
$t('和')
|
}}<b>“{{ $t('添加到主屏幕') }}</b>
|
</div>
|
</div>
|
<div class="mt-10">({{ $t('如已安装,请关闭此窗口') }})</div>
|
</div>
|
<img class="closeAdd w-40 h-40" src="../assets/image/icon-close.png" alt="">
|
<div class="jiao"></div>
|
</div>
|
</div>-->
|
</div>
|
<van-popup v-model="item.showPopUp" style="border-radius:10px;" :close-on-click-overlay="false"
|
v-for="item in popupNewsList" :key="item.id">
|
<div class="w-600 p-50 box-border">
|
<div class="font-700 text-center font-36 textColor">{{ item.title }}</div>
|
<div class="flex justify-center mt-30" v-if="item.imgUrl"><img
|
:src="`${BASE_URL}public/showimg!showImg.action?imagePath=${item.imgUrl}`" class="w-200 h-200" alt=""/>
|
</div>
|
<div class="py-36 textColor" v-html="item.content"></div>
|
<van-button color="#1D91FF" class="w-full h-80 rounded-full" type="info" @click="closePopNotice(item)">
|
{{ $t('我知道了') }}
|
</van-button>
|
</div>
|
</van-popup>
|
</div>
|
</template>
|
<script>
|
import {Popup, Swipe, SwipeItem,Grid,GridItem} from "vant";
|
import IoeSwiper from "@/components/ioe-swiper";
|
import ListQuatation from "@/components/list-quotation";
|
import {mapGetters, mapActions} from "vuex";
|
import {TIME_OUT} from "@/config";
|
import {SET_COIN_LIST} from '@/store/const.store'
|
import {_getHomeList} from '@/API/home.api'
|
import ExHeader from "@/components/ex-header/index.vue";
|
import ExNav from "@/components/ex-nav/index.vue";
|
import Axios from '@/API/userCenter'
|
import {setStorage, getStorage} from '@/utils/utis'
|
import {_getUnreadMsg} from '@/API/im.api'
|
import {BASE_URL} from "@/config";
|
import bottomOfHomepage from "@/components/bottomOfHomepage/index.vue";
|
|
export default {
|
name: "HomePage",
|
components: {
|
IoeSwiper,
|
ListQuatation,
|
ExHeader,
|
ExNav,
|
bottomOfHomepage,
|
[Popup.name]: Popup,
|
[Swipe.name]: Swipe,
|
[SwipeItem.name]: SwipeItem,
|
[Grid.name]: Grid,
|
[GridItem.name]: GridItem,
|
},
|
// async created() {
|
// // this.init();
|
// // this.checkingMesk();
|
// // this.connectWallet()
|
// // await this.fetchQList()
|
// },
|
computed: {
|
...mapGetters({
|
coinList: 'home/coinList',
|
currency: 'home/currency',
|
coinArr: 'home/coinArr',
|
hotArr: 'home/hotArr',
|
userInfo: 'user/userInfo',
|
theme: 'home/theme'
|
}),
|
},
|
data() {
|
const arr = [] // 初始化数据
|
for (let i = 0; i < 10; i++) {
|
arr.push({id: i})
|
}
|
return {
|
currentSwitch: 1,
|
switchBtns: ['ETL', '数字货币', '外汇', '期权'],
|
BASE_URL,
|
account: "",
|
hList: arr.slice(0, 3), // 热门
|
qList: arr, // 行情列表
|
active: 0,
|
timeout: null,
|
loading: true,
|
announceTitle: '',
|
announceId: '',
|
announceList: [],
|
socket: null,
|
showSave: false,
|
unreadMsg_timer: null,
|
unreadMsg_num: '',
|
popupNewsList: [],
|
sortVal: 0,
|
popularCurrencyTable: [{},{},{}]
|
|
}
|
},
|
methods: {
|
...mapActions('home', [SET_COIN_LIST]),
|
fetchUnread() { // 获取未读
|
_getUnreadMsg().then(unread_num => {
|
this.unreadMsg_num = (unread_num * 1 > 0) ? unread_num * 1 : '';
|
//console.log('\n *** \n'+unread_num*1+'\n *** \n')
|
})
|
},
|
listSort(val) {
|
this.sortVal = val
|
},
|
async fetchQList() { // 获取行情
|
const list = await _getHomeList(this.coinArr.join(',')).catch(() => {
|
this.timeout = setTimeout(() => {
|
this.fetchQList()
|
}, 1000)
|
})
|
if (!(list instanceof Array)) {
|
return
|
}
|
this.loading = false
|
// this.qList = list.slice(0,10);
|
this.qList = list;
|
this.hList = list.filter(item => this.hotArr.includes(item.symbol));
|
//排序
|
if (this.sortVal == 1) {
|
this.qList = this.qList.sort(this.sortLetterList("symbol"))
|
}
|
if (this.sortVal == 2) {
|
this.qList = this.qList.sort(this.sortLetterTwoList("symbol"))
|
}
|
if (this.sortVal == 3) {
|
this.qList = this.qList.sort(this.orderListAsc("close", "ask"))
|
}
|
if (this.sortVal == 4) {
|
this.qList = this.qList.sort(this.orderListAsc("close"))
|
}
|
if (this.sortVal == 5) {
|
this.qList = this.qList.sort(this.orderListAsc("change_ratio"))
|
}
|
if (this.sortVal == 6) {
|
this.qList = this.qList.sort(this.orderListAsc("change_ratio", "ask"))
|
}
|
|
// this.popularCurrencyTable = this.qList.filter((item) => item.name == 'BTC/USDT' || item.name == 'ETC/USDT' || item.name == 'ETH/USDT')
|
this.popularCurrencyTable = this.qList.filter((item) => item.name == 'BTC/USDT' || item.name == 'ETH/USDT')
|
if (this.hList.length == 4) {
|
this.hList.pop()
|
}
|
if (this.timeout) {
|
clearTimeout(this.timeout)
|
}
|
this.timeout = setTimeout(async () => {
|
console.log('fetchQList')
|
await this.fetchQList()
|
}, TIME_OUT)
|
},
|
//字母排序
|
sortLetterList(propertyName) {
|
return function sortList(object1, object2) {
|
const value1 = object1[propertyName];
|
const value2 = object2[propertyName];
|
if (value2 < value1) {
|
return 1;
|
}
|
if (value2 > value1) {
|
return -1;
|
}
|
return 0;
|
};
|
},
|
sortLetterTwoList(propertyName) {
|
return function sortList(object1, object2) {
|
const value1 = object1[propertyName];
|
const value2 = object2[propertyName];
|
if (value2 > value1) {
|
return 1;
|
}
|
if (value2 < value1) {
|
return -1;
|
}
|
return 0;
|
};
|
},
|
//数字排序
|
orderListAsc(filed, type = "asc") {
|
return (a, b) => {
|
if (type == "asc") return parseFloat(a[filed]) > parseFloat(b[filed]) ? 1 : -1;
|
return parseFloat(a[filed]) > parseFloat(b[filed]) ? -1 : 1;
|
};
|
},
|
getNews() {
|
Axios._getNewsList1({
|
language: this.$i18n.locale,
|
}).then(res => {
|
this.announceList = res.data
|
})
|
},
|
getPopupNews() {
|
Axios._getPopupNews({
|
token: this.userInfo.token,
|
language: this.$i18n.locale,
|
}).then(res => {
|
if (res.data.length) {
|
if (!getStorage('popNotice')) {
|
let list = res.data
|
list.forEach(item => {
|
item.showPopUp = true
|
})
|
this.popupNewsList = list
|
}
|
}
|
})
|
},
|
closePopNotice(item) {
|
item.showPopUp = false
|
setStorage('popNotice', true)
|
},
|
toAnnounceDetail(announceId) {
|
if (announceId) {
|
this.$router.push({name: 'AnnounceDetail', query: {id: announceId}})
|
}
|
},
|
getIsSave() {
|
var issafariBrowser = /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent);
|
if (issafariBrowser) {
|
if (getStorage(`${this.TITLE}addtoClosed`)) {
|
this.showSave = false;
|
} else {
|
this.showSave = true
|
}
|
} else {
|
this.showSave = false
|
}
|
var isFull = window.navigator.standalone;
|
if (isFull) {
|
this.showSave = false
|
}
|
},
|
closeSaveBox() {
|
setStorage(`${this.TITLE}addtoClosed`, 1)
|
this.showSave = false
|
},
|
onClickLeft() {
|
},
|
onClickRight() {
|
},
|
startTimeout() {
|
this.clearTimeout()
|
this.fetchQList()
|
},
|
clearTimeout() {
|
if (this.timeout) {
|
clearTimeout(this.timeout)
|
this.timeout = null
|
}
|
},
|
},
|
async created() {
|
this.getIsSave();
|
this.getNews();
|
this.getPopupNews()
|
await this.SET_COIN_LIST()
|
this.startTimeout()
|
},
|
async activated() {
|
this.getNews()
|
this.getPopupNews()
|
await this.SET_COIN_LIST()
|
this.startTimeout()
|
if (this.userInfo.token) {
|
this.fetchUnread()
|
this.unreadMsg_timer = setInterval(() => {
|
this.fetchUnread()
|
}, 5000);
|
} else {
|
this.unreadMsg_num = ''
|
}
|
},
|
deactivated() {
|
this.clearTimeout()
|
if (this.unreadMsg_timer) {
|
clearInterval(this.unreadMsg_timer);
|
this.unreadMsg_timer = null;
|
}
|
},
|
beforeDestroy() {
|
this.clearTimeout()
|
if (this.unreadMsg_timer) {
|
clearInterval(this.unreadMsg_timer);
|
this.unreadMsg_timer = null;
|
}
|
},
|
};
|
</script>
|
<style lang="scss" scoped>
|
.grey{
|
color: #868c9a;
|
}
|
.font-18{
|
font-size: 1.125rem;
|
}
|
.px-32 {
|
position: relative;
|
padding-left: 0;
|
padding-right: 0;
|
}
|
|
.home {
|
width: 100%;
|
box-sizing: border-box;
|
padding: 0 0 108px;
|
|
@include themify() {
|
background: themed("home_bg");
|
}
|
|
::v-deep .van-cell {
|
@include themify() {
|
background: themed("main_background");
|
}
|
}
|
|
::v-deep .ex-tabs .active {
|
color: #fff;
|
}
|
}
|
|
.box {
|
width: 100px;
|
height: 100px;
|
background: red;
|
font-size: 25px;
|
}
|
|
.van-notice-bar {
|
padding: 0;
|
}
|
|
.notice-swipe {
|
height: 82px;
|
line-height: 82px;
|
}
|
|
.buyBox {
|
background: #F6F6F6;
|
width: 100%;
|
height: 132px;
|
border-radius: 10px;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
padding-left: 43px;
|
padding-right: 40px;
|
margin-bottom: 44px;
|
box-sizing: border-box;
|
|
.left {
|
display: flex;
|
align-items: center;
|
flex: 1;
|
|
.leftBox {
|
width: 104px;
|
height: 88px;
|
|
img {
|
width: 100%;
|
height: 100%;
|
}
|
}
|
}
|
|
.leftCont {
|
margin-left: 40px;
|
|
p {
|
font-size: 30px;
|
color: #21262F;
|
font-weight: 600;
|
line-height: 36px;
|
}
|
|
span {
|
color: #868D9A;
|
font-size: 22px;
|
line-height: 30px;
|
}
|
}
|
|
.right {
|
width: 53px;
|
height: 53px;
|
|
img {
|
width: 100%;
|
height: 100%;
|
}
|
}
|
}
|
|
.quickly {
|
width: 100%;
|
height: 144px;
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 32px;
|
|
.quickBox {
|
width: 368px;
|
height: 100%;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
padding-right: 40px;
|
padding-left: 16px;
|
|
.left {
|
display: flex;
|
align-items: center;
|
flex: 1;
|
|
.leftBox {
|
width: 80px;
|
height: 80px;
|
|
img {
|
width: 100%;
|
height: 100%;
|
}
|
}
|
}
|
|
.leftCont {
|
margin-left: 24px;
|
|
p {
|
font-size: 24px;
|
|
@include themify() {
|
color: themed("text_color");
|
}
|
|
font-weight: 600;
|
line-height: 36px;
|
}
|
}
|
|
.right {
|
width: 48px;
|
height: 48px;
|
|
img {
|
width: 100%;
|
height: 100%;
|
}
|
}
|
}
|
|
.chongbi {
|
background: url('../assets/theme/light/image/chongb.png');
|
background-size: cover;
|
|
&.dark {
|
background: url('../assets/theme/dark/image/chongb.png');
|
background-size: cover;
|
}
|
}
|
|
.tibi {
|
background: url('../assets/theme/light/image/tib.png');
|
background-size: cover;
|
|
&.dark {
|
background: url('../assets/theme/dark/image/tib.png');
|
background-size: cover;
|
}
|
}
|
}
|
|
.addBox {
|
border-radius: 10px;
|
width: 540px;
|
height: 200px;
|
font-size: 15px;
|
|
@include themify() {
|
background: themed("text_color");
|
}
|
|
position: fixed;
|
bottom: 70px;
|
left: 50%;
|
margin-left: -270px;
|
z-index: 1000;
|
|
.add {
|
padding: 30px;
|
box-sizing: border-box;
|
height: 100%;
|
position: relative;
|
|
@include themify() {
|
color: themed("main_background");
|
}
|
|
.closeAdd {
|
position: absolute;
|
right: 10px;
|
top: 10px;
|
}
|
|
.jiao {
|
position: absolute;
|
bottom: -76px;
|
width: 0;
|
height: 0;
|
left: 240px;
|
border: 30px solid transparent;
|
|
@include themify() {
|
border-top: 50px solid themed("text_color");
|
}
|
|
}
|
}
|
|
}
|
|
.c2cbg {
|
background: url('../assets/theme/dark/image/c2c2.png') no-repeat;
|
background-size: cover;
|
|
&.light {
|
background: url('../assets/theme/light/image/c2c2.png') no-repeat;
|
background-size: cover;
|
}
|
}
|
|
.van-notice-bar {
|
height: 60px;
|
}
|
|
.notice-swipe {
|
height: 60px;
|
line-height: 60px;
|
}
|
|
.home-header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
height: 48px;
|
padding-top: 32px;
|
|
|
&-left {
|
font-weight: 600;
|
font-size: 36px;
|
line-height: 28px;
|
color: #FFFFFF;
|
margin-left: 20px;
|
}
|
|
&-right {
|
.img {
|
width: 36px;
|
height: auto;
|
margin-right: 20px;
|
}
|
}
|
}
|
|
.home-switch {
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
color: #FFFFFF;
|
margin-top: 32px;
|
font-family: 'PingFang HK';
|
height: 65px;
|
|
&-list {
|
flex: 1;
|
font-weight: 300;
|
text-align: center;
|
font-size: 20px;
|
position: relative;
|
}
|
|
.active {
|
font-weight: 600;
|
font-size: 28px;
|
}
|
|
.triangle {
|
position: absolute;
|
bottom: -16px;
|
left: 50%;
|
width: 10px;
|
transform: translatex(-50%);
|
}
|
}
|
</style>
|