浏览代码

2021-7-10

cmy 4 年之前
父节点
当前提交
9939f3854d
共有 3 个文件被更改,包括 172 次插入183 次删除
  1. 17 0
      api/index.js
  2. 2 2
      manifest.json
  3. 153 181
      pages/index/index.vue

+ 17 - 0
api/index.js

@@ -29,5 +29,22 @@ export function details(data,id) {
 		data
 	});
 }
+// 获取fil节点
+export function getFil(data,id) {
+	return request({
+		url: '/api/fil_miner_view',
+		method: 'GET',
+		data
+	});
+}
+// 获取云储数据
+export function getDataYun(data) {
+	return request({
+		url: '/api/fil_overview',
+		method: 'GET',
+		data
+	});
+}
+
 
 

+ 2 - 2
manifest.json

@@ -4,8 +4,8 @@
     // __UNI__6FC8B70
     // "appid" : "__UNI__6FC8B70",
     "description" : "",
-    "versionName" : "1.2.1",
-    "versionCode" : 121,
+    "versionName" : "1.2.2",
+    "versionCode" : 122,
     "transformPx" : false,
     "app-plus" : {
         /* 5+App特有相关 */

+ 153 - 181
pages/index/index.vue

@@ -19,7 +19,8 @@
 					<image src="../../static/img/img02.png"></image>
 					<view class="name">产品专题</view>
 				</view>
-				<view class="notice-tpl" @click="navTo('/pages/index/pingtai')"> <!-- @click="navTo('/pages/index/introduce')" -->
+				<view class="notice-tpl" @click="navTo('/pages/index/pingtai')">
+					<!-- @click="navTo('/pages/index/introduce')" -->
 					<image src="../../static/img/img03.png"></image>
 					<view class="name">平台介绍</view>
 				</view>
@@ -51,205 +52,113 @@
 					</view>
 				</view>
 			</view> -->
-			<view class="title">
-				六牛云储运营数据
-			</view>
+			<view class="title">六牛云储运营数据</view>
 			<view class="info-box">
 				<view class="top">
 					<view class="top-left">Filcoin</view>
 					<view class="top-right">
-						<view class="top-right-top">
-							全网算力
-						</view>
-						<view class="top-right-bottom">
-							7.255 EiB
-						</view>
+						<view class="top-right-top">全网算力</view>
+						<view class="top-right-bottom">{{ filData.netTotalPower }}</view>
 					</view>
 				</view>
 				<view class="middle">
 					<view class="middle-item">
-						<view class="item-name">
-							今日新增算力
-						</view>
-						<view class="item-val">
-							285.77 TiB
-						</view>
+						<view class="item-name">今日新增算力</view>
+						<view class="item-val">{{ filData.todayAdd }}</view>
 					</view>
 					<view class="middle-item">
-						<view class="item-name text-right">
-							平台总算力
-						</view>
-						<view class="item-val text-right">
-							25.770 PiB
-						</view>
+						<view class="item-name text-right">平台总算力</view>
+						<view class="item-val text-right">{{ filData.siteTotalPower }}</view>
 					</view>
 				</view>
 				<view class="bottom">
 					<view class="bottom-item">
-						<view class="item-name" style="color: #FB3A2F;">
-							今日单T产量>>>
-						</view>
-						<view class="item-val">
-							0.0255 FIL
-						</view>
+						<view class="item-name" style="color: #FB3A2F;">今日单T产量>>></view>
+						<view class="item-val">{{ filData.averageReward }} FIL</view>
 					</view>
 					<view class="bottom-item">
-						<view class="item-name text-right">
-							FIL/USDT
-						</view>
-						<view class="item-val text-right">
-							$53.800
-						</view>
+						<view class="item-name text-right">FIL/USDT</view>
+						<view class="item-val text-right">${{ filData.price }}</view>
 					</view>
 				</view>
 			</view>
-			<view class="title" style="padding-top: 24rpx;">
-				Swarm资讯
-			</view>
+			<view class="title" style="padding-top: 24rpx;">Swarm资讯</view>
 			<view class="info-box">
 				<view class="top">
 					<view class="top-left">Bzz</view>
 					<view class="top-right">
-						<view class="top-right-top">
-							
-						</view>
-						<view class="top-right-bottom">
-							
-						</view>
+						<view class="top-right-top"></view>
+						<view class="top-right-bottom"></view>
 					</view>
 				</view>
 				<view class="middle">
 					<view class="middle-item">
-						<view class="item-name">
-							可达节点数量
-						</view>
-						<view class="item-val">
-							9789.00
-						</view>
+						<view class="item-name">可达节点数量</view>
+						<view class="item-val">9789.00</view>
 					</view>
 					<view class="middle-item">
-						<view class="item-name text-right">
-							活跃节点总数
-						</view>
-						<view class="item-val text-right">
-							258125
-						</view>
+						<view class="item-name text-right">活跃节点总数</view>
+						<view class="item-val text-right">258125</view>
 					</view>
 				</view>
 				<view class="bottom">
 					<view class="bottom-item">
-						<view class="item-name">
-							不可达节点数量
-						</view>
-						<view class="item-val">
-							254562.00
-						</view>
+						<view class="item-name">不可达节点数量</view>
+						<view class="item-val">254562.00</view>
 					</view>
 					<view class="bottom-item">
-						<view class="item-name text-right">
-							已兑换总额
-						</view>
-						<view class="item-val text-right">
-							1.9565 gbzz
-						</view>
+						<view class="item-name text-right">已兑换总额</view>
+						<view class="item-val text-right">1.9565 gbzz</view>
 					</view>
 				</view>
 			</view>
-			<view class="title" style="padding-top: 24rpx;">
-				活动中心
-			</view>
+			<view class="title" style="padding-top: 24rpx;">活动中心</view>
 			<image src="../../static/img/ad.png" mode="" class="ad"></image>
-			<view class="tit">
-				六牛云储FIL节点
-			</view>
-			<view class="kg-item">
-				<view class="item-na">
-					矿工号:<text>f073844</text>
-				</view>
-				<view class="item-info">
-					<view class="item-name">账户余额</view>
-					<view class="item-val">152415.2 FIL</view>
-				</view>
-				<view class="item-info">
-					<view class="item-name">可用余额</view>
-					<view class="item-val">1725.123 FIL</view>
-				</view>
-				<view class="item-info">
-					<view class="item-name">扇区抵押</view>
-					<view class="item-val">100961.12 FIL</view>
-				</view>
-				<view class="item-info">
-					<view class="item-name">挖矿锁仓</view>
-					<view class="item-val">15996.266 FIL</view>
-				</view>
-				<view class="item-info">
-					<view class="item-name">全网占比</view>
-					<view class="item-val">0.15%</view>
-				</view>
-				<view class="item-info">
-					<view class="item-name">全网排名</view>
-					<view class="item-val">142</view>
-				</view>
-				<view class="item-info">
-					<view class="item-name">原值算力</view>
-					<view class="item-val">10.23 PiiB</view>
-				</view>
-				<view class="item-info">
-					<view class="item-name">累计出块份数</view>
-					<view class="item-val">5554</view>
-				</view>
-				<view class="item-info">
-					<view class="item-name">累计出块奖励</view>
-					<view class="item-val">125236.08 FIL</view>
-				</view>
-				<view class="item-info">
-					<view class="item-name">扇区大小</view>
-					<view class="item-val">32.0GiB</view>
-				</view>
-			</view>
-			<view class="kg-item">
+			<view class="tit">六牛云储FIL节点</view>
+			<view class="kg-item" v-for="ls in filUserData">
 				<view class="item-na">
-					矿工号:<text>f020742</text>
+					矿工号:
+					<text>{{ ls.name }}</text>
 				</view>
 				<view class="item-info">
 					<view class="item-name">账户余额</view>
-					<view class="item-val">152415.2 FIL</view>
+					<view class="item-val">{{ ls.balance }}FIL</view>
 				</view>
 				<view class="item-info">
 					<view class="item-name">可用余额</view>
-					<view class="item-val">1725.123 FIL</view>
+					<view class="item-val">{{ ls.availableBalance }}FIL</view>
 				</view>
 				<view class="item-info">
 					<view class="item-name">扇区抵押</view>
-					<view class="item-val">100961.12 FIL</view>
+					<view class="item-val">{{ ls.initialPledgeRequirement }}FIL</view>
 				</view>
 				<view class="item-info">
 					<view class="item-name">挖矿锁仓</view>
-					<view class="item-val">15996.266 FIL</view>
+					<view class="item-val">{{ ls.vestingFunds }}FIL</view>
 				</view>
 				<view class="item-info">
 					<view class="item-name">全网占比</view>
-					<view class="item-val">0.15%</view>
+					<view class="item-val">{{ ls.ratio }}%</view>
 				</view>
 				<view class="item-info">
 					<view class="item-name">全网排名</view>
-					<view class="item-val">142</view>
+					<view class="item-val">{{ ls.rank }}</view>
 				</view>
 				<view class="item-info">
 					<view class="item-name">原值算力</view>
-					<view class="item-val">10.23 PiiB</view>
+					<view class="item-val">{{ ls.qualityAdjPower }}</view>
 				</view>
 				<view class="item-info">
 					<view class="item-name">累计出块份数</view>
-					<view class="item-val">5554</view>
+					<view class="item-val">{{ ls.weightedBlocksMined }}</view>
 				</view>
 				<view class="item-info">
 					<view class="item-name">累计出块奖励</view>
-					<view class="item-val">125236.08 FIL</view>
+					<view class="item-val">{{ ls.totalRewards }} FIL</view>
 				</view>
 				<view class="item-info">
 					<view class="item-name">扇区大小</view>
-					<view class="item-val">32.0GiB</view>
+					<view class="item-val">{{ ls.piece }}GiB</view>
 				</view>
 			</view>
 		</view>
@@ -261,18 +170,37 @@
 </template>
 <script>
 import { interceptor } from '@/utils/loginUtils';
-import { loadIndexs,moneyType } from '@/api/index.js';
+import { loadIndexs, moneyType, getFil, getDataYun } from '@/api/index.js';
 import { mapState } from 'vuex';
 export default {
 	data() {
 		return {
 			swiperCurrent: 0,
 			banner: [],
-			list:''
+			list: '',
+			filData: {},
+			filUserData: [],
+			dataType: [
+				{
+					name: 'TiB'
+				},
+				{
+					name: 'PiB'
+				},
+				{
+					name: 'EiB'
+				},
+				{
+					name: 'ZiB'
+				},
+				{
+					name: 'YiB'
+				}
+			]
 		};
 	},
 	computed: {
-		...mapState(['loginInterceptor','hasLogin']),
+		...mapState(['loginInterceptor', 'hasLogin'])
 	},
 	onLoad: function(option) {
 		if (option.spread) {
@@ -285,32 +213,77 @@ export default {
 		if (this.loginInterceptor && !this.hasLogin) {
 			// 登录拦截
 			interceptor();
-		}else{
+		} else {
 			this.loadData();
 			this.moneyType();
 		}
+		this.getFil();
+		this.getDataYun();
 	},
 	//下拉刷新
 	onPullDownRefresh() {
 		this.loadData();
 		this.moneyType();
-		setTimeout(function () {
+		setTimeout(function() {
 			uni.stopPullDownRefresh();
 		}, 1000);
 	},
 	methods: {
+		// 获取数值
+		filnum: function(data) {
+			console.log(data);
+			// 获取数据值
+			let value = data;
+			// 获取当前数据大小
+			let num = 0;
+			while (value > 1024) {
+				value = value / 1024;
+				num++;
+			}
+			return value.toFixed(2) + this.dataType[num].name;
+		},
+		// 获取云储运营数据
+		getDataYun() {
+			getDataYun()
+				.then(e => {
+					this.filData = e.data;
+					this.filData.averageReward = (+e.data.averageReward).toFixed(4);
+					this.filData.netTotalPower = this.filnum(+e.data.netTotalPower);
+					this.filData.todayAdd = this.filnum(+e.data.todayAdd);
+					this.filData.siteTotalPower = this.filnum(+e.data.siteTotalPower);
+				})
+				.catch(e => {
+					console.log(e);
+				});
+		},
+		// 获取矿工数据
+		getFil() {
+			getFil()
+				.then(e => {
+					this.filUserData = e.data.map(e => {
+						e.qualityAdjPower = this.filnum(e.qualityAdjPower);
+						console.log((e.ratio*100));
+						e.ratio = (e.ratio*100).toFixed(2)
+						return e;
+					});
+					console.log(e);
+				})
+				.catch(e => {
+					console.log(e);
+				});
+		},
 		// 请求载入数据
 		async loadData() {
 			let obj = this;
 			loadIndexs({}).then(({ data }) => {
-			   obj.banner = data.banner;
+				obj.banner = data.banner;
 			});
 		},
-		moneyType(){
+		moneyType() {
 			let obj = this;
-			moneyType({index:1}).then(({ data }) => {
-			   obj.list = data;
-			   console.log('list-----',obj.list)
+			moneyType({ index: 1 }).then(({ data }) => {
+				obj.list = data;
+				console.log('list-----', obj.list);
 			});
 		},
 		/**
@@ -326,7 +299,7 @@ export default {
 		swiperChange(e) {
 			let index = e.detail.current;
 			this.swiperCurrent = index;
-		},
+		}
 	}
 };
 </script>
@@ -340,7 +313,7 @@ page {
 		padding: 25rpx 40rpx;
 	}
 }
-.tiele-index{
+.tiele-index {
 	font-weight: 500;
 	font-size: 50rpx;
 	padding: 15% 0rpx 30rpx 0rpx;
@@ -408,7 +381,7 @@ page {
 		}
 	}
 }
-.notice-box{
+.notice-box {
 	.text-right {
 		text-align: right;
 	}
@@ -426,8 +399,8 @@ page {
 		width: 678rpx;
 		height: 282rpx;
 		margin: 0 auto;
-		background: #FFFFFF;
-		border: 2px solid #5771DF;
+		background: #ffffff;
+		border: 2px solid #5771df;
 		border-radius: 5rpx;
 		padding: 15rpx 22rpx 25rpx;
 		font-size: 22rpx;
@@ -447,7 +420,7 @@ page {
 				font-size: 63rpx;
 				font-family: PingFang SC;
 				font-weight: bold;
-				color: #5771DF;
+				color: #5771df;
 			}
 			.top-right {
 				text-align: right;
@@ -455,7 +428,7 @@ page {
 					font-size: 30rpx;
 					font-family: PingFang SC;
 					font-weight: bold;
-					color: #5771DF;
+					color: #5771df;
 				}
 			}
 		}
@@ -469,7 +442,7 @@ page {
 					font-size: 30rpx;
 					font-family: PingFang SC;
 					font-weight: bold;
-					color: #5771DF;
+					color: #5771df;
 				}
 			}
 		}
@@ -482,7 +455,7 @@ page {
 				font-size: 30rpx;
 				font-family: PingFang SC;
 				font-weight: bold;
-				color: #5771DF;
+				color: #5771df;
 			}
 		}
 	}
@@ -497,19 +470,19 @@ page {
 		margin-top: 31rpx;
 		width: 678rpx;
 		height: 59rpx;
-		background: #5771DF;
+		background: #5771df;
 		border-radius: 5rpx;
 		text-align: center;
 		font-size: 28rpx;
 		font-family: PingFang SC;
 		font-weight: bold;
-		color: #FFFFFF;
+		color: #ffffff;
 		line-height: 59rpx;
 	}
 	.kg-item {
 		height: 100%;
 		height: 610rpx;
-		border-bottom: 1px solid #F3F4F6;
+		border-bottom: 1px solid #f3f4f6;
 		padding: 40rpx 17rpx 0;
 		line-height: 1;
 		font-size: 28rpx;
@@ -519,7 +492,7 @@ page {
 		.item-na {
 			padding-bottom: 39rpx;
 			text {
-				color:#FB3A2F;
+				color: #fb3a2f;
 			}
 		}
 		.item-info {
@@ -534,13 +507,13 @@ page {
 			justify-content: space-between;
 		}
 	}
-	.notice-title{
+	.notice-title {
 		padding-bottom: 30rpx;
-		image{
-			width:35rpx;
+		image {
+			width: 35rpx;
 			height: 32rpx;
 		}
-		.title{
+		.title {
 			font-size: 34rpx;
 			font-weight: bold;
 			font-style: italic;
@@ -548,83 +521,82 @@ page {
 			margin-left: 15rpx;
 		}
 	}
-	.notice-list{
-		.notice-tpl{
-			image{
+	.notice-list {
+		.notice-tpl {
+			image {
 				width: 99rpx;
 				height: 113rpx;
 			}
-			.name{
+			.name {
 				font-size: 26rpx;
-				color: #5D616D;
+				color: #5d616d;
 			}
-		}	
+		}
 	}
 }
-.logo-img{
+.logo-img {
 	width: 100%;
 	height: 210rpx;
 }
-.quotation-list{
+.quotation-list {
 	display: flex;
 	flex-wrap: wrap;
-	.quotation-tpl{
+	.quotation-tpl {
 		position: relative;
 		padding: 22rpx 24rpx;
 		height: 220rpx;
 		overflow: hidden;
 		display: flex;
 		flex-direction: column;
-		width:31%;
+		width: 31%;
 		margin-bottom: 4%;
 		margin-right: 2%;
 		// &:nth-child(2n + 1) {
 		// 	margin-right: 2%;
 		// }
-		.tpl{
+		.tpl {
 			z-index: 99;
 			position: relative;
 			font-size: 24rpx;
 			padding-bottom: 10rpx;
 		}
-		.title{
+		.title {
 			color: #333333;
 			font-weight: bold;
 			padding-bottom: 21rpx !important;
 		}
-		.num{
-			color: #FB3A2F;
+		.num {
+			color: #fb3a2f;
 		}
-		.money{
+		.money {
 			color: #666666;
 		}
-		.tip-box{
-			image{
+		.tip-box {
+			image {
 				width: 100%;
 				height: 118rpx;
 				position: absolute;
 				bottom: 0;
 				left: 0;
 			}
-			.tip{
+			.tip {
 				position: relative;
-				color: #FB3A2F;
+				color: #fb3a2f;
 				font-size: 26rpx;
 				text-align: center;
 				font-weight: 600;
 				padding-top: 25rpx;
 			}
-			.grenn{
+			.grenn {
 				color: #606266;
 			}
-			
 		}
 	}
 }
-.list-box{
-	image{
+.list-box {
+	image {
 		width: 326rpx;
 		height: 210rpx;
 	}
 }
-</style>
+</style>