index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. <template>
  2. <view class="container">
  3. <view class="tiele-index">首页</view>
  4. <view class="swiper">
  5. <view class="swiper-box">
  6. <swiper circular="true" autoplay="true" @change="swiperChange">
  7. <swiper-item v-for="swiper in banner" :key="swiper.id" @click="ToBanner(swiper)"><image :src="swiper.pic"></image></swiper-item>
  8. </swiper>
  9. <view class="indicator"><view class="dots" v-for="(swiper, index) in banner" :class="[swiperCurrent >= index ? 'on' : '']" :key="index"></view></view>
  10. </view>
  11. </view>
  12. <view class="notice-box">
  13. <view class="notice-title flex_item">
  14. <image src="../../static/img/img31.png"></image>
  15. <view class="title">通知</view>
  16. </view>
  17. <view class="notice-list flex">
  18. <view class="notice-tpl" @click="navTo('/pages/index/information')">
  19. <image src="../../static/img/img02.png"></image>
  20. <view class="name">产品专题</view>
  21. </view>
  22. <view class="notice-tpl" @click="navTo('/pages/index/pingtai')">
  23. <!-- @click="navTo('/pages/index/introduce')" -->
  24. <image src="../../static/img/img03.png"></image>
  25. <view class="name">平台介绍</view>
  26. </view>
  27. <view class="notice-tpl" @click="navTo('/pages/index/notice')">
  28. <image src="../../static/img/img04.png"></image>
  29. <view class="name">通知公告</view>
  30. </view>
  31. <view class="notice-tpl" @click="navTo('/pages/index/share')">
  32. <image src="../../static/img/img05.png"></image>
  33. <view class="name">好友邀请</view>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- <image class="logo-img" @click="navTo('/pages/index/information')" src="../../static/img/img44.png"></image> -->
  38. <view class="notice-box">
  39. <!-- <view class="notice-title flex_item">
  40. <image src="../../static/img/img32.png"></image>
  41. <view class="title">行情</view>
  42. </view>
  43. <view class="quotation-list">
  44. <view class="quotation-tpl" v-for="(ls,index) in list" :key='index' v-if="ls.name!='USDT'">
  45. <view class="tpl title">{{ls.name}}/USDT</view>
  46. <view class="tpl num">{{ls.usdt}}</view>
  47. <view class="tpl money">¥{{ls.price}}</view>
  48. <view class="tip-box">
  49. <image src="../../static/img/img30.png"></image>
  50. <view class="tip" v-if="ls.up > 0">{{ls.up * 100}}%</view>
  51. <view class="tip grenn" v-if="ls.up == 0 || ls.up < 0">{{ls.up * 100}}%</view>
  52. </view>
  53. </view>
  54. </view> -->
  55. <view class="title">六牛云储运营数据</view>
  56. <view class="info-box">
  57. <view class="top">
  58. <view class="top-left">Filcoin</view>
  59. <view class="top-right">
  60. <view class="top-right-top">全网算力</view>
  61. <view class="top-right-bottom">{{ filData.netTotalPower }}</view>
  62. </view>
  63. </view>
  64. <view class="middle">
  65. <view class="middle-item">
  66. <view class="item-name">今日新增算力</view>
  67. <view class="item-val">{{ filData.todayAdd }}</view>
  68. </view>
  69. <view class="middle-item">
  70. <view class="item-name text-right">平台总算力</view>
  71. <view class="item-val text-right">{{ filData.siteTotalPower }}</view>
  72. </view>
  73. </view>
  74. <view class="bottom">
  75. <view class="bottom-item">
  76. <view class="item-name" style="color: #FB3A2F;">今日单T产量>>></view>
  77. <view class="item-val">{{ filData.averageReward }} FIL</view>
  78. </view>
  79. <view class="bottom-item">
  80. <view class="item-name text-right">FIL/USDT</view>
  81. <view class="item-val text-right">${{ filData.price }}</view>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="title" style="padding-top: 24rpx;">Swarm资讯</view>
  86. <view class="info-box">
  87. <view class="top">
  88. <view class="top-left">Bzz</view>
  89. <view class="top-right">
  90. <view class="top-right-top"></view>
  91. <view class="top-right-bottom"></view>
  92. </view>
  93. </view>
  94. <view class="middle">
  95. <view class="middle-item">
  96. <view class="item-name">可达节点数量</view>
  97. <view class="item-val">9789.00</view>
  98. </view>
  99. <view class="middle-item">
  100. <view class="item-name text-right">活跃节点总数</view>
  101. <view class="item-val text-right">258125</view>
  102. </view>
  103. </view>
  104. <view class="bottom">
  105. <view class="bottom-item">
  106. <view class="item-name">不可达节点数量</view>
  107. <view class="item-val">254562.00</view>
  108. </view>
  109. <view class="bottom-item">
  110. <view class="item-name text-right">已兑换总额</view>
  111. <view class="item-val text-right">1.9565 gbzz</view>
  112. </view>
  113. </view>
  114. </view>
  115. <view class="title" style="padding-top: 24rpx;">活动中心</view>
  116. <image src="../../static/img/ad.png" mode="" class="ad"></image>
  117. <view class="tit">六牛云储FIL节点</view>
  118. <view class="kg-item" v-for="ls in filUserData">
  119. <view class="item-na">
  120. 矿工号:
  121. <text>{{ ls.name }}</text>
  122. </view>
  123. <view class="item-info">
  124. <view class="item-name">账户余额</view>
  125. <view class="item-val">{{ ls.balance }}FIL</view>
  126. </view>
  127. <view class="item-info">
  128. <view class="item-name">可用余额</view>
  129. <view class="item-val">{{ ls.availableBalance }}FIL</view>
  130. </view>
  131. <view class="item-info">
  132. <view class="item-name">扇区抵押</view>
  133. <view class="item-val">{{ ls.initialPledgeRequirement }}FIL</view>
  134. </view>
  135. <view class="item-info">
  136. <view class="item-name">挖矿锁仓</view>
  137. <view class="item-val">{{ ls.vestingFunds }}FIL</view>
  138. </view>
  139. <view class="item-info">
  140. <view class="item-name">全网占比</view>
  141. <view class="item-val">{{ ls.ratio }}%</view>
  142. </view>
  143. <view class="item-info">
  144. <view class="item-name">全网排名</view>
  145. <view class="item-val">{{ ls.rank }}</view>
  146. </view>
  147. <view class="item-info">
  148. <view class="item-name">原值算力</view>
  149. <view class="item-val">{{ ls.qualityAdjPower }}</view>
  150. </view>
  151. <view class="item-info">
  152. <view class="item-name">累计出块份数</view>
  153. <view class="item-val">{{ ls.weightedBlocksMined }}</view>
  154. </view>
  155. <view class="item-info">
  156. <view class="item-name">累计出块奖励</view>
  157. <view class="item-val">{{ ls.totalRewards }} FIL</view>
  158. </view>
  159. <view class="item-info">
  160. <view class="item-name">扇区大小</view>
  161. <view class="item-val">{{ ls.piece }}GiB</view>
  162. </view>
  163. </view>
  164. </view>
  165. <view class="list-box flex">
  166. <image src="../../static/img/img45.png"></image>
  167. <image src="../../static/img/img46.png"></image>
  168. </view>
  169. </view>
  170. </template>
  171. <script>
  172. import { interceptor } from '@/utils/loginUtils';
  173. import { loadIndexs, moneyType, getFil, getDataYun } from '@/api/index.js';
  174. import { mapState } from 'vuex';
  175. export default {
  176. data() {
  177. return {
  178. swiperCurrent: 0,
  179. banner: [],
  180. list: '',
  181. filData: {},
  182. filUserData: [],
  183. dataType: [
  184. {
  185. name: 'TiB'
  186. },
  187. {
  188. name: 'PiB'
  189. },
  190. {
  191. name: 'EiB'
  192. },
  193. {
  194. name: 'ZiB'
  195. },
  196. {
  197. name: 'YiB'
  198. }
  199. ]
  200. };
  201. },
  202. computed: {
  203. ...mapState(['loginInterceptor', 'hasLogin'])
  204. },
  205. onLoad: function(option) {
  206. if (option.spread) {
  207. // 存储其他邀请人
  208. uni.setStorageSync('spread', option.spread);
  209. }
  210. },
  211. onShow: function() {
  212. // 判断是否强制登录
  213. if (this.loginInterceptor && !this.hasLogin) {
  214. // 登录拦截
  215. interceptor();
  216. } else {
  217. this.loadData();
  218. this.moneyType();
  219. }
  220. this.getFil();
  221. this.getDataYun();
  222. },
  223. //下拉刷新
  224. onPullDownRefresh() {
  225. this.loadData();
  226. this.moneyType();
  227. setTimeout(function() {
  228. uni.stopPullDownRefresh();
  229. }, 1000);
  230. },
  231. methods: {
  232. // 获取数值
  233. filnum: function(data) {
  234. console.log(data);
  235. // 获取数据值
  236. let value = data;
  237. // 获取当前数据大小
  238. let num = 0;
  239. while (value > 1024) {
  240. value = value / 1024;
  241. num++;
  242. }
  243. return value.toFixed(2) + this.dataType[num].name;
  244. },
  245. // 获取云储运营数据
  246. getDataYun() {
  247. getDataYun()
  248. .then(e => {
  249. this.filData = e.data;
  250. this.filData.averageReward = (+e.data.averageReward).toFixed(4);
  251. this.filData.netTotalPower = this.filnum(+e.data.netTotalPower);
  252. this.filData.todayAdd = this.filnum(+e.data.todayAdd);
  253. this.filData.siteTotalPower = this.filnum(+e.data.siteTotalPower);
  254. })
  255. .catch(e => {
  256. console.log(e);
  257. });
  258. },
  259. // 获取矿工数据
  260. getFil() {
  261. getFil()
  262. .then(e => {
  263. this.filUserData = e.data.map(e => {
  264. e.qualityAdjPower = this.filnum(e.qualityAdjPower);
  265. console.log((e.ratio*100));
  266. e.ratio = (e.ratio*100).toFixed(2)
  267. return e;
  268. });
  269. console.log(e);
  270. })
  271. .catch(e => {
  272. console.log(e);
  273. });
  274. },
  275. // 请求载入数据
  276. async loadData() {
  277. let obj = this;
  278. loadIndexs({}).then(({ data }) => {
  279. obj.banner = data.banner;
  280. });
  281. },
  282. moneyType() {
  283. let obj = this;
  284. moneyType({ index: 1 }).then(({ data }) => {
  285. obj.list = data;
  286. console.log('list-----', obj.list);
  287. });
  288. },
  289. /**
  290. * 统一跳转接口,拦截未登录路由
  291. * navigator标签现在默认没有转场动画,所以用view
  292. */
  293. navTo(url) {
  294. uni.navigateTo({
  295. url
  296. });
  297. },
  298. //轮播图
  299. swiperChange(e) {
  300. let index = e.detail.current;
  301. this.swiperCurrent = index;
  302. }
  303. }
  304. };
  305. </script>
  306. <style lang="scss">
  307. page {
  308. min-height: 100%;
  309. background-color: #ffffff;
  310. .container {
  311. width: 100%;
  312. padding: 25rpx 40rpx;
  313. }
  314. }
  315. .tiele-index {
  316. font-weight: 500;
  317. font-size: 50rpx;
  318. padding: 15% 0rpx 30rpx 0rpx;
  319. }
  320. .top-head {
  321. position: fixed;
  322. top: 0;
  323. z-index: 99;
  324. width: 100%;
  325. background-color: #272f41;
  326. padding: 15rpx 35rpx;
  327. color: #edc959;
  328. image {
  329. width: 80rpx;
  330. height: 80rpx;
  331. }
  332. .top-name {
  333. padding-left: 15rpx;
  334. }
  335. }
  336. //轮播图
  337. .swiper {
  338. width: 100%;
  339. display: flex;
  340. justify-content: center;
  341. border-radius: 15rpx;
  342. .swiper-box {
  343. width: 100%;
  344. height: 335rpx;
  345. overflow: hidden;
  346. // box-shadow: 0upx 8upx 25upx rgba(0, 0, 0, 0.2);
  347. //兼容ios,微信小程序
  348. border-radius: 15rpx;
  349. position: relative;
  350. z-index: 1;
  351. swiper {
  352. width: 100%;
  353. height: 100%;
  354. swiper-item {
  355. image {
  356. width: 100%;
  357. height: 100%;
  358. border-radius: 15rpx;
  359. }
  360. }
  361. }
  362. .indicator {
  363. position: absolute;
  364. bottom: 20upx;
  365. left: 20upx;
  366. background-color: rgba(255, 255, 255, 0.4);
  367. width: 150upx;
  368. height: 5upx;
  369. border-radius: 3upx;
  370. overflow: hidden;
  371. display: flex;
  372. .dots {
  373. width: 0upx;
  374. background-color: rgba(255, 255, 255, 1);
  375. transition: all 0.3s ease-out;
  376. &.on {
  377. width: (100%/3);
  378. }
  379. }
  380. }
  381. }
  382. }
  383. .notice-box {
  384. .text-right {
  385. text-align: right;
  386. }
  387. padding: 40rpx 0rpx;
  388. .title {
  389. font-size: 28rpx;
  390. padding-bottom: 19rpx;
  391. font-family: PingFang SC;
  392. font-weight: bold;
  393. color: #000000;
  394. position: relative;
  395. left: -13rpx;
  396. }
  397. .info-box {
  398. width: 678rpx;
  399. height: 282rpx;
  400. margin: 0 auto;
  401. background: #ffffff;
  402. border: 2px solid #5771df;
  403. border-radius: 5rpx;
  404. padding: 15rpx 22rpx 25rpx;
  405. font-size: 22rpx;
  406. font-family: PingFang SC;
  407. font-weight: 500;
  408. color: #333333;
  409. // line-height: 1;
  410. display: flex;
  411. flex-direction: column;
  412. justify-content: space-between;
  413. // justify-content: ;
  414. .top {
  415. display: flex;
  416. align-items: center;
  417. justify-content: space-between;
  418. .top-left {
  419. font-size: 63rpx;
  420. font-family: PingFang SC;
  421. font-weight: bold;
  422. color: #5771df;
  423. }
  424. .top-right {
  425. text-align: right;
  426. .top-right-bottom {
  427. font-size: 30rpx;
  428. font-family: PingFang SC;
  429. font-weight: bold;
  430. color: #5771df;
  431. }
  432. }
  433. }
  434. .middle {
  435. display: flex;
  436. justify-content: space-between;
  437. .middle-item {
  438. display: flex;
  439. flex-direction: column;
  440. .item-val {
  441. font-size: 30rpx;
  442. font-family: PingFang SC;
  443. font-weight: bold;
  444. color: #5771df;
  445. }
  446. }
  447. }
  448. .bottom {
  449. display: flex;
  450. justify-content: space-between;
  451. .item-val {
  452. display: flex;
  453. // justify-content: ;
  454. font-size: 30rpx;
  455. font-family: PingFang SC;
  456. font-weight: bold;
  457. color: #5771df;
  458. }
  459. }
  460. }
  461. .ad {
  462. display: block;
  463. margin: 0 auto;
  464. width: 678rpx;
  465. height: 162rpx;
  466. }
  467. .tit {
  468. margin: 0 auto;
  469. margin-top: 31rpx;
  470. width: 678rpx;
  471. height: 59rpx;
  472. background: #5771df;
  473. border-radius: 5rpx;
  474. text-align: center;
  475. font-size: 28rpx;
  476. font-family: PingFang SC;
  477. font-weight: bold;
  478. color: #ffffff;
  479. line-height: 59rpx;
  480. }
  481. .kg-item {
  482. height: 100%;
  483. height: 610rpx;
  484. border-bottom: 1px solid #f3f4f6;
  485. padding: 40rpx 17rpx 0;
  486. line-height: 1;
  487. font-size: 28rpx;
  488. font-family: PingFang SC;
  489. font-weight: bold;
  490. color: #333333;
  491. .item-na {
  492. padding-bottom: 39rpx;
  493. text {
  494. color: #fb3a2f;
  495. }
  496. }
  497. .item-info {
  498. padding-left: 16rpx;
  499. font-size: 24rpx;
  500. font-family: PingFang SC;
  501. font-weight: bold;
  502. color: #333333;
  503. line-height: 1;
  504. padding-bottom: 24rpx;
  505. display: flex;
  506. justify-content: space-between;
  507. }
  508. }
  509. .notice-title {
  510. padding-bottom: 30rpx;
  511. image {
  512. width: 35rpx;
  513. height: 32rpx;
  514. }
  515. .title {
  516. font-size: 34rpx;
  517. font-weight: bold;
  518. font-style: italic;
  519. color: #333333;
  520. margin-left: 15rpx;
  521. }
  522. }
  523. .notice-list {
  524. .notice-tpl {
  525. image {
  526. width: 99rpx;
  527. height: 113rpx;
  528. }
  529. .name {
  530. font-size: 26rpx;
  531. color: #5d616d;
  532. }
  533. }
  534. }
  535. }
  536. .logo-img {
  537. width: 100%;
  538. height: 210rpx;
  539. }
  540. .quotation-list {
  541. display: flex;
  542. flex-wrap: wrap;
  543. .quotation-tpl {
  544. position: relative;
  545. padding: 22rpx 24rpx;
  546. height: 220rpx;
  547. overflow: hidden;
  548. display: flex;
  549. flex-direction: column;
  550. width: 31%;
  551. margin-bottom: 4%;
  552. margin-right: 2%;
  553. // &:nth-child(2n + 1) {
  554. // margin-right: 2%;
  555. // }
  556. .tpl {
  557. z-index: 99;
  558. position: relative;
  559. font-size: 24rpx;
  560. padding-bottom: 10rpx;
  561. }
  562. .title {
  563. color: #333333;
  564. font-weight: bold;
  565. padding-bottom: 21rpx !important;
  566. }
  567. .num {
  568. color: #fb3a2f;
  569. }
  570. .money {
  571. color: #666666;
  572. }
  573. .tip-box {
  574. image {
  575. width: 100%;
  576. height: 118rpx;
  577. position: absolute;
  578. bottom: 0;
  579. left: 0;
  580. }
  581. .tip {
  582. position: relative;
  583. color: #fb3a2f;
  584. font-size: 26rpx;
  585. text-align: center;
  586. font-weight: 600;
  587. padding-top: 25rpx;
  588. }
  589. .grenn {
  590. color: #606266;
  591. }
  592. }
  593. }
  594. }
  595. .list-box {
  596. image {
  597. width: 326rpx;
  598. height: 210rpx;
  599. }
  600. }
  601. </style>