修改宝箱助力功能
This commit is contained in:
parent
a44228e09c
commit
5291890134
@ -49,7 +49,7 @@
|
||||
<div class="box-btm-con-boost">
|
||||
<p>Invite friends to Boost,</p>
|
||||
<p>Earn more rewards</p>
|
||||
<div class="copy-btn">
|
||||
<div class="copy-btn" @click="copyLink(boxData)">
|
||||
<div class="icon">2</div>
|
||||
<div>Invite friends to Boost</div>
|
||||
</div>
|
||||
@ -93,6 +93,7 @@ export default {
|
||||
token: null,
|
||||
boxList: [],
|
||||
boxData: {},
|
||||
userData: {},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -111,6 +112,21 @@ export default {
|
||||
this.boxList = res.data.data
|
||||
this.boxData = res.data.data[0]
|
||||
},
|
||||
// 复制助力链接
|
||||
copyLink(data) {
|
||||
this.userData = JSON.parse(localStorage.getItem("userData"))
|
||||
// console.log(data, this.userData.code)
|
||||
// return
|
||||
let url = `http://192.168.100.216:8030/home/new=${this.userData.code}/box=${data.shareCode}/id=${data.id}`
|
||||
let oInput = document.createElement("input");
|
||||
oInput.value = url;
|
||||
document.body.appendChild(oInput);
|
||||
oInput.select();
|
||||
document.execCommand("Copy");
|
||||
oInput.className = "oInput";
|
||||
oInput.style.display = "none";
|
||||
this.$message.success("Copy succeeded");
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -825,17 +825,64 @@ export default {
|
||||
// 获取路由宝箱助力
|
||||
async helpBtn() {
|
||||
if (this.$route.params.box != undefined) {
|
||||
let boxId = this.$route.params.box.split("box=");
|
||||
if (boxId[1] != "undefined") {
|
||||
let boxCode = this.$route.params.box.split("box=");
|
||||
let boxId = this.$route.params.boxId.split("id=");
|
||||
if (boxCode[1] != "undefined") {
|
||||
// 查询宝箱助力记录
|
||||
this.getHelpBoxLog();
|
||||
let boxState = await this.initBoxState(boxCode[1], boxId[1])
|
||||
console.log('助力状态', boxState)
|
||||
// 1、助力次数是否用完
|
||||
if(bosState.userCurrent < bosState.userMax) {
|
||||
// 2、宝箱助力次数是否上限
|
||||
if(chestCurrent < chestMax) {
|
||||
// 3、是否已经助力此宝箱
|
||||
if(enhanced == 0) {
|
||||
// 是否链接钱包
|
||||
if(await isWalletConnected()) {
|
||||
// 助力上链签名
|
||||
let address = localStorage.getItem('myAddress')
|
||||
let helpRes = await sendHelp(address, boxCode[1])
|
||||
// 轮询是否助力成功
|
||||
if(helpRes) {
|
||||
let serTimeId = setInterval(async () => {
|
||||
let res = await this.$axios.post(
|
||||
"/api/chest/enhance",
|
||||
{ code: boxCode[1] },
|
||||
{ headers: { Authorization: `Bearer ${this.token}` } }
|
||||
);
|
||||
if (res.data.errcode == 0) {
|
||||
this.helpAmount = res.data.data.score;
|
||||
this.isHelpSuccess = true;
|
||||
clearInterval(serTimeId)
|
||||
}
|
||||
}, 2000)
|
||||
}
|
||||
} else {
|
||||
this.walletDialogVisible = true
|
||||
}
|
||||
} else {
|
||||
this.$message.error('Already helped this treasure chest')
|
||||
}
|
||||
} else {
|
||||
this.$message.error('The number of treasure chest boosts has been capped')
|
||||
}
|
||||
} else {
|
||||
this.$message.error('The number of assists for the day has been capped')
|
||||
}
|
||||
|
||||
|
||||
|
||||
return
|
||||
if(await isWalletConnected()) {
|
||||
// let address = localStorage.getItem('myAddress')
|
||||
// let helpRes = await sendHelp(address, boxId[1])
|
||||
// let helpRes = await sendHelp(address, boxCode[1])
|
||||
|
||||
this.helpDialogVisible = true;
|
||||
this.getHelpBoxLog();
|
||||
let res = await this.$axios.post(
|
||||
"/api/chest/enhance",
|
||||
{ code: boxId[1] },
|
||||
{ code: boxCode[1] },
|
||||
{ headers: { Authorization: `Bearer ${this.token}` } }
|
||||
);
|
||||
if (res.data.errcode == 0) {
|
||||
@ -852,6 +899,12 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// 助力状态查询
|
||||
async initBoxState(code,chestId) {
|
||||
let res = await this.$axios.post('/api/chest/enhance/state',{code: code, chestId: chestId, },{headers: { Authorization: `Bearer ${this.token}` }})
|
||||
return res.data.data
|
||||
},
|
||||
|
||||
// 领取助力奖励 || 判断是否是新用户
|
||||
async helpConfirm() {
|
||||
if(this.$route.params.name != undefined) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user