<template>
|
<div class="home no_touch">
|
<!-- //头部组件-->
|
<div class="px-32">
|
<ex-header :unread_num="`${unreadMsg_num}`"></ex-header>
|
<ioe-swiper>
|
<van-notice-bar
|
class="font-26 textColors"
|
left-icon="volume-o"
|
:scrollable="false"
|
background="transparent"
|
:text="announceTitle"
|
>
|
<div slot="left-icon" class="pr-13 flex items-center">
|
<img class="w-36 h-36" src="../assets/Horn.png" alt="" />
|
</div>
|
<van-swipe
|
vertical
|
class="notice-swipe"
|
:autoplay="2000"
|
:show-indicators="false"
|
>
|
<van-swipe-item
|
v-for="item in announceList"
|
:key="item.id"
|
@click="toAnnounceDetail(item.id)"
|
>{{ item.title }}</van-swipe-item
|
>
|
</van-swipe>
|
<!-- <div
|
class="ml-20 flex items-center"
|
slot="right-icon"
|
@click.stop="$router.push('/announce')"
|
>
|
<img class="w-36 h-36" src="../assets/more.png" alt="" />
|
</div> -->
|
</van-notice-bar>
|
</ioe-swiper>
|
</div>
|
<div
|
class="pt-40 contRound"
|
style="
|
border-top-left-radius: 30px;
|
border-top-right-radius: 30px;
|
margin: 0 10px;
|
"
|
>
|
<ex-nav></ex-nav>
|
<list-quatation :listData="qList" @listSort="listSort" />
|
<!-- <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>
|
<van-popup
|
v-model="isshow"
|
style="border-radius: 10px"
|
|
>
|
<div class="w-600 p-50 box-border">
|
<div class="font-700 text-center font-36 textColor">
|
提示
|
</div>
|
<div class="flex justify-center " >
|
</div>
|
<div class="py-36 textColor" >此项目均为吉星科技出品认准技术✈️号:
|
<div >商务2:@jixing05</div>
|
<div >商务3: @jixingkj06</div>
|
<div>非我司认准均为骗子,禁止盗用我司演示,谨防受骗上当!</div>
|
</div>
|
|
<van-button
|
color="#1D91FF"
|
class="w-full h-80 rounded-full"
|
type="info"
|
@click="closeclick"
|
>
|
{{ $t("我知道了") }}
|
</van-button>
|
</div>
|
</van-popup>
|
</div>
|
</template>
|
<script>
|
import { Popup, Swipe, SwipeItem } 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";
|
export default {
|
name: "HomePage",
|
components: {
|
IoeSwiper,
|
ListQuatation,
|
ExHeader,
|
ExNav,
|
[Popup.name]: Popup,
|
[Swipe.name]: Swipe,
|
[SwipeItem.name]: SwipeItem,
|
},
|
async created() {
|
await this.fetchQList()
|
// this.init();
|
// this.checkingMesk();
|
// this.connectWallet()
|
},
|
computed: {
|
...mapGetters({
|
coinList: "home/coinList",
|
currency: "home/currency",
|
coinArr: "home/coinArr",
|
newcoinArr: "home/newcoinArr",
|
hotArr: "home/hotArr",
|
userInfo: "user/userInfo",
|
theme: "home/theme",
|
}),
|
},
|
data() {
|
const arr = []; // 初始化数据
|
for (let i = 0; i < 10; i++) {
|
arr.push({ id: i });
|
}
|
return {
|
isshow:true,
|
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,
|
};
|
},
|
mounted() {
|
this.NEW_CION_LIST();
|
},
|
methods: {
|
...mapActions("home", [SET_COIN_LIST, "NEW_CION_LIST"]),
|
closeclick(){
|
this.isshow = false
|
},
|
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() {
|
// 获取行情
|
// console.log(this.newcoinArr, "[[[[[]]]]]");
|
// const mainArray = this.coinArr.filter(
|
// (item) => !this.newcoinArr.includes(item)
|
// );
|
|
|
const coins = this.coinList.map((item) => item.symbol);
|
|
const prioritize = ['btc', 'eth']; // 需要优先排序的币种
|
|
// 按照优先级对 coins 数组进行排序
|
const sortedCoins = coins.sort((a, b) => {
|
const aIndex = prioritize.indexOf(a);
|
const bIndex = prioritize.indexOf(b);
|
|
if (aIndex === -1 && bIndex === -1) return 0; // 两者都不在优先级列表中,不做排序
|
if (aIndex === -1) return 1; // b 在优先级列表中,a 不在,b 排在前面
|
if (bIndex === -1) return -1; // a 在优先级列表中,b 不在,a 排在前面
|
return aIndex - bIndex; // 根据优先级排序
|
});
|
|
|
const mainArray = sortedCoins.filter((item) => !this.newcoinArr.includes(item));
|
console.log(mainArray);
|
const list = await _getHomeList(mainArray.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"));
|
}
|
|
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;
|
this.isshow = true
|
});
|
},
|
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.NEW_CION_LIST();
|
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>
|
.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%);
|
}
|
}
|
.textColors {
|
color: #fff !important;
|
}
|
</style>
|