Commit 7bb75be5 authored by xhx's avatar xhx

购买状态判断

parent 77d898da
......@@ -25,6 +25,7 @@ export default Vue.extend({
const response = await service.getTicketAddress(addr)
const walletRes = await service.getWalletAddress(addr)
const _result = response.data.result?.data
Toast.clear()
if (walletRes.data.result?.datas) {
Toast({
message: '该账户不具备进入条件,将于3秒后退出',
......
// export const TICKET_COUNT = 10000
export const TICKET_COUNT = process.env.NODE_ENV !== 'production' ? 10000 : 3000
export const INCOME = 100
const stateData = {
showModal: true,
showModal: true,
inputBalance: 0
}
export type AppType = typeof stateData
export const global = {
......@@ -12,6 +13,9 @@ export const global = {
SET_SHOWMODAL(state: AppType, s: boolean) {
state.showModal = s
},
SET_BALANCE(state: AppType, c: number) {
state.inputBalance = c
}
},
actions: {
......
......@@ -35,6 +35,7 @@ export default Vue.extend({
info: {} as any,
fee: 0,
profit: 0,
ticket: 0,
isBind: false, // 是否初次委托
ticketNum: TICKET_COUNT, // 每票BTY
min: undefined as any
......@@ -51,6 +52,9 @@ export default Vue.extend({
service.getBalance(this.$store.state.app.address, 'coins').then((res: any) => {
this.profit = Math.floor((res.data.result as any)[0].balance / 1e8)
})
service.getBalance(this.$store.state.app.address, 'ticket').then((res: any) => {
this.ticket = Math.floor((res.data.result as any)[0].balance / 1e8)
})
},
getInfo() {
poolInfo(this.$route.query.id as string).then((res: any) => {
......@@ -66,15 +70,11 @@ export default Vue.extend({
})
})
},
// checkBind() {
// },
signGroup(txs:Array<string>){
return signTxGroup(txs.join(),'none',-1);
},
async buy(value: string) {
if (this.profit/this.ticketNum < +this.info.minTicket) {
// if (this.profit/this.ticketNum < 1) {
Toast(`您的票数余额为${Math.floor(this.profit/this.ticketNum)}票,不足${this.info.minTicket}票`)
return
}
......@@ -117,6 +117,7 @@ export default Vue.extend({
if (isBind) return
bindPool(this.info.id, value, isBind).then(async (r: any) => {
if (r.data.data.isSucc) {
this.$store.commit('global/SET_BALANCE', this.ticketNum * Number(value) + this.ticket)
this.$toast('购买成功')
}
}).catch(e => {
......@@ -128,7 +129,6 @@ export default Vue.extend({
}
},
created() {
console.log(this.ticketNum)
this.getFee()
this.getInfo()
}
......
......@@ -44,6 +44,7 @@ export default Vue.extend({
// }
},
methods: {
// freezon 前重复请求
waitToPool() {
if (this.timer) clearInterval(this.timer)
this.timer = setInterval(() => {
......@@ -54,12 +55,17 @@ export default Vue.extend({
service.getBalance(this.$store.state.app.address, 'ticket').then((res: any) => {
this.profit = Math.floor((res.data.result as any)[0].balance / 1e8)
this.ticketNum = Math.floor((res.data.result as any)[0].frozen / 1e8 / TICKET_COUNT)
if (this.profit > 3000) {
console.log(this.$store.state.global.inputBalance, 'income')
console.log(this.profit, 'profit')
// 等待 freezon
if (this.$store.state.global.inputBalance <= this.profit) {
this.btnClick = true
this.btnText = '等待挖矿'
this.waitToPool()
} else {
if (this.timer) clearInterval(this.timer)
// 普通状态 重置 inputBalance
this.$store.commit('global/SET_BALANCE', 0)
this.btnText = '领取收益'
this.btnClick = false
}
......
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