add error counter

This commit is contained in:
liangping 2022-04-04 17:30:06 +08:00
parent 4864ccf37f
commit d37cf6fef0

View File

@ -106,6 +106,7 @@ export default {
isLoading: true,
succeed: false,
error: '',
checkTimes: 0,
}
},
computed: {
@ -133,15 +134,20 @@ export default {
if (this.hash) {
this.error = null
this.$http.getTxs(this.hash).then(res => {
console.log('tx', res)
if (res.code === 0) {
this.succeed = true
clearInterval(this.timer)
} else if (res.code !== 3) { // code 3 is tx unconfirmed(not founded).
this.error = res.raw_log
console.log('error:', this.error)
clearInterval(this.timer)
}
}, () => {
// error statement
this.checkTimes += 1
if (this.checkTimes > 5) {
clearInterval(this.timer)
this.error = 'Timeout'
}
}).catch(e => {
this.error = e
clearInterval(this.timer)