index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. <template>
  2. <view class="index">
  3. <view class="wrap">
  4. <!-- 头部 -->
  5. <view class="header">
  6. <view class="center" v-if="userInfo.id>0">
  7. <navigator url="/pages/center/index">
  8. <view class="image">
  9. <image class="icon" src="/static/icons/circle.png">
  10. </image>
  11. <text class="text">T</text>
  12. </view>
  13. <view class="user">{{lang.center}}</view>
  14. </navigator>
  15. </view>
  16. <view v-else class="center">
  17. <navigator url="/pages/login/login">
  18. <view class="image">
  19. <image class="icon" src="/static/icons/circle.png">
  20. </image>
  21. <text class="text">Go</text>
  22. </view>
  23. <view class="user">{{lang.login}}</view>
  24. </navigator>
  25. </view>
  26. <view class="icons">
  27. <view class="icon-menu" @click="switchLang()">
  28. <image class="icon locale" src="../static/icons/zh-cn.png" mode=""></image>
  29. </view>
  30. <view class="icon-menu" @click="scan()">
  31. <image class="icon scan" src="../static/icons/scan.png" mode=""></image>
  32. </view>
  33. <view class="icon-menu">
  34. <image class="icon custom" src="../static/icons/custom.png" mode=""></image>
  35. <text v-if="message.custom" class="text"></text>
  36. </view>
  37. <view class="icon-menu">
  38. <image class="icon notice" src="../static/icons/notice.png" mode=""></image>
  39. <text v-if="message.notice" class="text"></text>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- 轮播广告 -->
  44. <view class="u-u-swiper">
  45. <u-swiper @change="change" :height="290" :list="banners" :title="title" :effect3d="effect3d"
  46. :indicator-pos="indicatorPos" :mode="mode" :interval="3000" @click="click"></u-swiper>
  47. </view>
  48. <!-- 公告 -->
  49. <view class="notices">
  50. <view class="info">
  51. <image class="icon" src="../static/icons/message.png" mode=""></image>
  52. <view class="list" v-if="notices.length>0">
  53. <u-swiper @change="change" :vertical="vertical" :height="30" :list="notices" :title="title"
  54. :effect3d="effect3d" :indicator-pos="indicatorPos" :mode="mode1" :interval="3000"
  55. @click="click"></u-swiper>
  56. </view>
  57. <view class="list" v-else>
  58. <text>{{lang.no_notice}}</text>
  59. </view>
  60. <image class="icon icon-list" src="/static/icons/list.png" mode=""></image>
  61. </view>
  62. </view>
  63. <!-- 菜单 -->
  64. <u-row class="tool-quick">
  65. <u-col class="quick-sell" :span="7" :offset="0">
  66. <image src="/static/icons/quick-bg2.jpeg" class="bg"></image>
  67. <view class="info">
  68. <view class="title">
  69. <image class="icon" src="/static/icons/usdt.png" mode=""></image>
  70. <text class="name">{{lang.quick_sell}}</text>
  71. <text class="price">¥{{trade.buy_price}}/USDT</text>
  72. </view>
  73. <view class="tips">
  74. {{lang.quick_sell_tips}}
  75. </view>
  76. <view class="input">
  77. <input class="input-usdt" type="number" v-model="counts.usdt" @input="countTotal">
  78. </view>
  79. <view class="bj">
  80. <view class="bj-info">
  81. <view class="text">
  82. {{lang.quick_sell_text}}
  83. </view>
  84. <view class="bj-result">
  85. ¥{{counts.result}}
  86. </view>
  87. </view>
  88. <view class="btn" @click="gotoPage('/pages/trade/index?type=2')">
  89. <image class="icon" src="/static/icons/row-right.png" mode=""></image>
  90. </view>
  91. </view>
  92. </view>
  93. </u-col>
  94. <u-col class="quick-buy" :span="5" :offset="0">
  95. <view class="menu" @click="gotoPage('/pages/order/index')">
  96. <image class="icon" src="/static/icons/list-order.png" mode=""></image>
  97. <text class="text">{{lang.my_order}}</text>
  98. <image class="icon right" src="/static/icons/row-right-gray.png" mode=""></image>
  99. </view>
  100. <view class="buy">
  101. <view class="buy-text">
  102. {{lang.buy_utc}}
  103. </view>
  104. <view class="buy-tips">
  105. <text class="text">{{lang.quick_buy_tips}}</text>
  106. <image class="icon" src="/static/icons/row-right-gray.png"
  107. @click="gotoPage('/pages/trade/index?type=1')" mode=""></image>
  108. </view>
  109. <view class="price">
  110. ¥{{trade.sell_price}}/USDT
  111. </view>
  112. </view>
  113. </u-col>
  114. </u-row>
  115. <!-- 实时统计 -->
  116. <u-row class="counts">
  117. <u-col class="count order-total" :span="4" :offset="0">
  118. <view class="name">{{lang.order_total_24}}</view>
  119. <view class="text">{{trade.total}}</view>
  120. </u-col>
  121. <u-col class="count order-count" :span="4" :offset="0">
  122. <view class="name">{{lang.order_count_24}}</view>
  123. <view class="text">{{trade.count}}</view>
  124. </u-col>
  125. <u-col class="count trade-rate" :span="4" :offset="0">
  126. <view class="name">24H{{lang.trade_rate}}</view>
  127. <view class="text">{{trade.rate}}%</view>
  128. </u-col>
  129. </u-row>
  130. </view>
  131. <!-- 推荐广告 -->
  132. <view class="advert" v-if="advert">
  133. <image class="image" :src="v.image" mode="" v-for="(v,k) in advert" :key="k" :title="v.title"></image>
  134. </view>
  135. <!-- 平台价格 -->
  136. <view class="platform-price">
  137. <view class="row title">
  138. <text class="name">平台</text>
  139. <text class="price">卖价(平均)</text>
  140. </view>
  141. <view class="row list-row first">
  142. <text class="name">U币支付</text>
  143. <text class="price">¥{{trade.sell_price}}</text>
  144. </view>
  145. </view>
  146. </view>
  147. </template>
  148. <script>
  149. import {
  150. switchLocale
  151. } from '@/common/checker.js'
  152. export default {
  153. data() {
  154. return {
  155. title: false,
  156. mode: 'round',
  157. mode1: 'round',
  158. vertical: false,
  159. indicatorPos: 'bottomCenter',
  160. effect3d: false,
  161. // 用户信息
  162. userInfo: {
  163. id: 0
  164. },
  165. // 轮播
  166. banners: [],
  167. advert: [],
  168. // 交易参数
  169. trade: {
  170. buy_price: '0.00',
  171. sell_price: '0.00',
  172. total: '0.00',
  173. count: 0,
  174. rate: '0.00'
  175. },
  176. // 公告
  177. notices: [],
  178. // 消息数量
  179. message: {
  180. custom: 2,
  181. notice: 0
  182. },
  183. // 比价计算
  184. counts: {
  185. usdt: 0,
  186. result: '0.00',
  187. },
  188. timerId: null,
  189. };
  190. },
  191. created() {
  192. this.getUserInfo();
  193. this.getIndex();
  194. },
  195. methods: {
  196. switchLang() {
  197. let lang = switchLocale();
  198. this.lang = this.lang
  199. location.reload()
  200. },
  201. countTotal() {
  202. this.counts.result = (this.counts.usdt * this.trade.price).toFixed(2);
  203. },
  204. titleChange(index) {
  205. this.title = index == 0 ? true : false;
  206. },
  207. modeChange(index) {
  208. this.mode = index == 0 ? 'round' : index == 1 ? 'rect' : index == 2 ? 'number' : 'none';
  209. },
  210. indicatorPosChange(index) {
  211. this.indicatorPos = index == 0 ? 'topLeft' : index == 1 ? 'topRight' : index == 2 ? 'bottomLeft' : index ==
  212. 3 ? 'bottomCenter' : 'bottomRight';
  213. },
  214. effect3dChange(index) {
  215. this.effect3d = index == 0 ? true : false;
  216. },
  217. click(index) {
  218. this.$refs.uToast.show({
  219. title: `点击了第${index + 1}张图片`,
  220. type: 'success'
  221. })
  222. },
  223. change(index) {
  224. // console.log(index);
  225. },
  226. //获取用户数据
  227. getUserInfo() {
  228. this.$request.sendToken('/api/user/info', {}, 'POST').then(res => {
  229. if (res.success == true) {
  230. this.userInfo = res.data;
  231. uni.setStorageSync('otc.user_type', this.userInfo.user_type)
  232. } else {
  233. this.$u.toast(res.msg);
  234. setTimeout(function() {
  235. uni.navigateTo({
  236. url: '/pages/login/login',
  237. });
  238. }, 2000)
  239. }
  240. })
  241. },
  242. //获取首页数据
  243. getIndex() {
  244. let _this = this;
  245. this.$request.sendToken('/api/index', {}, 'POST').then(res => {
  246. // 打印调用成功回调
  247. this.banners = res.data.banners.top;
  248. this.advert = res.data.banners.middle;
  249. this.notices = res.data.notices;
  250. this.trade = res.data.trade;
  251. let time = 8000 + parseInt(Math.random() * 2000);
  252. clearTimeout(_this.timerId)
  253. _this.timerId = setTimeout(function() {
  254. _this.getIndex();
  255. }, time)
  256. })
  257. },
  258. scan() {
  259. uni.scanCode({
  260. success: function(res) {
  261. if (res.result) {
  262. let ct = 1;
  263. if (this.formData.coin_type == 1) {
  264. let patt = /^T[a-zA-Z0-9]{20,50}/;
  265. ct = patt.test(addess) ? 1 : ct;
  266. } else {
  267. let patt = /^0x[a-zA-Z0-9]{20,50}/;
  268. ct = patt.test(addess) ? 2 : ct;
  269. }
  270. uni.setStorageSync({
  271. ct: ct,
  272. address: res.result
  273. })
  274. uni.navigateTo({
  275. url: '/pages/trade/transfer',
  276. });
  277. }
  278. console.log('条码类型:' + res.result);
  279. }
  280. });
  281. }
  282. }
  283. }
  284. </script>
  285. <style lang="scss" scoped>
  286. .index {
  287. padding: 38upx 0rpx 200rpx;
  288. .wrap {
  289. padding: 0rpx 19rpx;
  290. .header {
  291. width: calc(100% - 20px);
  292. margin-bottom: 11px;
  293. position: fixed;
  294. top: 0;
  295. z-index: 99;
  296. background: #1f1f1f;
  297. padding: 20px 0 10px;
  298. .center {
  299. background-color: #2c2b2b;
  300. border: 4rpx solid #bb955e;
  301. border-radius: 164rpx;
  302. position: relative;
  303. width: auto;
  304. display: inline-block;
  305. font-size: 0;
  306. min-width: 164rpx;
  307. height: 66rpx;
  308. line-height: 64rpx;
  309. .image {
  310. width: 84rpx;
  311. height: 84rpx;
  312. position: relative;
  313. margin-top: -13rpx;
  314. margin-left: -12rpx;
  315. float: left;
  316. .icon {
  317. width: 100%;
  318. height: 100%;
  319. position: relative;
  320. z-index: 1;
  321. }
  322. .text {
  323. width: 77rpx;
  324. height: 77rpx;
  325. position: absolute;
  326. z-index: 2;
  327. color: #fff;
  328. font-weight: bold;
  329. font-size: 30rpx;
  330. left: 0;
  331. top: 0;
  332. right: 0;
  333. bottom: 0;
  334. margin: auto;
  335. width: 74rpx;
  336. line-height: 76rpx;
  337. text-align: center;
  338. }
  339. }
  340. .user {
  341. top: 0;
  342. position: relative;
  343. display: inline-block;
  344. width: 100rpx;
  345. float: left;
  346. color: #fff;
  347. font-size: 24rpx;
  348. text-align: center;
  349. margin-left: -10rpx;
  350. }
  351. }
  352. .icons {
  353. float: right;
  354. .icon-menu {
  355. display: inline-block;
  356. position: relative;
  357. .icon {
  358. z-index: 1;
  359. position: relative;
  360. width: 44rpx;
  361. height: 44rpx;
  362. margin: 0rpx 10rpx;
  363. }
  364. .text {
  365. width: 24rpx;
  366. color: #fff;
  367. position: absolute;
  368. top: -8rpx;
  369. right: 8rpx;
  370. background-color: #185dbf;
  371. border: 4rpx solid #fff;
  372. border-radius: 50%;
  373. font-size: 19rpx;
  374. text-align: center;
  375. z-index: 2;
  376. height: 24rpx;
  377. line-height: 22rpx;
  378. padding: 2rpx;
  379. }
  380. }
  381. }
  382. }
  383. .u-u-swiper {
  384. margin-top: 102rpx;
  385. }
  386. .u-list-image-wrap {
  387. border-radius: 10rpx !important;
  388. }
  389. .u-indicator-item-round {
  390. background-color: #666 !important;
  391. }
  392. .tool-quick {
  393. height: 350rpx;
  394. .quick-sell {
  395. width: 100%;
  396. height: 100%;
  397. position: relative;
  398. .bg {
  399. width: 100%;
  400. height: 100%;
  401. position: absolute;
  402. z-index: 1;
  403. display: inline-block;
  404. border-radius: 10rpx;
  405. img {
  406. width: 100%;
  407. height: 100%;
  408. }
  409. }
  410. .info {
  411. padding: 28rpx;
  412. width: 100%;
  413. height: 100%;
  414. position: absolute;
  415. z-index: 2;
  416. color: #6e6c6b;
  417. .title {
  418. .name {
  419. color: #bb955e;
  420. font-size: 28rpx;
  421. font-weight: bold;
  422. margin-left: 8rpx;
  423. vertical-align: middle;
  424. }
  425. .icon {
  426. width: 48rpx;
  427. height: 48rpx;
  428. border-radius: 50%;
  429. vertical-align: middle;
  430. }
  431. .price {
  432. float: right;
  433. font-size: 28rpx;
  434. font-weight: bold;
  435. color: #d45c62;
  436. line-height: 48rpx;
  437. }
  438. }
  439. .tips {
  440. margin: 22rpx 0;
  441. word-break: break-all;
  442. text-overflow: ellipsis;
  443. display: -webkit-box;
  444. -webkit-box-orient: vertical;
  445. -webkit-line-clamp: 1;
  446. overflow: hidden;
  447. }
  448. .input-usdt {
  449. height: 55rpx;
  450. padding: 8rpx 10rpx;
  451. border-radius: 10rpx;
  452. border: 2rpx solid #6e6c6b;
  453. }
  454. .bj {
  455. margin-top: 29rpx;
  456. display: flex;
  457. .bj-info {
  458. width: calc(100% - 48rpx);
  459. .bj-result {
  460. color: #bb955e;
  461. font-size: 28rpx;
  462. }
  463. }
  464. .btn {
  465. float: right;
  466. .icon {
  467. width: 48rpx;
  468. height: 48rpx;
  469. padding: 10rpx;
  470. border-radius: 10rpx;
  471. vertical-align: middle;
  472. background-color: #d45c62;
  473. }
  474. }
  475. }
  476. }
  477. }
  478. .quick-buy {
  479. height: 100%;
  480. padding: 0 !important;
  481. .menu {
  482. width: 90%;
  483. margin-left: 10%;
  484. background-color: #2c2b2b;
  485. padding: 28rpx 0rpx;
  486. border-radius: 10rpx;
  487. .text {
  488. color: #bb955e;
  489. font-size: 28rpx;
  490. font-weight: bold;
  491. margin-left: 8rpx;
  492. vertical-align: middle;
  493. line-height: 48rpx;
  494. }
  495. .icon {
  496. width: 48rpx;
  497. height: 48rpx;
  498. vertical-align: middle;
  499. margin-left: 16rpx;
  500. }
  501. .icon.right {
  502. width: 28rpx;
  503. height: 28rpx;
  504. float: right;
  505. margin-right: 19rpx;
  506. line-height: 48rpx;
  507. vertical-align: middle;
  508. margin-top: 10rpx;
  509. }
  510. }
  511. .buy {
  512. color: #6e6c6b;
  513. margin-top: 22rpx;
  514. width: 90%;
  515. margin-left: 10%;
  516. padding: 30rpx 20rpx;
  517. border-radius: 10rpx;
  518. border-left: 8rpx solid #49c3ac;
  519. background-color: #2c2b2b;
  520. position: relative;
  521. .buy-tips {
  522. margin: 28rpx 0;
  523. word-break: break-all;
  524. text-overflow: ellipsis;
  525. display: -webkit-box;
  526. -webkit-box-orient: vertical;
  527. -webkit-line-clamp: 1;
  528. overflow: hidden;
  529. margin-right: 10rpx;
  530. .text {
  531. height: 100%;
  532. }
  533. .icon {
  534. width: 28rpx;
  535. height: 28rpx;
  536. // float: right;
  537. line-height: 48rpx;
  538. vertical-align: middle;
  539. margin-top: 10rpx;
  540. position: absolute;
  541. right: 10px;
  542. top: 40%;
  543. }
  544. }
  545. .buy-text,
  546. .price {
  547. color: #49c3ac;
  548. font-weight: bold;
  549. }
  550. }
  551. }
  552. }
  553. .notices {
  554. margin: 20rpx 0rpx;
  555. .info {
  556. width: 100%;
  557. display: flex;
  558. .list {
  559. color: #f1f1f1;
  560. margin: 0rpx 10rpx;
  561. line-height: 58rpx;
  562. width: calc(100% - 116rpx);
  563. }
  564. .icon {
  565. width: 58rpx;
  566. height: 58rpx;
  567. }
  568. .icon-list {
  569. margin-top: 6rpx;
  570. width: 48rpx;
  571. height: 48rpx;
  572. float: right;
  573. }
  574. }
  575. }
  576. .counts {
  577. margin-top: 38rpx;
  578. text-align: center;
  579. border-radius: 10rpx;
  580. background-color: #2c2b2b;
  581. .count {
  582. margin: 20rpx 0;
  583. color: #6e6c6b;
  584. padding: 10rpx 10rpx !important;
  585. text-align: center !important;
  586. border-right: 2rpx solid #6e6c6b;
  587. .text {
  588. font-size: 32rpx;
  589. margin-top: 10rpx;
  590. color: #bb955e;
  591. }
  592. }
  593. .count:last-child {
  594. border-right: 2rpx solid #2c2b2b;
  595. }
  596. }
  597. }
  598. .advert {
  599. margin: 38rpx 0 19rpx;
  600. width: 100%;
  601. height: 156rpx;
  602. .image {
  603. width: 100%;
  604. height: 100%;
  605. }
  606. }
  607. .platform-price {
  608. background-color: #2c2b2b;
  609. border-radius: 10rpx;
  610. padding: 19rpx 0;
  611. margin: 38rpx 19rpx;
  612. .row {
  613. overflow: hidden;
  614. margin: 0px 29rpx;
  615. padding: 19rpx 0;
  616. border-bottom: 1rpx solid #bb955e;
  617. color: #6e6c6b;
  618. .name {
  619. float: left;
  620. }
  621. .price {
  622. float: right;
  623. }
  624. }
  625. .row:last-child {
  626. border: none;
  627. }
  628. }
  629. }
  630. </style>