Commit 8051a625 authored by xhx's avatar xhx

委托限制

parent 685167f1
...@@ -6,16 +6,40 @@ ...@@ -6,16 +6,40 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue' import Vue from 'vue'
import { isBind } from '@/service/pool'
import service from '@/service/chain33'
import { closeWebview } from '@/utils/bridge'
// import { getCurrentBTYAddress } from '@/utils/bridge' // 币钱包环境 // import { getCurrentBTYAddress } from '@/utils/bridge' // 币钱包环境
import { test } from '@/utils/test' // 本地测试 import { test } from '@/utils/test' // 本地测试
import { Toast } from 'vant'
export default Vue.extend({ export default Vue.extend({
mounted() { methods: {
// 账号是否能进入挖矿
async hasPoolAddr(addr: string) {
const response = await service.getTicketAddress(addr)
console.log(response)
if (response.data.result?.data) {
isBind(response.data.result?.data).catch((res: any) => {
console.log(res.response)
const reason = res.response.data.reason
if (reason) {
Toast('该用户已开启挖矿')
setTimeout(() => {
closeWebview()
}, 1000)
}
})
}
}
},
created() {
// getCurrentBTYAddress('',(res: any) => { // getCurrentBTYAddress('',(res: any) => {
// console.log('res', res) // console.log('res', res)
// this.$store.commit('app/SET_ADDRESS', res) // this.$store.commit('app/SET_ADDRESS', res)
// console.log(this.$store.state.app.address) // this.hasPoolAddr(res)
// }) // })
this.$store.commit('app/SET_ADDRESS', test.addr) this.$store.commit('app/SET_ADDRESS', test.addr)
this.hasPoolAddr(test.addr)
} }
}) })
</script> </script>
......
<template>
<div class="">
</div>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
props: {
height: {
type: String,
default: ''
}
}
})
</script>
\ No newline at end of file
...@@ -47,7 +47,8 @@ export default Vue.extend({ ...@@ -47,7 +47,8 @@ export default Vue.extend({
}, },
methods: { methods: {
goMining() { goMining() {
this.$router.push({ path: '/details', query: { id: (this.info as any).id || '1' }}) this.$emit('goDetails', (this.info as any).id)
// this.$router.push({ path: '/details', query: { id: (this.info as any).id || '1' }})
} }
} }
}) })
......
...@@ -2,7 +2,6 @@ import { request } from "./service"; ...@@ -2,7 +2,6 @@ import { request } from "./service";
import axios from 'axios' import axios from 'axios'
import { sign } from '@/utils/bridge' import { sign } from '@/utils/bridge'
import { rawTransaction } from "@/type/request"; import { rawTransaction } from "@/type/request";
import { Toast } from "vant";
// import { test } from '@/utils/test' // import { test } from '@/utils/test'
const service = request('http://172.16.100.59:8801') const service = request('http://172.16.100.59:8801')
...@@ -155,5 +154,21 @@ export default { ...@@ -155,5 +154,21 @@ export default {
txs: any txs: any
}) { }) {
return chainRequire('Chain33.CreateRawTxGroup', [data]) return chainRequire('Chain33.CreateRawTxGroup', [data])
},
getTicketAddress: function (addr: string) {
return service.request({
data: {
method: 'Chain33.Query',
params: [{
execer: 'ticket',
funcName: 'MinerAddress',
payload: {
data: addr
}
}]
},
method: 'POST'
})
} }
} }
\ No newline at end of file
...@@ -44,6 +44,15 @@ export const checkBind = function(id: string) { ...@@ -44,6 +44,15 @@ export const checkBind = function(id: string) {
} }
/** /**
* 用户是否绑定挖矿
* @param id
* @returns
*/
export const isBind = function(addr: string) {
return service.get('/web/is-bind', { params: { addr }})
}
/**
* 矿池信息 * 矿池信息
* @param id * @param id
* @returns * @returns
......
...@@ -3,4 +3,5 @@ const _jsBridge = new jsBridge() ...@@ -3,4 +3,5 @@ const _jsBridge = new jsBridge()
export const sign = (params: any, fn?: Function) => _jsBridge.sign(params, fn) export const sign = (params: any, fn?: Function) => _jsBridge.sign(params, fn)
export const getCurrentBTYAddress = (params: any, fn?: Function) => _jsBridge.getCurrentBTYAddress(params, fn) export const getCurrentBTYAddress = (params: any, fn?: Function) => _jsBridge.getCurrentBTYAddress(params, fn)
export const signGroup = (params: any, fn?: Function) => _jsBridge.signTxGroup(params, fn) export const signGroup = (params: any, fn?: Function) => _jsBridge.signTxGroup(params, fn)
\ No newline at end of file export const closeWebview = () => _jsBridge.closeCurrentWebview()
\ No newline at end of file
// export const test = { // export const test = {
// addr: '16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp', // addr: '13SnepxL5RELnLwxGTWFkMJMgMJqJhP4FV',
// privateKey: '0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944' // privateKey: '0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944'
// } // }
// export const test = { // export const test = {
......
<template>
<div class="bg-gradient-7 py-2 text-13px text-brown3 flex items-center justify-between rounded">
<div class="flex-grow border-r border-solid border-card2-color">
<div>挖矿门槛</div>
<div>最低{{ info.minTicket || 10 }}</div>
</div>
<div class="flex-grow border-r border-solid border-card2-color">
<div>矿机周期</div>
<div>{{ info.days }}</div>
</div>
<div class="flex-grow">
<div>技术服务费</div>
<div class="special">限时免费</div>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
props: {
info: {
type: Object
}
}
})
</script>
\ No newline at end of file
...@@ -13,26 +13,17 @@ ...@@ -13,26 +13,17 @@
<p class="text-base text-red1 font-semibold">已实际出矿收益为准</p> <p class="text-base text-red1 font-semibold">已实际出矿收益为准</p>
</div> </div>
</div> </div>
<div class="bg-gradient-7 py-2 text-13px text-brown3 flex items-center justify-between rounded"> <details-bar :info="info" />
<div class="flex-grow border-r border-solid border-card2-color">
<div>挖矿门槛</div>
<div>最低{{ info.minTicket || 10 }}</div>
</div>
<div class="flex-grow border-r border-solid border-card2-color">
<div>矿机周期</div>
<div>{{ info.days }}</div>
</div>
<div class="flex-grow">
<div>技术服务费</div>
<div class="special">限时免费</div>
</div>
</div>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import Vue from 'vue' import Vue from 'vue'
import DetailsBar from '@/views/Details/DetailsBar.vue'
export default Vue.extend({ export default Vue.extend({
components: {
DetailsBar
},
props: { props: {
info: { info: {
type: Object type: Object
......
...@@ -26,7 +26,7 @@ export default Vue.extend({ ...@@ -26,7 +26,7 @@ export default Vue.extend({
}, },
max: { max: {
type: Number, type: Number,
default: 60 default: Infinity
}, },
min: { min: {
type: [Number, String], type: [Number, String],
......
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
<div class="py-2"> <div class="py-2">
<p class="details-item"> <p class="details-item">
<span class="flex-shrink-0 mr-3">矿池地址</span> <span class="flex-shrink-0 mr-3">矿池地址</span>
<span class="flex-grow-0 hide">{{ info.minerAddr }}</span> <span class="flex-grow-0 hide">{{ info.minerAddr || '-' }}</span>
</p> </p>
<p class="details-item"> <p class="details-item">
<span class="flex-shrink-0 mr-3">发起人挖矿地址</span> <span class="flex-shrink-0 mr-3">发起人挖矿地址</span>
<span class="flex-grow-0 hide">{{ info.selfAddr }}</span> <span class="flex-grow-0 hide">{{ info.selfAddr || '-' }}</span>
</p> </p>
<p class="details-item"> <p class="details-item">
<span>发起人委托票数</span> <span>发起人委托票数</span>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
v-model="isLoading" v-model="isLoading"
success-text="刷新成功" success-text="刷新成功"
@refresh="onRefresh"> @refresh="onRefresh">
<MiningCard v-for="(i, index) in lists" :key="index" :info="i" /> <MiningCard v-for="(i, index) in lists" :key="index" :info="i" @goDetails="goDetails" />
</van-pull-refresh> </van-pull-refresh>
</div> </div>
</template> </template>
...@@ -35,7 +35,7 @@ import Vue from 'vue' ...@@ -35,7 +35,7 @@ import Vue from 'vue'
import MiningCard from '@/components/MiningCard.vue' import MiningCard from '@/components/MiningCard.vue'
import Popup from '@/components/Popup.vue' import Popup from '@/components/Popup.vue'
import Bus from '@/utils/bus' import Bus from '@/utils/bus'
import { invitePool, poolList } from '@/service/pool' import { invitePool, poolList, checkBind } from '@/service/pool'
import { PullRefresh, Toast } from 'vant' import { PullRefresh, Toast } from 'vant'
export default Vue.extend({ export default Vue.extend({
components: { components: {
...@@ -102,6 +102,15 @@ export default Vue.extend({ ...@@ -102,6 +102,15 @@ export default Vue.extend({
this.onRefresh() this.onRefresh()
}, this.waiter) }, this.waiter)
}, },
goDetails(val: string) {
checkBind(val).then(res => {
if (res.data.data.isSucc) {
this.$router.push({ path: '/details', query: { id: val || '1' }})
}
}).catch(() => {
Toast('该账号已绑定过矿池')
})
},
addInvite(val: string) { addInvite(val: string) {
const regexp = /^(1|3)[a-zA-Z\d]{24,33}$/ const regexp = /^(1|3)[a-zA-Z\d]{24,33}$/
if (!val) { if (!val) {
......
...@@ -27,7 +27,6 @@ export default Vue.extend({ ...@@ -27,7 +27,6 @@ export default Vue.extend({
} }
}, },
methods: { methods: {
onClickLeft() { onClickLeft() {
this.$router.back() this.$router.back()
}, },
......
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