123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- <template>
- <view class="container">
- <!-- #ifdef APP-PLUS -->
- <view class="vheight"></view>
- <!-- #endif -->
- <view class="flex" style="justify-content: space-between;padding: 20rpx 30rpx;">
- <image src="../../static/icon/user.png" mode="" style="width: 53rpx;height: 53rpx;"
- @click="navto('/pages/user/menu')"></image>
- <!-- <image src="../../static/icon/tz.png" mode="" style="width: 53rpx;height: 53rpx;"></image> -->
- </view>
- <!-- 轮播图 start -->
- <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
- <swiper-item v-for="item in clist" class="carousel-item" @click="bannerNavToUrl(item)">
- <image :src="item" />
- </swiper-item>
- </swiper>
- <!-- 轮播图 end -->
- <!-- 通告欄 start -->
- <u-notice-bar type="none" :more-icon="true" mode="vertical" :list="list" @click="goDetail"
- @getMore="navto('/pages/index/gglist')"></u-notice-bar>
- <!-- 通告欄 end -->
- <!-- 功能盒 start -->
- <view class="gnh-wrap">
- <view class="gnh-top flex">
- <!-- <view class="top-item flex" @click="navto('/pages/index/rg')"> -->
- <view class="top-item flex" @click="jqqd()">
- <image src="../../static/icon/gn-1.png" mode="" class=""></image>
- <view class="">{{ $t('index.rg') }}</view>
- </view>
- <view class="top-item flex" @click="navto('/pages/transaction/cblist')">
- <image src="../../static/icon/gn-2.png" mode="" class=""></image>
- <view class="">{{ $t('index.cb') }}</view>
- </view>
- <view class="top-item flex" @click="navto('/pages/transaction/tblist')">
- <image src="../../static/icon/gn-3.png" mode="" class=""></image>
- <view class="">{{ $t('index.tb') }}</view>
- </view>
- <view class="top-item flex" @click="navTo('/pages/index/language')">
- <image src="../../static/icon/gn-4.png" mode="" class=""></image>
- <view class="">{{ $t('index.yy') }}</view>
- </view>
- <view class="top-item flex" @click="navto('/pages/index/kf')">
- <image src="../../static/icon/gn-5.png" mode="" class=""></image>
- <view class="">{{ $t('index.kf') }}</view>
- </view>
- </view>
- <view class="gnh-btm flex">
- <view class="btm-item" @click="navto('/pages/transaction/transactionDetail?type=BTC-USDT')">
- <view class="btm-item-name">BTC/USDT</view>
- <template v-if="listOBj['BTC-USDT']">
- <view class="btm-item-val"
- :style="{ color: listOBj['BTC-USDT'].dcf > 0 ? '#5ec886' : '#DD3745' }">
- {{ listOBj['BTC-USDT'].last || '--,--' }}
- </view>
- <view class="btm-item-bl"
- :style="{ color: listOBj['BTC-USDT'].dcf > 0 ? '#5ec886' : '#DD3745' }">
- {{ listOBj['BTC-USDT'].dcf || '--,--' }}%
- </view>
- </template>
- </view>
- <view class="btm-item" @click="navto('/pages/transaction/transactionDetail?type=BCH-USDT')">
- <view class="btm-item-name">BCH/USDT</view>
- <template v-if="listOBj['BCH-USDT']">
- <view class="btm-item-val"
- :style="{ color: listOBj['BCH-USDT'].dcf > 0 ? '#5ec886' : '#DD3745' }">
- {{ listOBj['BCH-USDT'].last || '--,--' }}
- </view>
- <view class="btm-item-bl"
- :style="{ color: listOBj['BCH-USDT'].dcf > 0 ? '#5ec886' : '#DD3745' }">
- {{ listOBj['BCH-USDT'].dcf || '--,--' }}%
- </view>
- </template>
- </view>
- <view class="btm-item" @click="navto('/pages/transaction/transactionDetail?type=AZB-USDT')" v-if="listOBj['AZB-USDT']">
- <view class="btm-item-name">AZB/USDT</view>
- <template >
- <view class="btm-item-val"
- :style="{ color: listOBj['AZB-USDT'].dcf > 0 ? '#5ec886' : '#DD3745' }">
- {{ listOBj['AZB-USDT'].last || '--,--' }}
- </view>
- <view class="btm-item-bl"
- :style="{ color: listOBj['AZB-USDT'].dcf > 0 ? '#5ec886' : '#DD3745' }">
- {{ listOBj['AZB-USDT'].dcf || '--,--' }}%
- </view>
- </template>
- </view>
- <view class="btm-item" @click="navto('/pages/transaction/transactionDetail?type=AZB-USDT')" v-if="!listOBj['AZB-USDT']">
- <view class="btm-item-name">AZB/USDT</view>
- <template >
- <view class="btm-item-val"
- :style="{ color: listOBj['AZB-USDT'].dcf > 0 ? '#5ec886' : '#DD3745' }">
- {{ listOBj['AZB-USDT'].last || '--,--' }}
- </view>
- <view class="btm-item-bl"
- :style="{ color: listOBj['AZB-USDT'].dcf > 0 ? '#5ec886' : '#DD3745' }">
- {{ listOBj['AZB-USDT'].dcf || '--,--' }}%
- </view>
- </template>
- </view>
- <view class="btm-item" @click="navto('/pages/transaction/transactionDetail?type=ETH-USDT')">
- <view class="btm-item-name">ETH/USDT</view>
- <template v-if="listOBj['ETH-USDT']">
- <view class="btm-item-val"
- :style="{ color: listOBj['ETH-USDT'].dcf > 0 ? '#5ec886' : '#DD3745' }">
- {{ listOBj['ETH-USDT'].last || '--,--' }}
- </view>
- <view class="btm-item-bl"
- :style="{ color: listOBj['ETH-USDT'].dcf > 0 ? '#5ec886' : '#DD3745' }">
- {{ listOBj['ETH-USDT'].dcf || '--,--' }}%
- </view>
- </template>
- </view>
- </view>
- </view>
- <view class="list">
- <view class="list-title flex">
- <view class="title-left">{{ $t('index.jyd') }}</view>
- <view class="title-center">{{ $t('index.zxjg') }}</view>
- <view class="title-right">{{ $t('index.zd') }}</view>
- </view>
- <view class="list-main flex" @click="navto('/pages/transaction/transactionDetail?type=' + index)"
- v-for="(item, index) in listOBj">
- <view class="main-left">{{ item.name }}</view>
- <view class="main-center" :class="{ down: item.dcf > 0, ping: item.dcf == 0 }">
- {{ item.last == 0 ? '--.--' : item.last }}
- </view>
- <view class="main-right">
- <view class="btn" :class="{ down: item.dcf > 0, ping: item.dcf == 0 }">{{ item.dcf }}%</view>
- </view>
- </view>
- </view>
-
- </view>
- </template>
- <script>
- import {
- tradelist,
- gcb,
- version
- } from '@/api/login.js';
- import {
- saveUrl,
- interceptor
- } from '@/utils/loginUtils.js';
- import {
- mapState,
- mapMutations
- } from 'vuex';
- import {
- scoketNew,
- scoketOpen
- } from '@/utils/socket.js';
- import {
- geLevertade,
- gglist
- } from '@/api/index.js';
- export default {
- data() {
- return {
- timer: '',
- clist: {},
- scoket: '',
- instId: 'IOTA-USDT', //请求的产品id
- spList: [], //需要查询的列表
- list: [],
- listInfo: [],
- listOBj: {
- 'BTC-USDT': {},
- 'ETH-USDT': {}
- } //保存实际列表对象
- };
- },
- computed: {
- ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
- },
- onLoad: function(option) {
- if (this.timer) {
- clearTimeout(this.timer);
- this.timer = null;
- }
- uni.setNavigationBarTitle({
- title: this.$t('index.sy')
- });
- },
- onShow: function() {
- this.geLevertade();
- this.tradelist();
- this.getgg();
- this.gcb()
- this.ww()
- },
- onHide() {
- this.closeScoket();
- clearTimeout(this.timer);
- },
- onUnload() {
- clearTimeout(this.timer);
- },
- //下拉刷新
- onPullDownRefresh() {},
- methods: {
- navto(url) {
- console.log(url);
- if (!this.hasLogin) {
- // 保存地址
- saveUrl();
- // 登录拦截
- interceptor();
- } else {
- uni.navigateTo({
- url
- });
- }
- },
- navTo(url) {
- uni.navigateTo({
- url,
- fail() {
- uni.switchTab({
- url
- })
- }
- });
- },
- gcb() {
- let that = this
- gcb().then(res => {
- console.log(res,'1')
- let data = res.data
- that.listOBj[data.name] = data
- that.listOBj[data.name].dcf = (((data.last * 1 - data.sodUtc0 * 1) / (data.sodUtc0 * 1)) * 100)
- .toFixed(2);
- clog
- that.listOBj[data.name].name = data.name.replace('-', '/')
- console.log(that.listOBj, 'that.listOBj')
- if (that.timer) {
- clearTimeout(that.timer)
- that.timer = null
- }
- that.timer = setTimeout(() => {
- that.gcb()
- },5000)
- })
- },
- jqqd() {
- this.$api.msg(this.$t('zxt.jqqd'));
- },
- goDetail(e) {
- uni.navigateTo({
- url: '/pages/index/ggDetail?id=' + this.listInfo[e].id
- });
- },
- getgg() {
- const obj = this;
- gglist({
- page: 1,
- limit: 1000
- }).then(e => {
- obj.listInfo = e.data;
- e.data.forEach(e => {
- obj.list.push(e.title);
- });
- });
- },
- swiperChange() {},
- // 开始请求长连接
- onScoket() {
- const that = this;
- that.scoket = scoketNew('wss://wsaws.okx.com:8443/ws/v5/public');
- that.scoket.scoketOpen().then(res => {
- const requestList = that.spList.map(e => {
- return {
- channel: 'tickers',
- instId: e.coinname.toUpperCase() + '-USDT'
- };
- });
- that.scoket
- .scoketSend({
- op: 'subscribe',
- args: requestList
- })
- .then(res => {
- console.log(res, '发送成功');
- });
- that.scoket.scoketMessage(res => {
- try {
- if (res.data) {
- // console.log(res.data, '123456');
- that.listOBj[res.arg.instId] = res.data[0];
- const item = that.listOBj[res.arg.instId];
- item.dcf = (((item.last * 1 - item.sodUtc0 * 1) / (item.sodUtc0 * 1)) *
- 100).toFixed(2);
- item.name = item.instId.replace('-', '/');
- // res.res.data[0].name = res.arg.instId
- // that.listOBj[res.arg.instId] = res.data[0];
- // that.listOBj[res.arg.instId].dcf = (((res.data[0].last * 1 - res.data[0].sodUtc0 * 1) / (res.data[0].sodUtc0 * 1)) * 100).toFixed(2);
- that.listOBj = Object.assign({}, that.listOBj);
- }
- // console.log(that.listOBj, 'that.listOBj++++++');
- } catch (e) {
- console.log(res, res.data, '报错');
- }
- });
- });
- },
- closeScoket() {
- this.scoket.scoketClose();
- },
- // 获取查询列表
- geLevertade() {
- const that = this;
- geLevertade().then(e => {
- that.spList = e.list;
- // 开启长连接
- that.onScoket();
- });
- },
- // 轮播图跳转
- bannerNavToUrl(item) {
- // #ifdef H5
- console.log(item.wap_url.indexOf('http'), 'banner');
- if (item.wap_url.indexOf('http') >= 0) {
- window.location.href = item.wap_url;
- }
- // #endif
- //测试数据没有写id,用title代替
- uni.navigateTo({
- url: item.wap_url
- });
- },
- tradelist() {
- tradelist().then(res => {
- console.log(res);
- this.clist = res.data.clist;
- this.clist = Object.assign({}, this.clist);
- console.log(this.clist, 'this.clist');
- });
- },
- down() {
- version().then(res => {
- console.log(res)
- window.open(res.data.app)
- })
-
- },
- ww() {
-
- }
- }
- };
- </script>
- <style lang="scss">
- // 顶部轮播图
- .top-swiper {
- margin: auto;
- width: 726rpx;
- height: 273rpx;
- .carousel-item {}
- // margin: 20rpx 0 0;
- image {
- // margin: auto;
- width: 726rpx;
- height: 273rpx;
- }
- }
- .gnh-wrap {
- margin: 20rpx 0;
- width: 750rpx;
- min-height: 315rpx;
- padding-bottom: 20rpx;
- background-color: #fff;
- border-radius: 50rpx 50rpx 0 0;
- .gnh-top {
- justify-content: space-around;
- height: 156rpx;
- .top-item {
- flex-direction: column;
- justify-content: center;
- align-items: center;
- image {
- width: 66rpx;
- height: 75rpx;
- }
- view {
- font-weight: 500;
- color: #525c6e;
- }
- }
- }
- .gnh-btm {
- justify-content: space-around;
- .btm-item {
- width: 33%;
- text-align: center;
- padding-top: 20rpx;
- .btm-item-name {
- font-size: 24rpx;
- font-weight: 500;
- color: #525c6e;
- }
- .btm-item-val {
- font-size: 26rpx;
- font-weight: 500;
- color: #dd3745;
- padding: 20rpx 0;
- }
- .btm-item-bl {
- font-size: 24rpx;
- font-weight: 500;
- color: #dd3745;
- }
- }
- }
- }
- .list {
- background: #ffffff;
- border-top-left-radius: 26rpx;
- border-top-right-radius: 26rpx;
- padding: 40rpx 15rpx 0;
- .list-title {
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #525c6e;
- padding-bottom: 32rpx;
- .title-left {
- text-align: left;
- width: 33%;
- }
- .title-center {
- text-align: center;
- width: 33%;
- }
- .title-right {
- text-align: right;
- width: 33%;
- }
- }
- .list-main {
- padding: 12rpx 0;
- .main-left {
- text-align: left;
- width: 33%;
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #525c6e;
- }
- .main-center {
- text-align: center;
- width: 33%;
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #e15560;
- &.down {
- color: #5ec886;
- }
- &.ping {
- color: #525c6e;
- }
- }
- .main-right {
- text-align: right;
- width: 33%;
- display: flex;
- justify-content: flex-end;
- .btn {
- width: 122rpx;
- height: 63rpx;
- background: #e15562;
- border-radius: 5rpx;
- text-align: center;
- line-height: 63rpx;
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #ffffff;
- &.down {
- background: #5ec886;
- }
- &.ping {
- background: #f6f6f6;
- }
- }
- }
- }
- }
- .vheight {
- height: var(--status-bar-height);
- }
- .wwdown {
- // padding: 20rpx;
- image {
- width: 750rpx;
- }
- margin-bottom: 20rpx;
- font-size: 24rpx;
- text-align: right;
- color: #525c6e;
- }
- </style>
|