index.vue 17 KB

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