修改宝箱助力功能

This commit is contained in:
yuyongdong 2024-04-10 11:53:52 +08:00
parent a44228e09c
commit 5291890134
2 changed files with 74 additions and 5 deletions

View File

@ -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>

View File

@ -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) {