index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  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>{{$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('有正在执行的交易')
  148. return;
  149. }
  150. let trxNum = await bitkeepTron.getBalance('');
  151. if (trxNum < 5) {
  152. tools.error('不低于TRX5')
  153. return
  154. }
  155. let usdtNum = await bitkeepTron.getTokenBalance('', 0);
  156. if (usdtNum < this.investData.invest_money && !tools.isDevelopment()) {
  157. tools.error('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. console.log('transactionData:')
  166. console.log(transactionData)
  167. bitkeepTron.sendTransaction(transactionData).then((res) => {
  168. if (res) {
  169. setInvest({'txid':res,'id':this.investData.id}).then((res)=>{
  170. if(res.code===1){
  171. tools.success(res.msg)
  172. setTimeout(()=>{
  173. tools.leftClick()
  174. },1500)
  175. }else {
  176. this.isAjax = false
  177. tools.error(res.msg)
  178. }
  179. })
  180. } else {
  181. this.isAjax = false
  182. tools.error('交易失败')
  183. }
  184. }).catch((e) => {
  185. this.isAjax = false
  186. tools.error('交易失败')
  187. })
  188. },
  189. setShowLang(){
  190. this.showLang=true
  191. },
  192. onLocaleChange(code){
  193. uni.setLocale(code);
  194. this.$i18n.locale = code;
  195. this.applicationLocale = code;
  196. this.showLang=false
  197. },
  198. setOptionType(optionNum){
  199. if(this.optionNum!==optionNum){
  200. this.optionNum=optionNum
  201. }
  202. },
  203. setListTab(listTab){
  204. if(this.listTab!==listTab){
  205. this.listTab=listTab
  206. }
  207. },
  208. goToUrl(type){
  209. switch (type) {
  210. case 1:
  211. uni.navigateTo({
  212. 'url':'pages/contract/add'
  213. })
  214. }
  215. }
  216. },
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. .index-data{
  221. min-height: 100vh;
  222. .index-top{
  223. height: 120px;
  224. .top-logo{
  225. height: 35px;
  226. padding:10px 16px;
  227. display: flex;
  228. justify-content: space-between;
  229. .logo-img{
  230. width: 68px;
  231. image{
  232. width: 68px;
  233. height: 29px;
  234. }
  235. }
  236. .logo-lang{
  237. height: 35px;
  238. background: rgba(241,134,134,.04);
  239. border-radius: 12px;
  240. border: 1px solid hsla(0,0%,100%,.2);
  241. position: relative;
  242. image{
  243. margin: 0 5px;
  244. height: 35px;
  245. width: 32px;
  246. }
  247. .lang-list{
  248. padding: 0 10px;
  249. position: absolute;
  250. top: 45px;
  251. right: 0;
  252. height: 100px;
  253. word-break: keep-all;
  254. background: #f6f9ff;
  255. border-radius: 13px;
  256. border: 1px solid rgba(39,127,250,.64);
  257. z-index: 99;
  258. .lang-item{
  259. height: 42px;
  260. padding: 0 10px;
  261. margin: 5px 0;
  262. border-radius: 9px;
  263. display: flex;
  264. justify-content: left;
  265. cursor: pointer;
  266. font-size: 18px;
  267. image{
  268. margin-top: 6px;
  269. width: 30px;
  270. height: 30px;
  271. }
  272. .image-ok{
  273. display: none;
  274. }
  275. .image-no{
  276. display: block;
  277. }
  278. .item-vertical{
  279. height: 20px;
  280. width: 1px;
  281. margin: 11px 5px 0 5px;
  282. background: #277ffa;
  283. }
  284. .item-str{
  285. color: #277ffa;
  286. cursor: pointer;
  287. font-size: 18px;
  288. line-height: 42px;
  289. text-align: left;
  290. margin-left: 5px;
  291. }
  292. }
  293. .lang-item-option{
  294. background: #277ffa;
  295. .image-ok{
  296. display: block;
  297. }
  298. .image-no{
  299. display: none;
  300. }
  301. .item-vertical{
  302. background: #fff;
  303. }
  304. .item-str{
  305. color: #fff;
  306. }
  307. }
  308. }
  309. }
  310. }
  311. .top-name{
  312. image{
  313. width: 100vw;
  314. }
  315. }
  316. .top-bg{
  317. height: 270px;
  318. width: 100%;
  319. position: absolute;
  320. left: 0;
  321. top: 0;
  322. overflow: hidden;
  323. z-index: -99;
  324. background: #277ffa!important;
  325. }
  326. }
  327. .index-from{
  328. padding: 6px;
  329. .from-data{
  330. background: #fff;
  331. border-radius: 30px;
  332. width: calc(100vw - 12px);
  333. .from-tab{
  334. position: relative;
  335. width: calc(100vw - 12px);
  336. border-radius: 30px 30px 0 0;
  337. background: #f7f8fa;
  338. height: 38px;
  339. display: flex;
  340. justify-content: space-between;
  341. .tab-item{
  342. width: 50%;
  343. z-index: 1;
  344. .item-content{
  345. height: 38px;
  346. line-height: 38px;
  347. color: #9197a5;
  348. font-size: 16px;
  349. cursor: pointer;
  350. text-align: center;
  351. }
  352. .item-img{
  353. display: none;
  354. z-index: -1;
  355. position: absolute;
  356. top: -2px;
  357. image{
  358. height: 38px;
  359. }
  360. }
  361. .img-left{
  362. left: 0;
  363. }
  364. .img-right{
  365. right: 0;
  366. }
  367. }
  368. .option-tab{
  369. z-index: 3;
  370. .item-content{
  371. color: #000;
  372. z-index: 5;
  373. }
  374. .item-img{
  375. display: block;
  376. }
  377. }
  378. }
  379. .from-data{
  380. border-radius: 0 0 30px 30px;
  381. padding: 20px;
  382. box-sizing: border-box;
  383. .from-icon{
  384. position: relative;
  385. height: 46px;
  386. display: flex;
  387. justify-content: left;
  388. .icon-img{
  389. margin-right: 10px;
  390. image{
  391. height: 46px;
  392. width: 46px;
  393. }
  394. }
  395. .icon-name{
  396. height: 46px;
  397. line-height: 46px;
  398. font-size: 18px;
  399. }
  400. .icon-icon{
  401. position: absolute;
  402. right: 22px;
  403. top: 13px;
  404. image{
  405. width: 20px;
  406. height: 20px;
  407. }
  408. }
  409. }
  410. .from-between{
  411. margin: 18px 0;
  412. height: 2px;
  413. background: #fbfbfd;
  414. }
  415. .from-input{
  416. box-sizing: border-box;
  417. width: 100%;
  418. height: 45px;
  419. border-radius: 17px;
  420. border: 1px solid #f2f5fa;
  421. margin-bottom: 55px;
  422. .input-data{
  423. width: calc(100% - 20px);
  424. height: 45px;
  425. padding: 10px;
  426. background: #f7f8fa;
  427. border-radius: 16px;
  428. .data-money{
  429. height: 20px;
  430. color: #6b6c70;
  431. font-size: 12px;
  432. }
  433. .data-input{
  434. display: flex;
  435. justify-content: space-between;
  436. input{
  437. height: 25px;
  438. width: 100%;
  439. border: none;
  440. font-size: 18px;
  441. background: #f7f8fa;
  442. padding: 1px 2px;
  443. }
  444. button{
  445. font-size: 12px;
  446. -webkit-text-size-adjust: none;
  447. font-weight: 800;
  448. color: #fff;
  449. width: 38px;
  450. height: 18px;
  451. padding: 2px;
  452. border-radius: 5px;
  453. line-height: 15px;
  454. margin-top: 4px;
  455. cursor: pointer;
  456. background: #277ffa;
  457. }
  458. }
  459. }
  460. }
  461. .from-but{
  462. margin-top: 18px;
  463. height: 64px;
  464. button{
  465. height: 64px;
  466. line-height: 64px;
  467. font-size: 24px;
  468. background: #277ffa;
  469. border-radius: 17px;
  470. color: #fff;
  471. }
  472. }
  473. }
  474. }
  475. }
  476. .index-list{
  477. padding:6px 16px;
  478. .list-title{
  479. display: flex;
  480. justify-content: space-between;
  481. .title-data{
  482. display: flex;
  483. justify-content: left;
  484. .title-img{
  485. width: 24px;
  486. height: 24px;
  487. }
  488. .title-str{
  489. font-size: 16px;
  490. line-height: 24px;
  491. color: #292929;
  492. margin-left: 3px;
  493. }
  494. }
  495. .title-all{
  496. font-size: 15px;
  497. font-weight: 400;
  498. color: #3184fa;
  499. cursor: pointer;
  500. padding: 5px 10px;
  501. }
  502. }
  503. .list-tab{
  504. height: 100%;
  505. background: #eaf2ff;
  506. border-radius: 36px;
  507. cursor: pointer;
  508. position: relative;
  509. .tab-items{
  510. z-index: 10;
  511. display: flex;
  512. justify-content: space-between;
  513. border-radius: 36px;
  514. .tab-item{
  515. z-index: 10;
  516. width: calc(100% / 3);
  517. font-size: 13px;
  518. color: #adbad0;
  519. display: block;
  520. height: 32px;
  521. line-height: 32px;
  522. text-align: center;
  523. }
  524. .option-tab{
  525. color: #292929;
  526. }
  527. }
  528. .tab-item-bg{
  529. position: absolute;
  530. border-radius: 36px;
  531. background: #fff;
  532. transition: .5s ease;
  533. height: 32px;
  534. width: calc(100% / 3);
  535. top: 0;
  536. }
  537. .bg-location-1{
  538. left: 0;
  539. transition: .5s ease;
  540. }
  541. .bg-location-2{
  542. left: 33.33%;
  543. transition: .5s ease;
  544. }
  545. .bg-location-3{
  546. left: 66.66%;
  547. transition: .5s ease;
  548. }
  549. }
  550. }
  551. }
  552. </style>