| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764 |
- <template>
- <view class="index">
- <view class="wrap">
- <!-- 头部 -->
- <view class="header">
- <view class="center" v-if="userInfo.id>0">
- <navigator url="/pages/center/index">
- <view class="image">
- <image class="icon" src="/static/icons/circle.png">
- </image>
- <text class="text">T</text>
- </view>
- <view class="user">{{lang.center}}</view>
- </navigator>
- </view>
- <view v-else class="center">
- <navigator url="/pages/login/login">
- <view class="image">
- <image class="icon" src="/static/icons/circle.png">
- </image>
- <text class="text">Go</text>
- </view>
- <view class="user">{{lang.login}}</view>
- </navigator>
- </view>
- <view class="icons">
- <view class="icon-menu" @click="switchLang()">
- <image class="icon locale en" v-if="this.locale == 'zh_cn'" src="../static/icons/en.png"
- mode="">
- </image>
- <image class="icon locale zh-cn" v-else src="../static/icons/zh-cn.png" mode=""></image>
- </view>
- <view class="icon-menu" @click="scan()">
- <image class="icon scan" src="../static/icons/scan.png" mode=""></image>
- </view>
- <view class="icon-menu" @click="gotoPage('/#/pages/chat/newList')">
- <image class="icon custom" src="../static/icons/custom.png" mode=""></image>
- <text v-if="message.custom" class="text"></text>
- </view>
- <view class="icon-menu">
- <image class="icon notice" src="../static/icons/notice.png" mode=""></image>
- <text v-if="message.notice" class="text"></text>
- </view>
- </view>
- </view>
- <!-- 轮播广告 -->
- <view class="u-u-swiper">
- <u-swiper @change="change" :height="290" :list="banners" :title="title" :effect3d="effect3d"
- :indicator-pos="indicatorPos" :mode="mode" :interval="3000" @click="click"></u-swiper>
- </view>
- <!-- 公告 -->
- <view class="notices">
- <view class="info">
- <image class="icon" src="../static/icons/message.png" mode=""></image>
- <view class="list" v-if="notices.length>0">
- <!--
- <u-swiper @change="change" :vertical="true" :height="30" :list="notices" :title="true"
- :effect3d="effect3d" :indicator-pos="indicatorPos" :mode="'none'" :circular="true"
- :interval="3000" @click="click"></u-swiper>
- -->
- <u-notice-bar :type="'none'" :volume-icon="false" mode="vertical" :list="notices">
- </u-notice-bar>
- </view>
- <view class="list" v-else>
- <text>{{lang.no_notice}}</text>
- </view>
- <image class="icon icon-list" src="/static/icons/list.png" mode=""></image>
- </view>
- </view>
- <!-- 菜单 -->
- <u-row class="tool-quick">
- <u-col class="quick-sell" :span="7" :offset="0">
- <image src="/static/icons/quick-bg2.jpeg" class="bg"></image>
- <view class="info">
- <view class="title" @click="gotoPage('/pages/trade/index?type=2')">
- <image class="icon" src="/static/icons/usdt.png" mode=""></image>
- <text class="name">{{lang.quick_sell}}</text>
- <text class="price">¥{{trade.buy_price}}/USDT</text>
- </view>
- <view class="tips" @click="gotoPage('/pages/trade/index?type=2')">
- {{lang.quick_sell_tips}}
- </view>
- <view class="input">
- <input class="input-usdt" type="number" v-model="counts.usdt" @input="countTotal">
- </view>
- <view class="bj" @click="gotoPage('/pages/trade/index?type=2')">
- <view class="bj-info">
- <view class="text">
- {{lang.quick_sell_text}}
- </view>
- <view class="bj-result">
- ¥{{counts.result}}
- </view>
- </view>
- <view class="btn">
- <image class="icon" src="/static/icons/row-right.png" mode=""></image>
- </view>
- </view>
- </view>
- </u-col>
- <u-col class="quick-buy" :span="5" :offset="0">
- <view class="menu" @click="gotoPage('/pages/order/index')">
- <image class="icon" src="/static/icons/list-order.png" mode=""></image>
- <text class="text">{{lang.my_order}}</text>
- <image class="icon right" src="/static/icons/row-right-gray.png" mode=""></image>
- </view>
- <view class="buy" @click="gotoPage('/pages/trade/index?type=1')">
- <view class="buy-text">
- {{lang.buy_utc}}
- </view>
- <view class="buy-tips">
- <text class="text">{{lang.quick_buy_tips}}</text>
- <image class="icon" src="/static/icons/row-right-gray.png" mode=""></image>
- </view>
- <view class="price">
- ¥{{trade.sell_price}}/USDT
- </view>
- </view>
- </u-col>
- </u-row>
- <!-- 实时统计 -->
- <u-row class="counts">
- <u-col class="count order-total" :span="4" :offset="0">
- <view class="name">{{lang.order_total_24}}</view>
- <view class="text">{{trade.total}}</view>
- </u-col>
- <u-col class="count order-count" :span="4" :offset="0">
- <view class="name">{{lang.order_count_24}}</view>
- <view class="text">{{trade.count}}</view>
- </u-col>
- <u-col class="count trade-rate" :span="4" :offset="0">
- <view class="name">24H{{lang.trade_rate}}</view>
- <view class="text">{{trade.rate}}%</view>
- </u-col>
- </u-row>
- </view>
- <!-- 推荐广告 -->
- <view class="advert" v-if="advert">
- <image class="image" :src="v.image" mode="" v-for="(v,k) in advert" :key="k" :title="v.title"
- @click="gotoPage('/pages/trade/index?type=2')"></image>
- </view>
- <!-- 平台价格 -->
- <view class="platform-price">
- <view class="row title">
- <text class="name">{{lang.platform}}</text>
- <text class="price">{{lang.sell_avg}}</text>
- </view>
- <view class="row list-row first">
- <text class="name">{{lang.pay_by_u}}</text>
- <text class="price">¥{{trade.sell_price}}</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- switchLocale
- } from '@/common/checker.js'
- export default {
- data() {
- return {
- title: false,
- mode: 'round',
- mode1: 'round',
- vertical: false,
- indicatorPos: 'bottomCenter',
- effect3d: false,
- // 用户信息
- userInfo: {
- id: 0
- },
- // 轮播
- banners: [],
- advert: [],
- // 交易参数
- trade: {
- buy_price: '0.00',
- sell_price: '0.00',
- total: '0.00',
- count: 0,
- rate: '0.00'
- },
- // 公告
- notices: [],
- // 消息数量
- message: {
- custom: 2,
- notice: 0
- },
- // 比价计算
- counts: {
- usdt: 0,
- result: '0.00',
- },
- timerId: null,
- };
- },
- created() {
- this.getUserInfo();
- this.getIndex();
- uni.setNavigationBarTitle({
- title: this.lang.index_title
- })
- },
- methods: {
- switchLang() {
- let _this = this
- let lang = switchLocale();
- let locale = uni.getStorageSync('locale')
- console.log(locale)
- this.$request.sendToken('/api/lang/switch', {
- locale: locale == 'en' ? 'en' : 'zh-cn'
- }, 'POST').then(res => {
- if (res.success == true) {
- _this.lang = this.lang
- location.reload()
- }
- });
- },
- countTotal() {
- this.counts.result = (this.counts.usdt * this.trade.price).toFixed(2);
- },
- titleChange(index) {
- this.title = index == 0 ? true : false;
- },
- modeChange(index) {
- this.mode = index == 0 ? 'round' : index == 1 ? 'rect' : index == 2 ? 'number' : 'none';
- },
- indicatorPosChange(index) {
- this.indicatorPos = index == 0 ? 'topLeft' : index == 1 ? 'topRight' : index == 2 ? 'bottomLeft' : index ==
- 3 ? 'bottomCenter' : 'bottomRight';
- },
- effect3dChange(index) {
- this.effect3d = index == 0 ? true : false;
- },
- click(index) {
- this.$refs.uToast.show({
- title: `点击了第${index + 1}张图片`,
- type: 'success'
- })
- },
- change(index) {
- // console.log(index);
- },
- //获取用户数据
- getUserInfo() {
- let _this = this
- this.$request.sendToken('/api/user/info', {
- }, 'POST').then(res => {
- if (res.success == true) {
- this.userInfo = res.data;
- uni.setStorageSync('otc.user_type', this.userInfo.user_type)
- if (this.userInfo.idcard_check != 1) {
- uni.showModal({
- title: _this.lang.safe_tips,
- content: this.userInfo.set_trade_password != 1 ? _this.lang
- .no_idcard_check_2 : _this.lang.no_idcard_check_1,
- confirmText: _this.lang.go_auth,
- cancelText: _this.lang.no_go,
- success: function(res) {
- if (res.confirm == true) {
- uni.navigateTo({
- url: '/pages/auth/index'
- })
- } else {
- }
- },
- });
- }
- } else {
- this.$u.toast(res.msg);
- setTimeout(function() {
- uni.navigateTo({
- url: '/pages/login/login',
- });
- }, 2000)
- }
- })
- },
- //获取首页数据
- getIndex() {
- let _this = this;
- let locale = uni.getStorageSync('locale')
- this.$request.sendToken('/api/index', {
- locale: locale == 'en' ? 'en' : 'zh-cn'
- }, 'POST').then(res => {
- // 打印调用成功回调
- this.banners = res.data.banners.top;
- this.advert = res.data.banners.middle;
- this.notices = res.data.notices;
- this.trade = res.data.trade;
- let time = 8000 + parseInt(Math.random() * 2000);
- clearTimeout(_this.timerId)
- _this.timerId = setTimeout(function() {
- _this.getIndex();
- }, time)
- })
- },
- scan() {
- uni.scanCode({
- success: function(res) {
- if (res.result) {
- let ct = 1;
- if (this.formData.coin_type == 1) {
- let patt = /^T[a-zA-Z0-9]{20,50}/;
- ct = patt.test(addess) ? 1 : ct;
- } else {
- let patt = /^0x[a-zA-Z0-9]{20,50}/;
- ct = patt.test(addess) ? 2 : ct;
- }
- uni.setStorageSync({
- ct: ct,
- address: res.result
- })
- uni.navigateTo({
- url: '/pages/trade/transfer',
- });
- }
- console.log('条码类型:' + res.result);
- }
- });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .index {
- padding: 38upx 0rpx 200rpx;
- .wrap {
- padding: 0rpx 19rpx;
- .header {
- width: calc(100% - 20px);
- margin-bottom: 11px;
- position: fixed;
- top: 0;
- z-index: 99;
- background: #1f1f1f;
- padding: 20px 0 10px;
- .center {
- background-color: #2c2b2b;
- border: 4rpx solid #bb955e;
- border-radius: 164rpx;
- position: relative;
- width: auto;
- display: inline-block;
- font-size: 0;
- min-width: 164rpx;
- height: 66rpx;
- line-height: 64rpx;
- .image {
- width: 84rpx;
- height: 84rpx;
- position: relative;
- margin-top: -13rpx;
- margin-left: -12rpx;
- float: left;
- .icon {
- width: 100%;
- height: 100%;
- position: relative;
- z-index: 1;
- }
- .text {
- width: 77rpx;
- height: 77rpx;
- position: absolute;
- z-index: 2;
- color: #fff;
- font-weight: bold;
- font-size: 30rpx;
- left: 0;
- top: 0;
- right: 0;
- bottom: 0;
- margin: auto;
- width: 74rpx;
- line-height: 76rpx;
- text-align: center;
- }
- }
- .user {
- top: 0;
- position: relative;
- display: inline-block;
- width: 100rpx;
- float: left;
- color: #fff;
- font-size: 24rpx;
- text-align: center;
- margin-left: -10rpx;
- }
- }
- .icons {
- float: right;
- .icon-menu {
- display: inline-block;
- position: relative;
- .icon {
- z-index: 1;
- position: relative;
- width: 44rpx;
- height: 44rpx;
- margin: 0rpx 10rpx;
- vertical-align: middle;
- }
- .icon.en {
- height: 74rpx;
- width: 74rpx;
- vertical-align: middle;
- }
- .icon.zh-cn {
- height: 46rpx;
- width: 46rpx;
- vertical-align: middle;
- }
- .text {
- width: 24rpx;
- color: #fff;
- position: absolute;
- top: -8rpx;
- right: 8rpx;
- background-color: #185dbf;
- border: 4rpx solid #fff;
- border-radius: 50%;
- font-size: 19rpx;
- text-align: center;
- z-index: 2;
- height: 24rpx;
- line-height: 22rpx;
- padding: 2rpx;
- }
- }
- }
- }
- .u-u-swiper {
- margin-top: 102rpx;
- }
- .u-list-image-wrap {
- border-radius: 10rpx !important;
- }
- .u-indicator-item-round {
- background-color: #666 !important;
- }
- .tool-quick {
- height: 350rpx;
- .quick-sell {
- width: 100%;
- height: 100%;
- position: relative;
- .bg {
- width: 100%;
- height: 100%;
- position: absolute;
- z-index: 1;
- display: inline-block;
- border-radius: 10rpx;
- img {
- width: 100%;
- height: 100%;
- }
- }
- .info {
- padding: 28rpx;
- width: 100%;
- height: 100%;
- position: absolute;
- z-index: 2;
- color: #6e6c6b;
- .title {
- .name {
- color: #bb955e;
- font-size: 28rpx;
- font-weight: bold;
- margin-left: 8rpx;
- vertical-align: middle;
- }
- .icon {
- width: 48rpx;
- height: 48rpx;
- border-radius: 50%;
- vertical-align: middle;
- }
- .price {
- float: right;
- font-size: 28rpx;
- font-weight: bold;
- color: #d45c62;
- line-height: 48rpx;
- }
- }
- .tips {
- margin: 22rpx 0;
- word-break: break-all;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
- overflow: hidden;
- }
- .input-usdt {
- height: 55rpx;
- padding: 8rpx 10rpx;
- border-radius: 10rpx;
- border: 2rpx solid #6e6c6b;
- }
- .bj {
- margin-top: 29rpx;
- display: flex;
- .bj-info {
- width: calc(100% - 48rpx);
- .bj-result {
- color: #bb955e;
- font-size: 28rpx;
- }
- }
- .btn {
- float: right;
- .icon {
- width: 48rpx;
- height: 48rpx;
- padding: 10rpx;
- border-radius: 10rpx;
- vertical-align: middle;
- background-color: #d45c62;
- }
- }
- }
- }
- }
- .quick-buy {
- height: 100%;
- padding: 0 !important;
- .menu {
- width: 90%;
- margin-left: 10%;
- background-color: #2c2b2b;
- padding: 28rpx 0rpx;
- border-radius: 10rpx;
- .text {
- color: #bb955e;
- font-size: 28rpx;
- font-weight: bold;
- margin-left: 8rpx;
- vertical-align: middle;
- line-height: 48rpx;
- }
- .icon {
- width: 48rpx;
- height: 48rpx;
- vertical-align: middle;
- margin-left: 16rpx;
- }
- .icon.right {
- width: 28rpx;
- height: 28rpx;
- float: right;
- margin-right: 19rpx;
- line-height: 48rpx;
- vertical-align: middle;
- margin-top: 10rpx;
- }
- }
- .buy {
- color: #6e6c6b;
- margin-top: 22rpx;
- width: 90%;
- margin-left: 10%;
- padding: 30rpx 20rpx;
- border-radius: 10rpx;
- border-left: 8rpx solid #49c3ac;
- background-color: #2c2b2b;
- position: relative;
- .buy-tips {
- margin: 28rpx 0;
- word-break: break-all;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
- overflow: hidden;
- margin-right: 10rpx;
- .text {
- height: 100%;
- }
- .icon {
- width: 28rpx;
- height: 28rpx;
- // float: right;
- line-height: 48rpx;
- vertical-align: middle;
- margin-top: 10rpx;
- position: absolute;
- right: 10px;
- top: 40%;
- }
- }
- .buy-text,
- .price {
- color: #49c3ac;
- font-weight: bold;
- }
- }
- }
- }
- .notices {
- margin: 20rpx 0rpx;
- .info {
- width: 100%;
- display: flex;
- .list {
- color: #f1f1f1 !important;
- margin: 0rpx 10rpx;
- line-height: 58rpx;
- width: calc(100% - 116rpx);
- }
- .icon {
- width: 58rpx;
- height: 58rpx;
- }
- .icon-list {
- margin-top: 6rpx;
- width: 48rpx;
- height: 48rpx;
- float: right;
- }
- }
- }
- .counts {
- margin-top: 38rpx;
- text-align: center;
- border-radius: 10rpx;
- background-color: #2c2b2b;
- .count {
- margin: 20rpx 0;
- color: #6e6c6b;
- padding: 10rpx 10rpx !important;
- text-align: center !important;
- border-right: 2rpx solid #6e6c6b;
- .text {
- font-size: 32rpx;
- margin-top: 10rpx;
- color: #bb955e;
- }
- }
- .count:last-child {
- border-right: 2rpx solid #2c2b2b;
- }
- }
- }
- .advert {
- margin: 38rpx 0 19rpx;
- width: 100%;
- height: 156rpx;
- .image {
- width: 100%;
- height: 100%;
- }
- }
- .platform-price {
- background-color: #2c2b2b;
- border-radius: 10rpx;
- padding: 19rpx 0;
- margin: 38rpx 19rpx;
- .row {
- overflow: hidden;
- margin: 0px 29rpx;
- padding: 19rpx 0;
- border-bottom: 1rpx solid #bb955e;
- color: #6e6c6b;
- .name {
- float: left;
- }
- .price {
- float: right;
- }
- }
- .row:last-child {
- border: none;
- }
- }
- }
- </style>
|