Commit 7d9516a4 authored by xhx's avatar xhx

fix:推荐人校验及文本调整

parent b5d567cf
......@@ -14,7 +14,7 @@
</noscript>
<div id="app"></div>
<script>
console.log('v1.0.4')
console.log('v1.0.5')
</script>
<!-- built files will be auto injected -->
</body>
......
......@@ -12,7 +12,7 @@
</div>
<div class="pb-3 flex items-center justify-between">
<div class="px-2 flex flex-col items-start">
<div class="text-xs text-white2">可委托票数</div>
<div class="text-xs text-white2">可委托票数</div>
<div class="income-count">{{ rest || 0 }}</div>
</div>
<button class="w-24 h-9 rounded-full text-sm text-brown1 text-medium bg-gradient-4" @click="goMining">立即委托</button>
......@@ -80,7 +80,7 @@ export default Vue.extend({
}
},
rest() {
return Math.floor(this.coin/TICKET_COUNT)
return Math.floor((this.coin - 1)/TICKET_COUNT)
}
}
})
......
<template>
<div class="bg-gradient-6 p-4 pt-20">
<div class="pb-4">
<div class="text-brown1 text-base font-semibold text-left">{{ info.friendlyName || '-' }}</div>
</div>
<div class="mb-6 flex items-center justify-between">
<div class="text-left flex-grow">
<p class="mb-2 text-xs text-brown">委托票数</p>
<p class="text-base text-red1 font-semibold">3000 BTY=1票</p>
<div>
<div class="bg-gradient-6 p-4 pt-20">
<div class="pb-4">
<div class="text-brown1 text-base font-semibold text-left">{{ info.friendlyName || '-' }}</div>
</div>
<div class="mb-6 flex items-center justify-between">
<div class="text-left flex-grow">
<p class="mb-2 text-xs text-brown">委托票数</p>
<p class="text-base text-red1 font-semibold">{{ ticketCount }} BTY=1票</p>
</div>
<div class="text-left flex-grow">
<p class="mb-2 text-xs text-brown">奖励发放</p>
<p class="text-base text-red1 font-semibold">已实际出票奖励为准</p>
</div>
</div>
<div class="text-left flex-grow">
<p class="mb-2 text-xs text-brown">奖励发放</p>
<p class="text-base text-red1 font-semibold">已实际出票奖励为准</p>
<info-bar>
<template v-slot:left>
<div>投票门槛</div>
<div>最低{{ info.minTicket || 10 }}</div>
</template>
<div>票池周期</div>
<div>{{ days }}天</div>
<template v-slot:right>
<div>技术服务费</div>
<div class="special">限时免费</div>
</template>
</info-bar>
</div>
<div class="bg-theme-color pt-3">
<div class="bg-card2-color px-4 mt-3 pb-4">
<p class="details-title">投票信息</p>
<div class="py-2">
<list-line>
票池地址
<template v-slot:right><span>{{ address || '-' }}</span></template>
</list-line>
<list-line>
委托人数
<template v-slot:right><span class="special">{{ info.entrustPerson || 0 }}</span></template>
</list-line>
<list-line>
委托总票
<template v-slot:right><span class="special">{{ info.entrustTicket || 0 }}</span></template>
</list-line>
</div>
</div>
</div>
<info-bar>
<template v-slot:left>
<div>投票门槛</div>
<div>最低{{ info.minTicket || 10 }}</div>
</template>
<div>票池周期</div>
<div>{{ days }}天</div>
<template v-slot:right>
<div>技术服务费</div>
<div class="special">限时免费</div>
</template>
</info-bar>
</div>
</template>
<script lang="ts">
import Vue from 'vue'
import InfoBar from '@/components/InfoBar.vue'
import { TICKET_COUNT } from '@/constance/const'
import ListLine from '@/components/ListLine.vue'
export default Vue.extend({
components: {
InfoBar
InfoBar,
ListLine
},
props: {
info: {
......@@ -43,6 +67,12 @@ export default Vue.extend({
computed: {
days():number {
return +this.info.days - +this.info.runDays
},
ticketCount():number {
return TICKET_COUNT
},
address(): string {
return this.info?.minerAddr?.slice(0, 10) + '...' + this.info?.minerAddr?.slice(-10)
}
}
})
......
......@@ -30,7 +30,7 @@ export default Vue.extend({
},
min: {
type: [Number, String],
default: 1
default: 0
}
},
data() {
......
......@@ -8,7 +8,7 @@
</template>
</nav-bar>
<DetailsCard :info="info" />
<DetailsList :info="info" />
<!-- <DetailsList :info="info" /> -->
<DetailsFooter :max="Math.floor(profit/ticketNum)" :min="min" @buy="buy" />
</div>
</template>
......@@ -16,7 +16,7 @@
<script lang="ts">
import Vue from 'vue'
import DetailsCard from '@/views/Details/DetailsCard.vue'
import DetailsList from '@/views/Details/DetailsList.vue'
// import DetailsList from '@/views/Details/DetailsList.vue'
import DetailsFooter from '@/views/Details/DetailsFooter.vue'
import { NavBar, Toast } from 'vant'
import { TICKET_COUNT, TICKET_ADDRESS } from '@/constance/const'
......@@ -27,7 +27,7 @@ export default Vue.extend({
components: {
'nav-bar': NavBar,
DetailsCard,
DetailsList,
// DetailsList,
DetailsFooter
},
data() {
......@@ -65,7 +65,7 @@ export default Vue.extend({
// 已经绑定过
if (res.data.data.isSucc) {
this.isBind = true
this.min = 1
this.min = 0
}
}).catch(() => {
this.isBind = false
......@@ -77,8 +77,8 @@ export default Vue.extend({
return signTxGroup(txs.join(),'none',-1);
},
async buy(value: string) {
if (this.profit/this.ticketNum < +(this.min as number)) {
Toast(`您的票数余额为${Math.floor(this.profit/this.ticketNum)}票,不足${this.min}票`)
if ((this.profit-1)/this.ticketNum < +(this.min as number)) {
Toast(`您的票数余额为${Math.floor((this.profit-1)/this.ticketNum)}票,不足${this.min}票`)
return
}
const bindRes = await service.createBindMiner({
......
......@@ -5,6 +5,9 @@
<span>当前地址:{{ addr }}</span>
<span @click="$router.push('/record')">奖励记录</span>
</div>
<div class="flex justify-between text-sm text-left pb-3">
<span>推荐地址:{{ inviter.slice(0, 8) + '...' + inviter.slice(-8) }}</span>
</div>
<div class="flex items-center justify-between">
<div>
<p class="text-xs text-brown">可领奖励</p>
......@@ -25,13 +28,16 @@
<script lang="ts">
import Vue from 'vue'
import service from '@/service/chain33'
import { getUserInfo } from '@/service/pool'
import { TICKET_COUNT, TICKET_ADDRESS } from '@/constance/const'
import { Toast } from 'vant'
import Bus from '@/utils/bus'
import { mapState } from 'vuex'
export default Vue.extend({
data() {
return {
addr: '',
inviter: '', // 推荐人地址
profit: 0,
ticketNum: 0,
fee: 0,
......@@ -40,6 +46,11 @@ export default Vue.extend({
waiter: 1000
}
},
computed: {
...mapState({
'address': (state: any) => state.app.address
})
},
methods: {
// freezon 前重复请求,已取消
waitToPool() {
......@@ -49,7 +60,7 @@ export default Vue.extend({
}, 5000)
},
getInfo() {
service.getBalance(this.$store.state.app.address, 'ticket').then((res: any) => {
service.getBalance(this.address, 'ticket').then((res: any) => {
const { result } = res.data
this.profit = Math.floor(result[0].balance / 1e8)
this.ticketNum = Math.floor(result[0].frozen / 1e8 / TICKET_COUNT)
......@@ -57,6 +68,9 @@ export default Vue.extend({
// this.ticketNum = Math.floor((res.data.result as any)[0].frozen / 1e8 / TICKET_COUNT)
if (this.timer) clearInterval(this.timer)
})
getUserInfo().then(res => {
this.inviter = res.data.data.inviter
})
},
// 手续费
getFee() {
......@@ -116,10 +130,10 @@ export default Vue.extend({
}
},
created() {
console.log('address--info', this.$store.state.app.address)
console.log('address--info', this.address)
console.log('每票所含的数值', TICKET_COUNT)
this.addr = this.$store.state.app.address
this.addr = this.addr.slice(0, 5) + '...' + this.addr.slice(this.addr.length - 10)
this.addr = this.address
this.addr = this.addr.slice(0, 8) + '...' + this.addr.slice(-8)
this.getInfo()
this.getFee()
Bus.$on('updateMsg', () => {
......
......@@ -36,7 +36,7 @@
<div class="px-2 mt-2">
<p>1台手机仅可为一个钱包地址提供委托服务,一旦绑定委托关系,无法解绑。</p>
<br>
<p>请再次确认推荐人地址:<span class="text-orange1">{{ value }}</span></p>
<p>请再次确认推荐人地址:<span class="text-orange1">{{ value.slice(0, 8) + '...' + value.slice(-8) }}</span></p>
</div>
<div class="flex justify-around border-t mt-2">
<div class="py-3 flex-1 border-r" @click="showSure = false">取消</div>
......@@ -64,6 +64,7 @@ import Bus from '@/utils/bus'
import { invitePool, poolList, checkBind } from '@/service/pool'
import service from '@/service/chain33'
import { PullRefresh, Toast, Popup, Dialog } from 'vant'
import { mapState } from 'vuex'
// import { getDeviceId, getCurrentBTYAddress } from '@/utils/bridge' // 币钱包环境
export default Vue.extend({
......@@ -98,10 +99,13 @@ export default Vue.extend({
constant() {
return constant.HOME_IMAGE
},
...mapState({
address: (state: any) => state.app.address
})
},
methods: {
getCoins() {
service.getBalance(this.$store.state.app.address, 'coins').then((res: any) => {
service.getBalance(this.address, 'coins').then((res: any) => {
this.coins = Math.floor(res.data.result[0].balance / 1e8)
})
},
......@@ -173,7 +177,7 @@ export default Vue.extend({
sellDays: string,
startTime: string
}) {
service.getTicketAddress(this.$store.state.app.address).then(r => {
service.getTicketAddress(this.address).then(r => {
// 已经投过票,跳过封闭期
if (r.data.result?.data) {
checkBind(val.id).then(res => {
......@@ -204,44 +208,23 @@ export default Vue.extend({
if (!val) {
Toast('请先输入推荐人地址')
return
} else {
// 查询冻结余额, > 9000 可推荐
service.getBalance(this.address, 'ticket').then((res: any) => {
const restFreeze = Math.floor(res.data.result[0].frozen / 1e8)
if (restFreeze >= 9000) {
this.value = val
this.text = '5'
if (this.tipsTimer) clearInterval(this.tipsTimer)
this.tipsTimer = setInterval(() => {
this.text = +this.text > 0 ? +this.text - 1 + '' : '确定'
}, 1000)
this.showSure = true
} else {
Toast('该推荐人暂无推荐资格')
}
})
}
this.value = val
this.text = '5'
if (this.tipsTimer) clearInterval(this.tipsTimer)
this.tipsTimer = setInterval(() => {
console.log('run---------')
this.text = +this.text > 0 ? +this.text - 1 + '' : '确定'
}, 1000)
this.showSure = true
// Dialog.confirm({
// title: '提示',
// message: `注意:1台手机仅可为一个钱包地址提供委托服务,一旦绑定委托关系,无法解绑。\n请再次确认推荐人地址:${val}`,
// confirmButtonText: `${text}`,
// }).then(() => {
// // on close
// if (+text > 0) {
// console.log('-----------------')
// return false;
// }
// invitePool(val).then((res: any) => {
// if (res.data.data.isSucc) {
// Toast('添加成功')
// this.show = false
// this.getList()
// Bus.$emit('updateMsg', true)
// } else {
// Toast('请输入正确的推荐人地址')
// }
// }).catch((e) => {
// console.log(e)
// const { status } = e.response
// if (status === 413) {
// Toast('该设备已绑定过推荐人')
// } else {
// Toast('请输入正确的推荐人地址')
// }
// })
// });
},
handleConfirm() {
if (+this.text > 0) {
......
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