Commit 41e1d16c authored by xhx's avatar xhx

feat:导入

parent 77738ecb
...@@ -13,11 +13,12 @@ ...@@ -13,11 +13,12 @@
import Vue from 'vue'; import Vue from 'vue';
import Component from 'vue-class-component'; import Component from 'vue-class-component';
import { Prop, PropSync } from 'vue-property-decorator'; import { Prop, PropSync } from 'vue-property-decorator';
import { Dialog } from 'vant'; import { Dialog, Field } from 'vant';
@Component({ @Component({
components: { components: {
[Dialog.Component.name]: Dialog.Component [Dialog.Component.name]: Dialog.Component,
'van-field': Field
} }
}) })
export default class InputPasswordDialog extends Vue { export default class InputPasswordDialog extends Vue {
......
...@@ -43,16 +43,6 @@ ...@@ -43,16 +43,6 @@
/> />
</van-radio> </van-radio>
</van-cell> </van-cell>
<!-- <van-cell class="lockstatus_item" title="全锁定" label="不可转账,不可挖矿" clickable @click="radio = '3'">
<img slot="icon" src="@/assets/all_lock@2x.png" alt="">
<van-radio name="3" slot="right-icon">
<img class="radio_icon"
slot="icon"
slot-scope="props"
:src="props.checked ? activeIcon : inactiveIcon "/>
</van-radio>
</van-cell>-->
</van-cell-group> </van-cell-group>
</van-radio-group> </van-radio-group>
</van-dialog> </van-dialog>
...@@ -60,7 +50,7 @@ ...@@ -60,7 +50,7 @@
<script lang='ts'> <script lang='ts'>
import Vue from 'vue'; import Vue from 'vue';
import Component from 'vue-class-component'; import Component from 'vue-class-component';
import { Dialog } from 'vant'; import { Dialog, RadioGroup, Radio, CellGroup, Cell } from 'vant';
import { Prop, PropSync } from 'vue-property-decorator'; import { Prop, PropSync } from 'vue-property-decorator';
// import getNodeStatus from '../mixins/getNodeStatus'; // import getNodeStatus from '../mixins/getNodeStatus';
let activeIcon = require('@/assets/image/activeIcon@2x.png'); let activeIcon = require('@/assets/image/activeIcon@2x.png');
...@@ -68,7 +58,11 @@ let inactiveIcon = require('@/assets/image/inactiveIcon@2x.png'); ...@@ -68,7 +58,11 @@ let inactiveIcon = require('@/assets/image/inactiveIcon@2x.png');
@Component({ @Component({
components: { components: {
[Dialog.Component.name]: Dialog.Component [Dialog.Component.name]: Dialog.Component,
'van-radio-group': RadioGroup,
'van-cell-group': CellGroup,
'van-cell': Cell,
'van-radio': Radio
} }
}) })
export default class LockStatusDialog extends Vue { export default class LockStatusDialog extends Vue {
...@@ -103,10 +97,10 @@ export default class LockStatusDialog extends Vue { ...@@ -103,10 +97,10 @@ export default class LockStatusDialog extends Vue {
</script> </script>
<style scoped> <style scoped>
.van-radio { .van-radio {
height: 0.68rem; /* height: 0.68rem; */
} }
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
.lockstatus_item { .lockstatus_item {
align-items: center; align-items: center;
.van-cell__title { .van-cell__title {
...@@ -114,12 +108,16 @@ export default class LockStatusDialog extends Vue { ...@@ -114,12 +108,16 @@ export default class LockStatusDialog extends Vue {
text-align: left; text-align: left;
} }
img { img {
width: 0.54rem; width: 20px;
height: 0.4rem; height: 16px;
margin-right: 6px;
} }
img.radio_icon { img.radio_icon {
width: 0.48rem; width: 10px;
height: auto; height: auto;
} }
} }
/deep/ .van-nav-bar {
color: #000
}
</style> </style>
\ No newline at end of file
...@@ -6,15 +6,15 @@ ...@@ -6,15 +6,15 @@
</li> </li>
<!-- showLockStatusDialog --> <!-- showLockStatusDialog -->
<li @click="lockStatusHandler"> <li @click="lockStatusHandler">
<div v-if="!walletStatus.isWalletLock"> <div v-if="!walletStatus.isWalletLock" class="block">
<img :src="require(`@/assets/image/full_unlock${isIcon?'_icon':'_button'}@2x.png`)" alt /> <img :src="require(`@/assets/image/full_unlock${isIcon?'_icon':'_button'}@2x.png`)" alt />
<div class="desc active">全解锁</div> <div class="desc active">全解锁</div>
</div> </div>
<div v-else-if="walletStatus.isWalletLock && walletStatus.isTicketLock"> <div v-else-if="walletStatus.isWalletLock && walletStatus.isTicketLock" class="block">
<img :src="require(`@/assets/image/all_lock${isIcon?'_icon':'_button'}@2x.png`)" alt /> <img :src="require(`@/assets/image/all_lock${isIcon?'_icon':'_button'}@2x.png`)" alt />
<div class="desc">全锁定</div> <div class="desc">全锁定</div>
</div> </div>
<div v-else> <div v-else class="block">
<img :src="require(`@/assets/image/mine_unlock${isIcon?'_icon':'_button'}@2x.png`)" alt /> <img :src="require(`@/assets/image/mine_unlock${isIcon?'_icon':'_button'}@2x.png`)" alt />
<div class="desc active" >挖矿解锁</div> <div class="desc active" >挖矿解锁</div>
</div> </div>
...@@ -29,10 +29,7 @@ ...@@ -29,10 +29,7 @@
<div class="desc" :class="[blockSync?'active':'']" > <div class="desc" :class="[blockSync?'active':'']" >
<!-- blockanmation --> <!-- blockanmation -->
<div>区块同步</div> <div>区块同步</div>
<!-- <div v-if="!blockSync"> <div v-if="!isIcon" class="block-height" :class="[blockSync?'active':'']">{{`(${peerHeight})`}}</div>
{{`(${peerHeight})`}}
</div> -->
<!-- {{`(${Math.floor(peerHeight/allHeight * 100)}/100)`}}</div> -->
</div> </div>
</li> </li>
<!-- autoMiningHandler --> <!-- autoMiningHandler -->
...@@ -41,7 +38,7 @@ ...@@ -41,7 +38,7 @@
<img :src="require(`@/assets/image/ticket${isButton}_normal@2x.png`)" v-else alt /> <img :src="require(`@/assets/image/ticket${isButton}_normal@2x.png`)" v-else alt />
<div class="desc" :class="[(walletStatus && !walletStatus.isAutoMining)?'':'active']">自动购票</div> <div class="desc" :class="[(walletStatus && !walletStatus.isAutoMining)?'':'active']">自动购票</div>
</li> </li>
<div v-if="!isIcon" class="block-height" :class="[blockSync?'active':'']">{{`(${peerHeight})`}}</div> <!-- <div v-if="!isIcon" class="block-height" :class="[blockSync?'active':'']">{{`(${peerHeight})`}}</div> -->
</ul> </ul>
</template> </template>
<script lang="ts"> <script lang="ts">
...@@ -106,17 +103,9 @@ export default Vue.extend({ ...@@ -106,17 +103,9 @@ export default Vue.extend({
} }
ul.wallet-status-component{ ul.wallet-status-component{
display: flex; display: flex;
display: grid; align-items: flex-start;
grid-template-columns: repeat(5,1fr); justify-content: center;
place-content: space-between;
padding: 6px 0; padding: 6px 0;
// justify-content: space-between;
.block-height{
grid-column: 3 / span 3;
&.active{
color: rgba(230, 88, 132, 0.7);
}
}
.action{ .action{
width: 100%; width: 100%;
height:auto; height:auto;
...@@ -126,16 +115,27 @@ ul.wallet-status-component{ ...@@ -126,16 +115,27 @@ ul.wallet-status-component{
animation: hue 3s linear infinite; animation: hue 3s linear infinite;
} }
li { li {
flex: 1;
display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center;
text-align: center; text-align: center;
overflow: hidden; overflow: hidden;
div.block {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
img{ img{
width: 14px; width: 50%;
height: auto; height: auto;
} }
div.desc { div.desc {
font-size: 14px; margin-top: 6px;
font-size: 12px;
text-align: center;
&.active { &.active {
color: rgba(230, 88, 132, 0.7); color: rgba(230, 88, 132, 0.7);
} }
......
...@@ -32,8 +32,10 @@ ...@@ -32,8 +32,10 @@
import Vue from 'vue' import Vue from 'vue'
import LockStatusDialog from '@/components/LockStatusDialog.vue'; import LockStatusDialog from '@/components/LockStatusDialog.vue';
import InputPasswordDialog from '@/components/InputPasswordDialog.vue'; import InputPasswordDialog from '@/components/InputPasswordDialog.vue';
import MinerTips from '@/components/MinerTips.vue';
import WalletStatus from '@/components/WalletStatus.vue'; import WalletStatus from '@/components/WalletStatus.vue';
import { getNodeStatus } from '@/utils/getDeviceInfo';
import { rpc } from '@/service/rpc';
import { Toast } from 'vant';
export default Vue.extend({ export default Vue.extend({
components: { components: {
...@@ -44,25 +46,137 @@ export default Vue.extend({ ...@@ -44,25 +46,137 @@ export default Vue.extend({
data() { data() {
return { return {
walletStatus: {} as any, walletStatus: {} as any,
blockSync: {} as any, // blockSync: false,
peerHeight: undefined as undefined|number, // peerHeight: undefined as undefined|number,
allHeight: undefined as undefined|number, // allHeight: undefined as undefined|number,
passwordDialogShow: false, passwordDialogShow: false,
errMsg: {} as any, errMsg: '',
lockStatusDialogShow: false, lockStatusDialogShow: false,
showAction: false, showAction: false,
isSync: false,
ticketCount: undefined as undefined|number,
peersInfo: {} as any,
accounts: {} as any,
password: '',
userSelectedStatus: '',
timer: 0
}
},
computed: {
ip(): string {
console.log(this.$route.params.ip)
return this.$route.params.ip || ''
},
url(): string {
return this.ip ? `http://${this.ip}:8801` : '';
},
peerInfo(): any {
return (
(this.peersInfo && this.peersInfo.peers &&
this.peersInfo.peers.find((peer: any) => {
return peer.self;
})) ||
{}
);
},
peerHeight(): number {
return (this.peerInfo.header && this.peerInfo.header.height) || 0;
},
allHeight(): number {
return (
(this.peersInfo.peers &&
this.peersInfo.peers.reduce(
(acc: number, cur: any) => Math.max(acc, cur.header.height),
0
)) ||
0
);
},
blockSync(): boolean {
return this.peerHeight === this.allHeight;
},
paiWalletInfo():any {
return (
this.accounts && this.accounts.wallets &&
this.accounts.wallets.find((wallet: any) => {
return wallet.label === 'YUAN-miner节点'
}) || {}
)
},
walletLabel():string {
return this.paiWalletInfo.label || ''
}
},
created() {
this.init()
this.timer = setInterval(() => {
let {getTicketCount,getPeerInfo} = rpc;
const {url} = this;
let promise = [getTicketCount.call(rpc,url),getPeerInfo.call(rpc,url)]
Promise.all(promise).then(([ticketCount,peersInfo]) => {
this.ticketCount = ticketCount;
this.peersInfo = peersInfo;
})
}, 2000);
},
beforeDestroy() {
if (this.timer) {
clearInterval(this.timer)
} }
}, },
methods: { methods: {
async init() { async init() {
const {walletStatus,isSync,ticketCount,peersInfo,accounts} = await getNodeStatus({ip:this.ip});
const {walletStatus,isSync,ticketCount,peersInfo,accounts} = await this.getNodeStatus({ip:this.ip});
this.walletStatus = walletStatus; this.walletStatus = walletStatus;
this.isSync = isSync; this.isSync = isSync;
this.ticketCount = ticketCount; this.ticketCount = ticketCount;
this.peersInfo = peersInfo; this.peersInfo = peersInfo;
this.accounts = accounts; this.accounts = accounts;
},
reCheckLockStatusHandler() {
this.passwordDialogShow = false
this.lockStatusDialogShow = true
},
async confirmPasswordHandler(password: string) {
this.errMsg = '';
this.password = password;
if (this.password === '') {
this.errMsg = '请输入密码';
return;
}
try {
let flag = true; // true : 解锁购票 ;false : 解锁整个钱包
if (this.userSelectedStatus === '1') {
flag = false;
}
const {msg} = await rpc.unlock(this.password, flag, 0, this.url);
if (msg) {
if (
['ErrVerifyOldpasswdFail', 'ErrInputPassword'].includes(
msg
)
) {
this.errMsg = '请输入正确的密码';
return;
} else {
throw msg;
}
}
await rpc.lock(this.url);
await rpc.unlock(this.password, flag, 0, this.url);
} catch (err: any) {
Toast(err.message || err);
} finally {
this.init();
}
},
showPasswordDialogHandler(status: string) {
console.log('userSelected status:', status)
this.userSelectedStatus = status
this.passwordDialogShow = true
this.lockStatusDialogShow = false
// this.hideLockStatusDialog();
// this.showPasswordDialog();
} }
} }
}) })
......
...@@ -84,7 +84,7 @@ export default Vue.extend({ ...@@ -84,7 +84,7 @@ export default Vue.extend({
return { return {
pageShow: false, pageShow: false,
wifiName: '', wifiName: '',
devices: [{}] as Array<any>, devices: [] as Array<any>,
isfeedback: false, isfeedback: false,
btyAddress: '' btyAddress: ''
} }
......
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 to comment