Commit 697c181e by zhanghui1

矿机接口数据

parent fac602f9
...@@ -310,6 +310,11 @@ html,body {-webkit-tap-highlight-color: rgba(0, 0, 0,0); font-size: 0.28rem; bac ...@@ -310,6 +310,11 @@ html,body {-webkit-tap-highlight-color: rgba(0, 0, 0,0); font-size: 0.28rem; bac
.top {top:64px;} .top {top:64px;}
} }
} }
.miners{
.page-content{
.top{top:64px;}
}
}
} }
.no { .no {
......
...@@ -62,6 +62,7 @@ export default { ...@@ -62,6 +62,7 @@ export default {
<style lang="less"> <style lang="less">
.tab-bar { .tab-bar {
position: fixed; position: fixed;
z-index: 10;
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
......
<template> <template>
<div class="dashboard bg-blue no"> <div class="dashboard bg-blue no">
<div class="page-header" :class="hasZIndex==true?'zIndexAuto':''" flex="main:justify cross:center"> <div class="page-header" :class="hasZIndex==true?'zIndexAuto':''">
<div class="side" @click="getSide"><i class="iconfont icon-mulu"></i></div> <div class="l" @click="getSide"><span class="icon-side abs-left"><i class="iconfont icon-mulu"></i></span></div>
<div class="title" @click="getRegion">{{account_name}} - {{region_name}}<i class="iconfont icon-down"></i></div> <div class="c" @click="getRegion">{{account_name}} - {{region_name}}<i class="iconfont icon-down"></i></div>
<div class="btn-choose-coin" @click="getCoin"><span :class="coin_type"></span><i class="iconfont icon-down"></i></div> <div class="r" @click="getCoin"><span class="abs-right"><b class="bg-coin" :class="coin_type"></b><i class="iconfont icon-down mr10"></i></span></div>
</div> </div>
<div class="page-content"> <div class="page-content">
<!-- 切换币种 --> <!-- 切换币种 -->
......
<template> <template>
<div class="my-popup"> <div class="my-popup">
<ul> <ul>
<li v-for="(items, index) in sortDate" @click="sortActive(items, index)" :key="items.text" :class="{active:group==items.text}"> <li :class="sideIndex==0?'active':''" @click="sideClick(0,0,'全部')"><span>{{txt[language].quanbu}}</span><i class="iconfont icon-dui"></i></li>
<span>{{items.text}}</span> <li :class="sideIndex==-1?'active':''" @click="sideClick(-1,-1,'默认分组')"><span>{{txt[language].morenfenzu}}</span><i class="iconfont icon-dui"></i></li>
<i class="iconfont icon-dui"></i> <li v-for="(item,index) in group_data" :key="item.group_id" :class="sideIndex==(index+1)?'active':''" @click="sideClick(index+1,item.group_id,item.name)"><span>{{item.name}}</span><i class="iconfont icon-dui"></i></li>
</li>
</ul> </ul>
</div> </div>
</template> </template>
<script> <script>
export default { import fn from '@/utils/function.js'
name:'group', import { mapState } from 'vuex'
export default {
name: 'group',
props: ['group'], props: ['group'],
data(){ data() {
return { return {
sortDate:[{ api: '',
text:'全部' group_data: [], //分组数据
},{ group_id: 0, //默认为全部
text:'默认分组' group_name: "", //切换自定义分组名
},{ status: "ALL", //默认当前状态
text:'北京机房' sideIndex: 0, //默认side为"全部"
},{ }
text:'四川' },
}] computed: {
...mapState(['txt', 'language']),
puid() {
return this.$store.state.puid || localStorage.getItem('puid');
},
coin_type() {
return this.$store.state.coin_type || localStorage.getItem('coin_type');
},
region_id() {
return this.$store.state.region_id || localStorage.getItem('region_id');
},
language() {
return this.$store.state.language || localStorage.getItem('language');
} }
}, },
methods: { methods: {
sortActive(items, index){ getGroup() {
this.$emit("childGroup",items.text) //获取分组
let self = this;
fn.getApiBaseUrl(self.region_id, self.coin_type).then(api => {
this.api = api;
fn.getGroup(api, self.puid).then(res => {
if (res.err_no == 0) {
self.group_data = res.data;
} else {
this.$toast('获取当前子帐户分组信息错误!');
} }
// self.getWorker();
});
});
},
sideClick(sideIndex, group_id, group_name) {
//分组点击事件
let self = this;
this.sideIndex = sideIndex;
this.group_id = group_id;
this.group_name = group_name;
this.status = "ALL";
this.$emit("childGroup", { "sideIndex": this.sideIndex, "group_id": this.group_id, "group_name": this.group_name, "status": this.status })
this.$indicator.open({ spinnerType: 'fading-circle' })
} }
},
mounted() {
this.getGroup();
} }
</script> }
</script>
...@@ -11,13 +11,16 @@ ...@@ -11,13 +11,16 @@
<group :group="messageGroup" v-on:childGroup="formGroup"></group> <group :group="messageGroup" v-on:childGroup="formGroup"></group>
</mt-popup> </mt-popup>
<!-- 切换排序 --> <!-- 切换排序 -->
<mt-popup v-model="showSort" class='show-center'> <mt-actionsheet :actions="sortArray" v-model="showSort" cancelText></mt-actionsheet>
<sort :sort="messageSort" v-on:childSort="fromSort"></sort>
</mt-popup>
<!-- 固定 --> <!-- 固定 -->
<div class="miners-fixed"> <div class="miners-fixed">
<ul class="miners-tab" flex="dir:center box:mean cross:center"> <ul class="miners-tab" flex="dir:center box:mean cross:center">
<li v-for="(items,index) in tablist" @click="tabActive(items,index)" :class="index==i?'active':''"><span><b>{{items.text}}<br>{{items.num}}</b></span></li> <li v-for="items in tablist" @click="tabClick(items.status)" :class="items.status==status?'active':''">
<span v-if="items.status=='ALL'"><b>{{items.text}}<br>{{workers_active+workers_dead+workers_inactive}}</b></span>
<span v-if="items.status=='ACTIVE'"><b>{{items.text}}<br>{{workers_active}}</b></span>
<span v-if="items.status=='INACTIVE'"><b>{{items.text}}<br>{{workers_inactive}}</b></span>
<span v-if="items.status=='DEAD'"><b>{{items.text}}<br>{{workers_dead}}</b></span>
</li>
</ul> </ul>
<div class="miners-sort f-tar"><span @click="getSort"><b><i class="iconfont icon-paixujiang"></i>排序:</b><b>{{messageSort}}<i class="iconfont icon-down"></i></b></span></div> <div class="miners-sort f-tar"><span @click="getSort"><b><i class="iconfont icon-paixujiang"></i>排序:</b><b>{{messageSort}}<i class="iconfont icon-down"></i></b></span></div>
<div class="title list-row"> <div class="title list-row">
...@@ -29,18 +32,18 @@ ...@@ -29,18 +32,18 @@
</div> </div>
</div> </div>
<div class="miners-content"> <div class="miners-content">
<!-- 添加刷新加载位置 --> <mr-better-scroll ref="scroll" class="content-scroll" :pullUpLoad="true" @pullingUp="pullingUp">
<div class="list list-row" v-for="items in tableData" :class="{'redBg':items.status==1,'greyBg':items.status==2} "> <div class="list list-row" v-for="items in tableData" :class="{'redBg':items.status=='INACTIVE','greyBg':items.status=='DEAD'} ">
<div class="s1">{{items.name}} <div class="s1">{{items.worker_name}}
<em v-if="items.status==1" class="red">不活跃</em> <em v-if="items.status=='INACTIVE'" class="red">不活跃</em>
<em v-else-if="items.status==2" class="grey">失效</em> <em v-else-if="items.status=='DEAD'" class="grey">失效</em>
</div> </div>
<div class="s2">{{items.realPower}}<span><b>{{items.unit}}h/</b>s</span></div> <div class="s2">{{items.shares_15m}}<span><b>{{items.unit}}h/</b>s</span></div>
<div class="s3">{{items.dayPower}}<span><b>{{items.unit}}h/</b>s</span></div> <div class="s3">{{items.shares_24h}}<span><b>{{items.unit}}h/</b>s</span></div>
<div class="s4">{{items.refuse}}</div> <div class="s4">{{items.reject_rate| formatPercent2}}</div>
<div class="s5"><i class="iconfont icon-jiantou"></i></div> <div class="s5"><i class="iconfont icon-jiantou"></i></div>
</div> </div>
<!-- 添加刷新加载位置 --> </mr-better-scroll>
</div> </div>
</div> </div>
</div> </div>
...@@ -48,136 +51,132 @@ ...@@ -48,136 +51,132 @@
</template> </template>
<script> <script>
import fn from '@/utils/function.js'; import fn from '@/utils/function.js';
import sort from "@/components/Miners/sort";
import group from "@/components/Miners/group"; import group from "@/components/Miners/group";
export default { export default {
name: 'miners', name: 'miners',
components: { components: {
sort,
group, group,
}, },
data() { data() {
return { return {
showSort: false,
showGroup: false,
messageGroup: '全部',
messageSort: '默认排序',
i: 0,
tablist: [{ tablist: [{
text: '全部', text: '全部',
num: '1006' status: 'ALL'
}, { }, {
text: '活跃', text: '活跃',
num: '1002' status: 'ACTIVE'
}, { }, {
text: '不活跃', text: '不活跃',
num: '107' status: 'INACTIVE'
}, { }, {
text: '失效', text: '失效',
num: '17' status: 'DEAD'
}],
tableData: [{
name: '1103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'T',
status: "1"
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'M',
status: "2"
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'H',
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'T',
status: "1"
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'M',
status: "2"
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'H',
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'T',
status: "1"
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'M',
status: "2"
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'H',
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'T',
status: "1"
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'M',
status: "2"
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'H',
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'T',
status: "1"
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'M',
status: "2"
}, {
name: '3103037',
realPower: '205.204',
dayPower: '252.752',
refuse: '19.45%',
unit: 'H',
}], }],
i: 0, //miners-tab默认第一个选中 workers_active: 0,
hasZIndex: false, workers_dead: 0,
showSort: false, workers_inactive: 0,
showGroup: false,
messageSort: '矿机名 倒序', order_by: '',
messageGroup: '全部' sort: '', //asc
page: 1,
pagesize: 30,
sortArray: [{
name: '默认排序',
method: () => {
this.messageSort = '默认排序';
// puid=78&status=ALL&order_by=worker_name&sort=desc&page=1&pagesize=30
console.log(this.status)
this.order_by = '';
this.sort = '';
this.getWorker();
}
},
{
name: '日算力 低到高',
method: () => {
this.$indicator.open({ spinnerType: 'fading-circle' })
this.messageSort = '日算力 低到高';
this.order_by = 'shares_24h';
this.sort = 'asc';
this.page = 1;
// console.log("排序参数api:",this.api);
// console.log("排序参数puid:",this.puid);
// console.log("排序参数group_id:",this.group_id);
// console.log("排序参数status:",this.status);
// console.log("排序参数order_by:",this.order_by);
// console.log("排序参数page:",this.page);
// console.log("排序参数page_size:",this.page_size);
this.sortWorkder();
}
},
{
name: '日算力 高到低',
method: () => {
this.$indicator.open({ spinnerType: 'fading-circle' })
this.messageSort = '日算力 高到低';
this.order_by = 'shares_24h';
this.sort = 'desc';
this.page = 1;
this.sortWorkder();
}
},
{
name: '矿机名 倒序',
method: () => {
this.$indicator.open({ spinnerType: 'fading-circle' })
this.messageSort = '矿机名 倒序'
this.order_by = 'worker_name';
this.sort = 'desc';
this.page = 1;
this.sortWorkder();
}
},
{
name: '拒绝率 高到低',
method: () => {
this.$indicator.open({ spinnerType: 'fading-circle' })
this.messageSort = '拒绝率 高到低'
this.order_by = 'reject_rate';
this.sort = 'desc';
this.page = 1;
this.sortWorkder();
}
},
{
name: '拒绝率 低到高',
method: () => {
this.$indicator.open({ spinnerType: 'fading-circle' })
this.messageSort = '拒绝率 低到高';
this.order_by = 'reject_rate';
this.sort = 'asc';
this.page = 1;
this.sortWorkder();
}
},
{
name: '最近提交时间',
method: () => {
this.$indicator.open({ spinnerType: 'fading-circle' })
this.messageSort = '最近提交时间';
this.order_by = 'last_share_time';
this.sort = 'desc';
this.page = 1;
this.sortWorkder();
}
}
],
api: '',
group_id: 0,
status: 'ALL',
page_size: 30,
page: 1,
tableData: [],
} }
}, },
computed: { computed: {
...@@ -192,40 +191,122 @@ export default { ...@@ -192,40 +191,122 @@ export default {
}, },
language() { language() {
return this.$store.state.language || localStorage.getItem('language'); return this.$store.state.language || localStorage.getItem('language');
},
scroll() {
return this.$refs.scroll
} }
}, },
mounted() { mounted() {
this.$indicator.close(); this.$indicator.open({ spinnerType: 'fading-circle' })
this.getWorker();
}, },
methods: { methods: {
//矿机详情
goMinerShow(worker_id) { goMinerShow(worker_id) {
//矿机详情
this.$router.push('/my/' + this.puid + '/' + this.coin_type + '/' + this.region_id + '/miners/' + worker_id) this.$router.push('/my/' + this.puid + '/' + this.coin_type + '/' + this.region_id + '/miners/' + worker_id)
}, },
tabClick(status, index) {
//miners-tab点击切换的选中状态 //miners-tab点击切换的选中状态
tabActive(items, index) { this.$indicator.open({ spinnerType: 'fading-circle' })
this.i = index this.status = status;
console.log(items.text) this.page = 1;
if (this.order_by.length > 0) {
this.sortWorkder();
} else {
this.getWorker();
}
}, },
getSort() { getSort() {
this.hasZIndex = true;
this.showSort = !this.showSort; this.showSort = !this.showSort;
this.showGroup = false; this.showGroup = false;
}, },
getGroup() { getGroup() {
this.hasZIndex = false;
this.showGroup = !this.showGroup; this.showGroup = !this.showGroup;
this.showSort = false; this.showSort = false;
}, },
fromSort(msg) {
this.messageSort = msg;
this.showSort = false;
},
formGroup(msg) { formGroup(msg) {
this.messageGroup = msg; // console.log("切换分组信息:", msg)
this.messageGroup = msg.group_name;
this.showGroup = false; this.showGroup = false;
this.group_id = msg.group_id;
this.status = msg.status;
if (this.order_by.length > 0) {
this.sortWorkder()
} else {
this.getWorker()
}
},
getWorker() {
//默认排序下的获取矿机列表
let self = this;
fn.getApiBaseUrl(self.region_id, self.coin_type).then(api => {
this.api = api;
fn.getWorker(api, self.puid, self.group_id, self.status, self.page_size).then(res => {
if (res.data.err_no == 0) {
//console.log("矿机列表", res.data.data.data)
self.tableData = res.data.data.data;
this.workers_active = res.data.data.workers_active;
this.workers_dead = res.data.data.workers_dead;
this.workers_inactive = res.data.data.workers_inactive;
try {
if (res.data.data.data[0].hasOwnProperty("shares_24h")) {
self.hideCol = 1;
} else {
self.hideCol = 0;
}
} catch (e) {
self.hideCol = 0;
} }
} else {
this.$toast("获取矿机数据错误!");
$router.replace({
name: "no",
path: "/my/" + self.$route.params.puid + "/" + self.$route.params.coin_type
});
} }
this.$indicator.close()
});
})
},
sortWorkder() {
//排序方法
fn.sortWorkder(this.api, this.puid, this.group_id, this.status, this.order_by, this.sort, this.page, this.page_size).then(res => {
if (res.data.err_no == 0) {
this.tableData = res.data.data.data;
} else {
this.$toast("获取矿工列表列表错误!");
}
this.$indicator.close()
});
},
pullingUp() {
this.search(this.page + 1)
},
search(page) {
fn.getPaymentHistory(this.api, this.puid, page).then(res => {
if (res.data.data.data.length > 0) {
this.page = page;
this.paymentList.push(res.data.data)
this.scroll.forceUpdate(true)
} else {
this.scroll.forceUpdate(false)
}
})
},
},
} }
</script> </script>
<style lang="less">
.miners {
.list-wrapper.content-scroll {
top: 3.2rem!important;
bottom: 1rem!important;
}
}
</style>
...@@ -218,8 +218,10 @@ export default { ...@@ -218,8 +218,10 @@ export default {
text-align: justify; text-align: justify;
} }
.list-wrapper.content-scroll { .payments {
.list-wrapper.content-scroll {
top: 4.5rem!important; top: 4.5rem!important;
}
} }
</style> </style>
...@@ -48,7 +48,7 @@ axios.interceptors.request.use(config => { ...@@ -48,7 +48,7 @@ axios.interceptors.request.use(config => {
function checkToken() { function checkToken() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve('eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IlEwTTBNRUl4UVRVME5qazJNa0ZFT0RCRk56WkJNVGc0TmtFd09UWkNOakZGTlRFMFEwVTJOdyJ9.eyJpc3MiOiJodHRwczovL2Jsb2NraW4uYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDU5ZjE3OTc5ZDljMGM1MzZiZjRhMzVjMSIsImF1ZCI6WyJodHRwczovL3d3dy5wb29saW4uY29tL2FwaSIsImh0dHBzOi8vYmxvY2tpbi5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNTE3NTM2NjU4LCJleHAiOjE1MTc1NDM4NTgsImF6cCI6IkZhczI5dWJNNW52NElFMlZUQ3ZEWU5iaWtIeTF0bDBkIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSByZWFkIHdyaXRlIn0.tE5v7bvMZSQnW8VvECKXkV1NVIwFpbVDW8iPEr5VO3TmsQnUVCWXz_2yK_jyA8EdK25Cw-Awidhr3kFnMLrz88SYZ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Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment