diff --git a/src/App.vue b/src/App.vue index 950aa74..202906e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -26,6 +26,7 @@ html, body { background-color: #0f1013; + margin: 0px; } div, diff --git a/src/assets/common/P5-up.png b/src/assets/common/P5-up.png new file mode 100644 index 0000000..30b153a Binary files /dev/null and b/src/assets/common/P5-up.png differ diff --git a/src/assets/common/P5.png b/src/assets/common/P5.png new file mode 100644 index 0000000..f13736f Binary files /dev/null and b/src/assets/common/P5.png differ diff --git a/src/views/home/gameView.vue b/src/views/home/gameView.vue index 6a4666b..52ae331 100644 --- a/src/views/home/gameView.vue +++ b/src/views/home/gameView.vue @@ -2,7 +2,6 @@
-
hhhhhhhhhhhhhhhhhhhhhhh
@@ -73,7 +72,7 @@ export default { cc.mainAnim.setCurrPos(this.getTotalUsed), 4000) }, - async sendOneAction(step) { + async sendOneAction(getTotalUsed, step) { let address = this.$store.state.user.address; if (!this.$store.state.wallet.connected || !address) { console.log('====') @@ -101,10 +100,11 @@ export default { clearInterval(serTimeId) } } else { - alert(`领取成功, 播放动画, 并显示奖励: ${JSON.stringify(data)}`) - // cc.mainAnim.setCurrPos(getTotalUsed) - // cc.mainAnim.setData(step) - // this.$emit('awardDialog', JSON.stringify(data)) + console.log(JSON.stringify(data)) + // alert(`领取成功, 播放动画, 并显示奖励: ${JSON.stringify(data)}`) + cc.mainAnim.setCurrPos(getTotalUsed) + cc.mainAnim.setData(step) + this.$emit('awardDialog', data) localStorage.removeItem(storeageKey) clearInterval(serTimeId) } diff --git a/src/views/home/helpDialog.vue b/src/views/home/helpDialog.vue index 623c928..9f2d0bc 100644 --- a/src/views/home/helpDialog.vue +++ b/src/views/home/helpDialog.vue @@ -17,7 +17,7 @@
{{ boxData.nickname }}: Thank you for your support!
- +
Wallet Connect
@@ -154,37 +154,38 @@ export default { // 3、是否已经助力此宝箱 if(this.boxState.enhanced == 0) { // 4、开始助力 - try{ - // 5、链上请求交互 - let helpRes = await sendHelp(address, this.boxCode) - if(helpRes) { - // 6、轮询是否助力成功 - let serTimeId = setInterval(async () => { - let res = await this.$axios.post( - "/api/chest/enhance", - { code: this.boxCode }, - { headers: { Authorization: `Bearer ${this.token}` } } - ); - if (res.data.errcode == 0) { - // 7、判断是否是新用户 - if(this.isNewUser == 0) { - // 8、关闭助力弹窗 - this.awardData = {...res.data.data, isNewUser: this.isNewUser} - this.$emit('awardDialog', this.awardData) - this.$emit('handleClose') - } else { - // 8、关闭助力弹窗 - this.awardData = {...res.data.data, isNewUser: this.isNewUser} - this.$emit('awardDialog', this.awardData) - this.$emit('handleClose') - } - clearInterval(serTimeId) - } - }, 2000) - } - } catch(e) { - this.$message.error(e.message) - } + this.sendEnhanceReq(this.boxCode) + // try{ + // // 5、链上请求交互 + // let helpRes = await sendHelp(address, this.boxCode) + // if(helpRes) { + // // 6、轮询是否助力成功 + // let serTimeId = setInterval(async () => { + // let res = await this.$axios.post( + // "/api/chest/enhance", + // { code: this.boxCode }, + // { headers: { Authorization: `Bearer ${this.token}` } } + // ); + // if (res.data.errcode == 0) { + // // 7、判断是否是新用户 + // if(this.isNewUser == 0) { + // // 8、关闭助力弹窗 + // this.awardData = {...res.data.data, isNewUser: this.isNewUser} + // this.$emit('awardDialog', this.awardData) + // this.$emit('handleClose') + // } else { + // // 8、关闭助力弹窗 + // this.awardData = {...res.data.data, isNewUser: this.isNewUser} + // this.$emit('awardDialog', this.awardData) + // this.$emit('handleClose') + // } + // clearInterval(serTimeId) + // } + // }, 2000) + // } + // } catch(e) { + // this.$message.error(e.message) + // } } else { this.$emit('handleClose') this.$message.error('Already helped this treasure chest') @@ -200,6 +201,49 @@ export default { }, + // 发送宝箱助力上链请求并领取奖励 + async sendEnhanceReq(boxCode) { + let address = this.$store.state.user.address; + if (!this.$store.state.wallet.connected || !address) { + this.walletDialogVisible = true + return + } + let storeageKey + try { + storeageKey = await sendToChain('chest_enhance', address, boxCode) + } catch (err) { + this.$message.error(`error send chain request`) + return + } + let serTimeId = setInterval(async () => { + try { + let { errcode, errmsg, data } = await apiEnhanceBox(boxCode) + if (!errcode) { + alert(`助力成功, 获得积分: ${data.score}`) + if(this.isNewUser == 0) { + // 8、关闭助力弹窗 + this.awardData = {data, isNewUser: this.isNewUser} + this.$emit('awardDialog', this.awardData) + this.$emit('handleClose') + } else { + // 8、关闭助力弹窗 + this.awardData = {data, isNewUser: this.isNewUser} + this.$emit('awardDialog', this.awardData) + this.$emit('handleClose') + } + localStorage.removeItem(storeageKey) + clearInterval(serTimeId) + } else if (errcode !== 14) { + // 状态不是等待链上确认的, 都提示错误 + this.$message.error(errmsg) + clearInterval(serTimeId) + } + } catch (err) { + this.$message.error(`claim task reward error: ${err}`) + } + }, 3000) + }, + // 助力状态查询 async initBoxState(code,chestId) { let res = await this.$axios.post('/api/chest/enhance/state',{code: code, chestId: chestId, },{headers: { Authorization: `Bearer ${this.token}` }}) diff --git a/src/views/home/index.vue b/src/views/home/index.vue index cbbabae..3306ad7 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -1,6 +1,6 @@