index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <template>
  2. <view class="index-data">
  3. <view class="index-top">
  4. <view class="top-logo">
  5. <view class="logo-img">
  6. <image src="/static/img/index/index-logo.png" mode="aspectFit"></image>
  7. </view>
  8. <view class="logo-lang" @click="setShowLang">
  9. <image v-if="applicationLocale==='en'" src="/static/img/index/en.svg" mode="aspectFit"></image>
  10. <image v-else src="/static/img/index/cn.svg" mode="aspectFit"></image>
  11. <view class="lang-list" @click.stop v-show="showLang">
  12. <view class="lang-item" @click.stop="onLocaleChange('en')" :class="{'lang-item-option':applicationLocale==='en'}">
  13. <image class="image-ok" src="/static/img/index/en.svg" mode="aspectFit"></image>
  14. <image class="image-no" src="/static/img/index/en-no.svg" mode="aspectFit"></image>
  15. <view class="item-vertical"></view>
  16. <view class="item-str">English</view>
  17. </view>
  18. <view class="lang-item" @click.stop="onLocaleChange('zh-Hans')" :class="{'lang-item-option':applicationLocale==='zh-Hans'}">
  19. <image class="image-ok" src="/static/img/index/cn.svg" mode="aspectFit"></image>
  20. <image class="image-no" src="/static/img/index/cn-no.svg" mode="aspectFit"></image>
  21. <view class="item-vertical"></view>
  22. <view class="item-str">简体中文</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="top-name">
  28. <image src="/static/img/index/name.svg" mode="widthFix"></image>
  29. </view>
  30. <view class="top-bg"></view>
  31. </view>
  32. <view class="index-from">
  33. <view class="from-data">
  34. <view class="from-tab">
  35. <view class="tab-item" @click="setOptionType(1)" :class="{'option-tab':optionNum===1}" >
  36. <view class="item-content">{{$t('index.index.investment')}}</view>
  37. <view class="item-img img-left">
  38. <image src="/static/img/index/left.png" mode="heightFix"></image>
  39. </view>
  40. </view>
  41. <view class="tab-item" @click="setOptionType(2)" :class="{'option-tab':optionNum===2}" >
  42. <view class="item-content">{{$t('index.index.after')}}</view>
  43. <view class="item-img img-right">
  44. <image src="/static/img/index/right.png" mode="heightFix"></image>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="from-data">
  49. <view class="from-icon">
  50. <view class="icon-img">
  51. <image src="/static/img/index/USDT(ERC20).png" mode="aspectFill"></image>
  52. </view>
  53. <view class="icon-name">USDT(TRC20)</view>
  54. <view class="icon-icon">
  55. <image src="/static/img/index/select.svg" mode="aspectFill"></image>
  56. </view>
  57. </view>
  58. <view class="from-between"></view>
  59. <view class="from-input">
  60. <view class="input-data">
  61. <view class="data-money">{{$t('index.index.money')}}: {{(usdtNum).toFixed(6)}}</view>
  62. <view class="data-input">
  63. <view>
  64. <input type="number">
  65. </view>
  66. <view> <button>MAX</button></view>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="from-but">
  71. <button @click="setInvest">{{$t('index.index.affirm')}}</button>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="index-list">
  77. <view class="list-title">
  78. <view class="title-data">
  79. <view><image class="title-img" mode="aspectFit" src="/static/img/index/a.png"></image></view>
  80. <view class="title-str">{{$t('index.index.transaction')}}</view>
  81. </view>
  82. <view class="title-all">{{$t('index.index.all')}}>></view>
  83. </view>
  84. <view class="list-tab">
  85. <view class="tab-items">
  86. <view class="tab-item" @click="setListTab(1)" :class="{'option-tab':listTab===1}">NFT</view>
  87. <view class="tab-item" @click="setListTab(2)" :class="{'option-tab':listTab===2}">{{$t('index.index.team')}}</view>
  88. <view class="tab-item" @click="setListTab(3)" :class="{'option-tab':listTab===3}">{{$t('index.index.code')}}</view>
  89. </view>
  90. <view class="tab-item-bg" :class="{'bg-location-1':listTab===1,'bg-location-2':listTab===2,'bg-location-3':listTab===3}"></view>
  91. </view>
  92. <view class="list-data">
  93. <view class="contract-list"></view>
  94. <view class="team-list"></view>
  95. <view class="recommend-code"></view>
  96. </view>
  97. </view>
  98. </view>
  99. </template>
  100. <script>
  101. import {getInvestData, setInvest} from "@/api/contract";
  102. import tools from "@/common/js/tools";
  103. import bitkeepTron from "@/common/wallet/bitkeep-wallet/bitkeep-tron";
  104. export default {
  105. components: {
  106. },
  107. data() {
  108. return {
  109. applicationLocale:'',
  110. systemLocale:'',
  111. showLang:false,
  112. optionNum:1,
  113. listTab:1,
  114. investData: {
  115. id: 1,
  116. invest_money: '',
  117. sysAddress: "",
  118. sendNum: "",
  119. },
  120. isAjax: false,
  121. usdtNum:0
  122. }
  123. },
  124. watch: {
  125. },
  126. async onLoad(query) {
  127. this.applicationLocale = uni.getLocale();
  128. this.getInvestData()
  129. this.usdtNum = await bitkeepTron.getTokenBalance('', 0);
  130. },
  131. mounted() {
  132. },
  133. methods: {
  134. getInvestData() {
  135. getInvestData().then((res) => {
  136. if (res.code === 1) {
  137. this.investData = res.data
  138. } else {
  139. tools.leftClick()
  140. }
  141. }).catch((e) => {
  142. tools.leftClick()
  143. })
  144. },
  145. async setInvest() {
  146. if (this.investData.sendNum > 0) {
  147. tools.error(this.$t('index.index.invest.execute'))
  148. return;
  149. }
  150. let trxNum = await bitkeepTron.getBalance('');
  151. if (trxNum < 5) {
  152. tools.error(this.$t('index.index.invest.mix'))
  153. return
  154. }
  155. let usdtNum = await bitkeepTron.getTokenBalance('', 0);
  156. if (usdtNum < this.investData.invest_money && !tools.isDevelopment()) {
  157. tools.error(this.$t('index.index.invest.no_usdt'))
  158. return
  159. }
  160. if (this.isAjax) {
  161. return
  162. }
  163. this.isAjax = true
  164. let transactionData = bitkeepTron.getContractData(this.investData.sysAddress, this.investData.invest_money,0)
  165. bitkeepTron.sendTransaction(transactionData).then((res) => {
  166. if (res) {
  167. setInvest({'txid':res,'id':this.investData.id}).then((res)=>{
  168. if(res.code===1){
  169. tools.success(res.msg)
  170. setTimeout(()=>{
  171. tools.leftClick()
  172. },1500)
  173. }else {
  174. this.isAjax = false
  175. tools.error(res.msg)
  176. }
  177. })
  178. } else {
  179. this.isAjax = false
  180. tools.error(this.$t('index.index.invest.send_no'))
  181. }
  182. }).catch((e) => {
  183. this.isAjax = false
  184. tools.error(this.$t('index.index.invest.send_no'))
  185. })
  186. },
  187. setShowLang(){
  188. this.showLang=true
  189. },
  190. onLocaleChange(code){
  191. uni.setLocale(code);
  192. this.$i18n.locale = code;
  193. this.applicationLocale = code;
  194. this.showLang=false
  195. },
  196. setOptionType(optionNum){
  197. if(this.optionNum!==optionNum){
  198. this.optionNum=optionNum
  199. }
  200. },
  201. setListTab(listTab){
  202. if(this.listTab!==listTab){
  203. this.listTab=listTab
  204. }
  205. },
  206. goToUrl(type){
  207. switch (type) {
  208. case 1:
  209. uni.navigateTo({
  210. 'url':'pages/contract/add'
  211. })
  212. }
  213. }
  214. },
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .index-data{
  219. min-height: 100vh;
  220. .index-top{
  221. height: 120px;
  222. .top-logo{
  223. height: 35px;
  224. padding:10px 16px;
  225. display: flex;
  226. justify-content: space-between;
  227. .logo-img{
  228. width: 68px;
  229. image{
  230. width: 68px;
  231. height: 29px;
  232. }
  233. }
  234. .logo-lang{
  235. height: 35px;
  236. background: rgba(241,134,134,.04);
  237. border-radius: 12px;
  238. border: 1px solid hsla(0,0%,100%,.2);
  239. position: relative;
  240. image{
  241. margin: 0 5px;
  242. height: 35px;
  243. width: 32px;
  244. }
  245. .lang-list{
  246. padding: 0 10px;
  247. position: absolute;
  248. top: 45px;
  249. right: 0;
  250. height: 100px;
  251. word-break: keep-all;
  252. background: #f6f9ff;
  253. border-radius: 13px;
  254. border: 1px solid rgba(39,127,250,.64);
  255. z-index: 99;
  256. .lang-item{
  257. height: 42px;
  258. padding: 0 10px;
  259. margin: 5px 0;
  260. border-radius: 9px;
  261. display: flex;
  262. justify-content: left;
  263. cursor: pointer;
  264. font-size: 18px;
  265. image{
  266. margin-top: 6px;
  267. width: 30px;
  268. height: 30px;
  269. }
  270. .image-ok{
  271. display: none;
  272. }
  273. .image-no{
  274. display: block;
  275. }
  276. .item-vertical{
  277. height: 20px;
  278. width: 1px;
  279. margin: 11px 5px 0 5px;
  280. background: #277ffa;
  281. }
  282. .item-str{
  283. color: #277ffa;
  284. cursor: pointer;
  285. font-size: 18px;
  286. line-height: 42px;
  287. text-align: left;
  288. margin-left: 5px;
  289. }
  290. }
  291. .lang-item-option{
  292. background: #277ffa;
  293. .image-ok{
  294. display: block;
  295. }
  296. .image-no{
  297. display: none;
  298. }
  299. .item-vertical{
  300. background: #fff;
  301. }
  302. .item-str{
  303. color: #fff;
  304. }
  305. }
  306. }
  307. }
  308. }
  309. .top-name{
  310. image{
  311. width: 100vw;
  312. }
  313. }
  314. .top-bg{
  315. height: 270px;
  316. width: 100%;
  317. position: absolute;
  318. left: 0;
  319. top: 0;
  320. overflow: hidden;
  321. z-index: -99;
  322. background: #277ffa!important;
  323. }
  324. }
  325. .index-from{
  326. padding: 6px;
  327. .from-data{
  328. background: #fff;
  329. border-radius: 30px;
  330. width: calc(100vw - 12px);
  331. .from-tab{
  332. position: relative;
  333. width: calc(100vw - 12px);
  334. border-radius: 30px 30px 0 0;
  335. background: #f7f8fa;
  336. height: 38px;
  337. display: flex;
  338. justify-content: space-between;
  339. .tab-item{
  340. width: 50%;
  341. z-index: 1;
  342. .item-content{
  343. height: 38px;
  344. line-height: 38px;
  345. color: #9197a5;
  346. font-size: 16px;
  347. cursor: pointer;
  348. text-align: center;
  349. }
  350. .item-img{
  351. display: none;
  352. z-index: -1;
  353. position: absolute;
  354. top: -2px;
  355. image{
  356. height: 38px;
  357. }
  358. }
  359. .img-left{
  360. left: 0;
  361. }
  362. .img-right{
  363. right: 0;
  364. }
  365. }
  366. .option-tab{
  367. z-index: 3;
  368. .item-content{
  369. color: #000;
  370. z-index: 5;
  371. }
  372. .item-img{
  373. display: block;
  374. }
  375. }
  376. }
  377. .from-data{
  378. border-radius: 0 0 30px 30px;
  379. padding: 20px;
  380. box-sizing: border-box;
  381. .from-icon{
  382. position: relative;
  383. height: 46px;
  384. display: flex;
  385. justify-content: left;
  386. .icon-img{
  387. margin-right: 10px;
  388. image{
  389. height: 46px;
  390. width: 46px;
  391. }
  392. }
  393. .icon-name{
  394. height: 46px;
  395. line-height: 46px;
  396. font-size: 18px;
  397. }
  398. .icon-icon{
  399. position: absolute;
  400. right: 22px;
  401. top: 13px;
  402. image{
  403. width: 20px;
  404. height: 20px;
  405. }
  406. }
  407. }
  408. .from-between{
  409. margin: 18px 0;
  410. height: 2px;
  411. background: #fbfbfd;
  412. }
  413. .from-input{
  414. box-sizing: border-box;
  415. width: 100%;
  416. height: 45px;
  417. border-radius: 17px;
  418. border: 1px solid #f2f5fa;
  419. margin-bottom: 55px;
  420. .input-data{
  421. width: calc(100% - 20px);
  422. height: 45px;
  423. padding: 10px;
  424. background: #f7f8fa;
  425. border-radius: 16px;
  426. .data-money{
  427. height: 20px;
  428. color: #6b6c70;
  429. font-size: 12px;
  430. }
  431. .data-input{
  432. display: flex;
  433. justify-content: space-between;
  434. input{
  435. height: 25px;
  436. width: 100%;
  437. border: none;
  438. font-size: 18px;
  439. background: #f7f8fa;
  440. padding: 1px 2px;
  441. }
  442. button{
  443. font-size: 12px;
  444. -webkit-text-size-adjust: none;
  445. font-weight: 800;
  446. color: #fff;
  447. width: 38px;
  448. height: 18px;
  449. padding: 2px;
  450. border-radius: 5px;
  451. line-height: 15px;
  452. margin-top: 4px;
  453. cursor: pointer;
  454. background: #277ffa;
  455. }
  456. }
  457. }
  458. }
  459. .from-but{
  460. margin-top: 18px;
  461. height: 64px;
  462. button{
  463. height: 64px;
  464. line-height: 64px;
  465. font-size: 24px;
  466. background: #277ffa;
  467. border-radius: 17px;
  468. color: #fff;
  469. }
  470. }
  471. }
  472. }
  473. }
  474. .index-list{
  475. padding:6px 16px;
  476. .list-title{
  477. display: flex;
  478. justify-content: space-between;
  479. .title-data{
  480. display: flex;
  481. justify-content: left;
  482. .title-img{
  483. width: 24px;
  484. height: 24px;
  485. }
  486. .title-str{
  487. font-size: 16px;
  488. line-height: 24px;
  489. color: #292929;
  490. margin-left: 3px;
  491. }
  492. }
  493. .title-all{
  494. font-size: 15px;
  495. font-weight: 400;
  496. color: #3184fa;
  497. cursor: pointer;
  498. padding: 5px 10px;
  499. }
  500. }
  501. .list-tab{
  502. height: 100%;
  503. background: #eaf2ff;
  504. border-radius: 36px;
  505. cursor: pointer;
  506. position: relative;
  507. .tab-items{
  508. z-index: 10;
  509. display: flex;
  510. justify-content: space-between;
  511. border-radius: 36px;
  512. .tab-item{
  513. z-index: 10;
  514. width: calc(100% / 3);
  515. font-size: 13px;
  516. color: #adbad0;
  517. display: block;
  518. height: 32px;
  519. line-height: 32px;
  520. text-align: center;
  521. }
  522. .option-tab{
  523. color: #292929;
  524. }
  525. }
  526. .tab-item-bg{
  527. position: absolute;
  528. border-radius: 36px;
  529. background: #fff;
  530. transition: .5s ease;
  531. height: 32px;
  532. width: calc(100% / 3);
  533. top: 0;
  534. }
  535. .bg-location-1{
  536. left: 0;
  537. transition: .5s ease;
  538. }
  539. .bg-location-2{
  540. left: 33.33%;
  541. transition: .5s ease;
  542. }
  543. .bg-location-3{
  544. left: 66.66%;
  545. transition: .5s ease;
  546. }
  547. }
  548. }
  549. }
  550. </style>