修改几个需上链的方法
This commit is contained in:
parent
91da00ec5e
commit
3aa761d3ef
@ -168,6 +168,11 @@ export const apiGameStep = async (id) => {
|
|||||||
const url = `${API_BASE}/api/game/step`;
|
const url = `${API_BASE}/api/game/step`;
|
||||||
return httpPost(url, { id })
|
return httpPost(url, { id })
|
||||||
}
|
}
|
||||||
|
// 探索前置
|
||||||
|
export const apiPreStep = async (step) => {
|
||||||
|
const url = `${API_BASE}/api/game/pre_step`;
|
||||||
|
return httpPost(url, { step })
|
||||||
|
}
|
||||||
|
|
||||||
// 签到列表
|
// 签到列表
|
||||||
export const apiCheckin = async (tag) => {
|
export const apiCheckin = async (tag) => {
|
||||||
@ -198,6 +203,16 @@ export const apiBoxList = async () => {
|
|||||||
const url = `${API_BASE}/api/chest/list`;
|
const url = `${API_BASE}/api/chest/list`;
|
||||||
return httpPost(url, { })
|
return httpPost(url, { })
|
||||||
}
|
}
|
||||||
|
// 宝箱助力
|
||||||
|
export const apiEnhanceBox = async (coder) => {
|
||||||
|
const url = `${API_BASE}/api/chest/enhance`;
|
||||||
|
return httpPost(url, {coder})
|
||||||
|
}
|
||||||
|
// 开启宝箱
|
||||||
|
export const apiBoxOpen = async (chestId) => {
|
||||||
|
const url = `${API_BASE}/api/chest/open`;
|
||||||
|
return httpPost(url, {chestId})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const checkReCaptcha = async(action) =>{
|
export const checkReCaptcha = async(action) =>{
|
||||||
|
@ -231,7 +231,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getToken } from './../../utils/cookies.js'
|
import { getToken } from './../../utils/cookies.js'
|
||||||
import Pagination from './../../components/pagination.vue'
|
import Pagination from './../../components/pagination.vue'
|
||||||
import { sendOpenChest } from './../../utils/chainapi.js'
|
import { sendOpenChest, sendToChain } from './../../utils/chainapi.js'
|
||||||
|
import { apiBoxOpen } from '@/utils/webapi.js'
|
||||||
import PaginationDialog from './../../components/paginationDialog.vue'
|
import PaginationDialog from './../../components/paginationDialog.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -421,6 +422,38 @@ export default {
|
|||||||
console.log('助力记录', this.boostingList)
|
console.log('助力记录', this.boostingList)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async openBoxToChain(id) {
|
||||||
|
let address = this.$store.state.user.address;
|
||||||
|
if (!this.$store.state.wallet.connected || !address) {
|
||||||
|
throw new Error('wallet not connected')
|
||||||
|
}
|
||||||
|
|
||||||
|
let storeageKey
|
||||||
|
try {
|
||||||
|
storeageKey = await sendToChain('chest_open', address, id)
|
||||||
|
} catch (err) {
|
||||||
|
this.$message.error(`error send chain request`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let serTimeId = setInterval(async () => {
|
||||||
|
try {
|
||||||
|
let { errcode, errmsg, data } = await apiBoxOpen(id)
|
||||||
|
if (errcode) {
|
||||||
|
if (errcode !== 12) {
|
||||||
|
// 状态不是等待链上确认的, 都提示错误
|
||||||
|
this.$message.error(errmsg)
|
||||||
|
clearInterval(serTimeId)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert(`领取成功,显示奖励: ${JSON.stringify(data)}`)
|
||||||
|
localStorage.removeItem(storeageKey)
|
||||||
|
clearInterval(serTimeId)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
this.$message.error(`claim task reward error: ${err}`)
|
||||||
|
}
|
||||||
|
}, 3000)
|
||||||
|
},
|
||||||
// 开宝箱
|
// 开宝箱
|
||||||
async turnBox(id) {
|
async turnBox(id) {
|
||||||
let address = localStorage.getItem("myAddress")
|
let address = localStorage.getItem("myAddress")
|
||||||
|
@ -7,11 +7,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { sendExplore } from "./../../utils/chainapi.js";
|
import { sendToChain } from "./../../utils/chainapi.js";
|
||||||
import { getToken } from './../../utils/cookies.js'
|
import { getToken } from './../../utils/cookies.js'
|
||||||
import { isWalletConnected } from './../../wallet/index.js'
|
import { isWalletConnected } from './../../wallet/index.js'
|
||||||
import {
|
import {
|
||||||
apiGameStep,
|
apiGameStep,
|
||||||
|
apiPreStep,
|
||||||
} from "./../../utils/webapi.js";
|
} from "./../../utils/webapi.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -71,7 +72,42 @@ export default {
|
|||||||
cc.mainAnim.setCurrPos(this.getTotalUsed),
|
cc.mainAnim.setCurrPos(this.getTotalUsed),
|
||||||
4000)
|
4000)
|
||||||
},
|
},
|
||||||
|
async sendOneAction(step) {
|
||||||
|
let address = this.$store.state.user.address;
|
||||||
|
if (!this.$store.state.wallet.connected || !address) {
|
||||||
|
throw new Error('wallet not connected')
|
||||||
|
}
|
||||||
|
const preRes = await apiPreStep(step)
|
||||||
|
if (preRes.errcode) {
|
||||||
|
this.$message.error(preRes.errmsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let storeageKey
|
||||||
|
try {
|
||||||
|
storeageKey = await sendToChain('explore', address, preRes.data.id)
|
||||||
|
} catch (err) {
|
||||||
|
this.$message.error(`error send chain request`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let serTimeId = setInterval(async () => {
|
||||||
|
try {
|
||||||
|
let { errcode, errmsg, data } = await apiGameStep(preRes.data.id)
|
||||||
|
if (errcode) {
|
||||||
|
if (errcode !== 13) {
|
||||||
|
// 状态不是等待链上确认的, 都提示错误
|
||||||
|
this.$message.error(errmsg)
|
||||||
|
clearInterval(serTimeId)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert(`领取成功, 播放动画, 并显示奖励: ${JSON.stringify(data)}`)
|
||||||
|
localStorage.removeItem(storeageKey)
|
||||||
|
clearInterval(serTimeId)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
this.$message.error(`claim task reward error: ${err}`)
|
||||||
|
}
|
||||||
|
}, 3000)
|
||||||
|
},
|
||||||
// 行动
|
// 行动
|
||||||
async stepBtn(getTotalUsed,amount) {
|
async stepBtn(getTotalUsed,amount) {
|
||||||
console.log(getTotalUsed,amount)
|
console.log(getTotalUsed,amount)
|
||||||
|
@ -501,7 +501,8 @@ import {
|
|||||||
joinDiscord,
|
joinDiscord,
|
||||||
apiProgress,
|
apiProgress,
|
||||||
apiGameStat,
|
apiGameStat,
|
||||||
apiUsercheckin
|
apiUsercheckin,
|
||||||
|
apiEnhanceBox,
|
||||||
} from "./../../utils/webapi.js";
|
} from "./../../utils/webapi.js";
|
||||||
import { sendToChain, sendHelp } from "./../../utils/chainapi.js";
|
import { sendToChain, sendHelp } from "./../../utils/chainapi.js";
|
||||||
import { Wallet } from '@/wallet/index.js'
|
import { Wallet } from '@/wallet/index.js'
|
||||||
@ -765,6 +766,10 @@ export default {
|
|||||||
this.$message.error(errmsg)
|
this.$message.error(errmsg)
|
||||||
this.getActivitrStatue(id)
|
this.getActivitrStatue(id)
|
||||||
clearInterval(serTimeId)
|
clearInterval(serTimeId)
|
||||||
|
} else if (errcode !== 14) {
|
||||||
|
// 状态不是等待链上确认的, 都提示错误
|
||||||
|
this.$message.error(errmsg)
|
||||||
|
clearInterval(serTimeId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(data?.status == 3) {
|
if(data?.status == 3) {
|
||||||
@ -852,6 +857,9 @@ export default {
|
|||||||
this.$message.error(errmsg)
|
this.$message.error(errmsg)
|
||||||
this.getGameStat();
|
this.getGameStat();
|
||||||
clearInterval(serTimeId)
|
clearInterval(serTimeId)
|
||||||
|
} else if (errcode !== 13) {
|
||||||
|
this.$message.error(errmsg)
|
||||||
|
clearInterval(serTimeId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alert(`领取成功, 获得积分: ${data.score}`)
|
alert(`领取成功, 获得积分: ${data.score}`)
|
||||||
@ -906,7 +914,39 @@ export default {
|
|||||||
// console.log(res.data.data,'检查签到并领取奖励')
|
// console.log(res.data.data,'检查签到并领取奖励')
|
||||||
return res.data.data
|
return res.data.data
|
||||||
},
|
},
|
||||||
|
// 发送宝箱助力上链请求并领取奖励
|
||||||
|
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}`)
|
||||||
|
this.getGameStat();
|
||||||
|
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 helpBtn() {
|
async helpBtn() {
|
||||||
if (this.$route.params.box != undefined) {
|
if (this.$route.params.box != undefined) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user