index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <template>
  2. <view class="index-data">
  3. <view class="index-top">
  4. <top-head></top-head>
  5. <view class="top-text">
  6. <view class="text-item">Use your NFTs as collateral</view>
  7. <view class="text-item"> to borrow ETH or deposit</view>
  8. <view class="text-item"> your ETH and earn yields</view>
  9. <view class="text-item"> instantly!</view>
  10. </view>
  11. <view class="top-but">
  12. <button @click="goToUrl(1)">定金</button>
  13. </view>
  14. <view class="top-bottom">
  15. <image class="bottom-img" src="@/static/img/index/dagou.svg" mode="aspectFill"></image>
  16. <text class="bottom-text">Running SAFE for 236 days. Read more in the</text>
  17. <text class="bottom-text"> Audit report</text>
  18. </view>
  19. </view>
  20. <view class="index-list">
  21. <view class="list-title">
  22. <view class="title-img">
  23. <image src="@/static/img/index/bnb2.png" mode="aspectFill"></image>
  24. </view>
  25. <view class="title-text">我的收支明细(100)</view>
  26. </view>
  27. <division></division>
  28. <view v-for="i in 5" class="item">
  29. <view class="list-item">
  30. <view class="item-line">
  31. <view class="item-text">BNB</view>
  32. </view>
  33. <view class="item-line line-text">
  34. <view class="item-text">平台分润</view>
  35. </view>
  36. <view class="item-line">
  37. <view class="item-text">BNB Number</view>
  38. <view class="item-text text-two">
  39. <view class="text-img">
  40. <image src="@/static/img/index/bnb2.png"></image>
  41. </view>
  42. <view class="text">56</view>
  43. </view>
  44. </view>
  45. <view class="item-line">
  46. <view class="item-text">积分</view>
  47. <view class="item-text text-two">
  48. <view class="text-img">
  49. <image src="@/static/img/index/jf.svg"></image>
  50. </view>
  51. <view class="text">56</view>
  52. </view>
  53. </view>
  54. <view class="item-line">
  55. <view class="item-text">手续费</view>
  56. <view class="item-text">56</view>
  57. </view>
  58. <view class="item-line">
  59. <view class="item-text">时间</view>
  60. <view class="item-text">56</view>
  61. </view>
  62. </view>
  63. <division class="division-item"></division>
  64. </view>
  65. </view>
  66. <view class="index-bottom"></view>
  67. </view>
  68. </template>
  69. <script>
  70. import {getInvestData, setInvest} from "@/api/contract";
  71. import tools from "@/common/js/tools";
  72. import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
  73. import {getMemberInfo} from "@/api/member";
  74. import Division from "@/pages/index/components/division";
  75. import TopHead from "@/pages/index/components/top-head";
  76. export default {
  77. components: {TopHead, Division},
  78. data() {
  79. return {
  80. applicationLocale: '',
  81. systemLocale: '',
  82. showLang: false,
  83. isAjax: false,
  84. langList: [{'name': 'zh-Hans', 'value': '简体中文'}, {'name': 'en', 'value': 'English'}, {
  85. 'name': 'ja',
  86. 'value': '日本語'
  87. }, {'name': 'ko', 'value': '한국어'}],
  88. tabNum: 0,
  89. investData: {
  90. id: 1,
  91. invest_money: '',
  92. sysAddress: "",
  93. sendNum: "",
  94. },
  95. memberData: {
  96. "id": 30,
  97. "address": "",
  98. "invite_code": "72592982",
  99. "level_id": 0,
  100. "levelName": "V0",
  101. "recommendNum": 0,
  102. "teamNum": 0
  103. },
  104. bnbNum: 0,
  105. babAddress: ''
  106. }
  107. },
  108. watch: {},
  109. async onLoad(query) {
  110. this.applicationLocale = uni.getLocale();
  111. this.getInvestData()
  112. this.bnbNum = await tokenpocketBnb.getBalance();
  113. this.getMyData()
  114. },
  115. mounted() {
  116. },
  117. methods: {
  118. goToUrl(type) {
  119. switch (type) {
  120. case 1:
  121. uni.navigateTo({
  122. 'url': 'pages/index/contract'
  123. })
  124. break
  125. case 2:
  126. uni.navigateTo({
  127. 'url': 'pages/index/contract'
  128. })
  129. break
  130. case 3:
  131. uni.navigateTo({
  132. 'url': 'pages/index/contract'
  133. })
  134. break
  135. }
  136. },
  137. setShowLang() {
  138. this.showLang = !this.showLang
  139. },
  140. setTabNum(tabNum) {
  141. if (tabNum !== this.tabNum) {
  142. this.tabNum = tabNum
  143. }
  144. },
  145. getMyData() {
  146. this.babAddress = tokenpocketBnb.getMyAddress()
  147. getMemberInfo().then((res) => {
  148. if (res.code === 1) {
  149. this.memberData = res.data
  150. }
  151. })
  152. },
  153. getInvestData() {
  154. getInvestData().then((res) => {
  155. if (res.code === 1) {
  156. this.investData = res.data
  157. } else {
  158. tools.goToError(4)
  159. }
  160. }).catch((e) => {
  161. tools.goToError(4)
  162. })
  163. },
  164. async setInvest() {
  165. if (this.bnbNum < this.investData.invest_money && !tools.isDevelopment()) {
  166. tools.error(this.$t('index.index.invest.no_usdt'))
  167. return
  168. }
  169. if (this.isAjax) {
  170. return
  171. }
  172. // this.isAjax = true
  173. tokenpocketBnb.getTransactionData(this.investData.sysAddress, 0.0001).then((data) => {
  174. try {
  175. tokenpocketBnb.sendTransaction(data).then((res) => {
  176. this.sendSetInvest(res)
  177. }).catch((e) => {
  178. tools.error(this.$t('index.index.invest.send_no'))
  179. })
  180. } catch (e) {
  181. tools.error(this.$t('index.index.invest.send_no'))
  182. }
  183. })
  184. },
  185. sendSetInvest(hashRes) {
  186. setInvest({'txid': hashRes, 'id': this.investData.id}).then((res) => {
  187. if (res.code === 1) {
  188. tools.success(res.msg)
  189. // setTimeout(()=>{
  190. // tools.leftClick()
  191. // },1500)
  192. } else {
  193. this.isAjax = false
  194. tools.error(res.msg)
  195. }
  196. })
  197. },
  198. },
  199. }
  200. </script>
  201. <style lang="scss" scoped>
  202. //@import "/static/css/common.css";
  203. .index-data {
  204. .index-top {
  205. box-shadow: 0 0 24rpx 0 #000;
  206. box-sizing: border-box;
  207. overflow: hidden;
  208. padding: 40rpx 0;
  209. width: 100%;
  210. background: linear-gradient(0deg, rgb(64, 74, 96) 0%, rgb(9, 21, 36) 100%);
  211. .top-head {
  212. display: flex;
  213. justify-content: space-between;
  214. height: 84rpx;
  215. padding-left: 20rpx;
  216. .head-item {
  217. display: flex;
  218. justify-content: left;
  219. }
  220. .head-left {
  221. .left-img {
  222. margin-top: 1rpx;
  223. image {
  224. width: 80rpx;
  225. height: 80rpx;
  226. }
  227. }
  228. .left-text {
  229. padding-top: 5px;
  230. margin-left: 10px;
  231. .item-item {
  232. font-size: 22rpx;
  233. color: #fff;
  234. }
  235. .item-item:nth-of-type(1) {
  236. font-size: 32rpx;
  237. font-weight: bold;
  238. }
  239. }
  240. }
  241. .head-right {
  242. justify-content: right;
  243. .right-img {
  244. width: 70rpx;
  245. height: 70rpx;
  246. image {
  247. width: 70rpx;
  248. height: 70rpx;
  249. }
  250. }
  251. .right-text {
  252. margin-left: 20rpx;
  253. height: 70rpx;
  254. line-height: 70rpx;
  255. width: 200rpx;
  256. overflow: hidden;
  257. text-overflow: ellipsis;
  258. color: rgb(116, 132, 164);
  259. }
  260. }
  261. }
  262. .top-text {
  263. clear: both;
  264. padding: 40rpx;
  265. margin-top: 40rpx;
  266. .text-item {
  267. color: #fff;
  268. font-size: 50rpx;
  269. font-weight: bold;
  270. }
  271. }
  272. .top-but {
  273. width: 80%;
  274. margin: 60rpx auto 0;
  275. button {
  276. height: 90rpx;
  277. line-height: 90rpx;
  278. text-align: center;
  279. background: rgb(0, 87, 255);
  280. color: #fff;
  281. border-radius: 20rpx;
  282. font-weight: bold;
  283. }
  284. }
  285. .top-bottom {
  286. padding: 40rpx;
  287. .bottom-img {
  288. display: inline-block;
  289. width: 24rpx;
  290. height: 24rpx;
  291. margin-right: 10rpx;
  292. }
  293. .bottom-text {
  294. font-size: 24rpx;
  295. color: #7484a4;
  296. }
  297. .bottom-text:nth-of-type(2) {
  298. margin-left: 0.5em;
  299. text-decoration: underline;
  300. }
  301. }
  302. }
  303. .index-list {
  304. background: #fff;
  305. width: 90%;
  306. margin: 40rpx auto;
  307. border-radius: 10px;
  308. padding: 20px 10px;
  309. overflow: hidden;
  310. font-size: 13px;
  311. box-shadow: 0 8rpx 16rpx 0 rgba(0, 0, 0, 0.08);
  312. .list-title {
  313. display: flex;
  314. justify-content: left;
  315. .title-img {
  316. background: rgb(0, 87, 255);
  317. padding: 10rpx;
  318. border-radius: 20rpx;
  319. image {
  320. width: 80rpx;
  321. height: 80rpx;
  322. }
  323. }
  324. .title-text {
  325. margin-left: 20rpx;
  326. line-height: 100rpx;
  327. font-size: 34rpx;
  328. font-weight: bold;
  329. }
  330. }
  331. .list-item {
  332. margin-top: 20rpx;
  333. .item-line {
  334. margin-bottom: 20rpx;
  335. display: flex;
  336. justify-content: space-between;
  337. .item-text {
  338. font-size: 26rpx;
  339. color: rgb(177, 177, 177);
  340. line-height: 42rpx;
  341. height: 42rpx;
  342. }
  343. .text-two {
  344. display: flex;
  345. justify-content: right;
  346. .text-img {
  347. display: inline-block;
  348. padding: 6rpx;
  349. background: rgb(0, 87, 255);
  350. border-radius: 50%;
  351. height: 42rpx;
  352. width: 42rpx;
  353. box-sizing: border-box;
  354. image {
  355. width: 30rpx;
  356. height: 30rpx;
  357. z-index: 100;
  358. }
  359. }
  360. .text {
  361. margin-left: 10rpx;
  362. font-size: 30rpx;
  363. }
  364. }
  365. }
  366. .line-text {
  367. margin-bottom: 40rpx;
  368. .item-text {
  369. font-weight: bold;
  370. font-size: 26rpx;
  371. color: #222;
  372. }
  373. }
  374. }
  375. .item:last-child {
  376. .division-item {
  377. display: none;
  378. }
  379. }
  380. }
  381. .index-bottom {
  382. height: 50rpx;
  383. }
  384. }
  385. </style>