弹窗1
This commit is contained in:
parent
216df91c13
commit
6fcd2d4ccf
@ -34,6 +34,7 @@ const mutations = {
|
|||||||
updateAddress(state, _address) {
|
updateAddress(state, _address) {
|
||||||
console.log('update address: ', _address);
|
console.log('update address: ', _address);
|
||||||
state.address = _address;
|
state.address = _address;
|
||||||
|
state.connected = true;
|
||||||
},
|
},
|
||||||
updateChain(state, _chainId) {
|
updateChain(state, _chainId) {
|
||||||
console.log('update chain: ', _chainId);
|
console.log('update chain: ', _chainId);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Wallet } from '@/wallet/index.js'
|
import { Wallet } from '@/wallet/index.js'
|
||||||
|
import store from '@/store'
|
||||||
|
|
||||||
|
|
||||||
// 开宝箱
|
// 开宝箱
|
||||||
@ -18,7 +19,9 @@ export const sendToChain = async (type, address, val) => {
|
|||||||
if (localStorage.getItem(storeageKey)) {
|
if (localStorage.getItem(storeageKey)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await new Wallet().changeChain()
|
if (store.state.wallet.chainId+'' !== process.env.VUE_APP_CHAIN_ID){
|
||||||
|
await new Wallet().changeChain()
|
||||||
|
}
|
||||||
let dataStr = `data:,{"p":"cf-20","op":"${type}","val":"${val}"}`
|
let dataStr = `data:,{"p":"cf-20","op":"${type}","val":"${val}"}`
|
||||||
if (type === 'check') {
|
if (type === 'check') {
|
||||||
dataStr = 'data:,{"p":"cf-20","op":"check"}';
|
dataStr = 'data:,{"p":"cf-20","op":"check"}';
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<!-- <iframe :src="src" ref="iframe" id="iframe" style="border: 0px" width="500" height="480"></iframe> -->
|
<!-- <iframe :src="src" ref="iframe" id="iframe" style="border: 0px" width="500" height="480"></iframe> -->
|
||||||
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" ref="iframe"></canvas>
|
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" ref="iframe"></canvas>
|
||||||
|
<div @click="sendOneAction(1)">hhhhhhhhhhhhhhhhhhhhhhh</div>
|
||||||
<!-- <div @click="stepBtn">方法</div> -->
|
<!-- <div @click="stepBtn">方法</div> -->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -75,6 +76,7 @@ export default {
|
|||||||
async sendOneAction(step) {
|
async sendOneAction(step) {
|
||||||
let address = this.$store.state.user.address;
|
let address = this.$store.state.user.address;
|
||||||
if (!this.$store.state.wallet.connected || !address) {
|
if (!this.$store.state.wallet.connected || !address) {
|
||||||
|
console.log('====')
|
||||||
throw new Error('wallet not connected')
|
throw new Error('wallet not connected')
|
||||||
}
|
}
|
||||||
const preRes = await apiPreStep(step)
|
const preRes = await apiPreStep(step)
|
||||||
@ -100,6 +102,9 @@ export default {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alert(`领取成功, 播放动画, 并显示奖励: ${JSON.stringify(data)}`)
|
alert(`领取成功, 播放动画, 并显示奖励: ${JSON.stringify(data)}`)
|
||||||
|
// cc.mainAnim.setCurrPos(getTotalUsed)
|
||||||
|
// cc.mainAnim.setData(step)
|
||||||
|
// this.$emit('awardDialog', JSON.stringify(data))
|
||||||
localStorage.removeItem(storeageKey)
|
localStorage.removeItem(storeageKey)
|
||||||
clearInterval(serTimeId)
|
clearInterval(serTimeId)
|
||||||
}
|
}
|
||||||
@ -111,8 +116,6 @@ export default {
|
|||||||
// 行动
|
// 行动
|
||||||
async stepBtn(getTotalUsed,amount) {
|
async stepBtn(getTotalUsed,amount) {
|
||||||
let myAddress = localStorage.getItem("myAddress")
|
let myAddress = localStorage.getItem("myAddress")
|
||||||
// console.log(myAddress,getTotalUsed,amount,'--------------------------------')
|
|
||||||
// return
|
|
||||||
if(await isWalletConnected()) {
|
if(await isWalletConnected()) {
|
||||||
if(amount >= 1) {
|
if(amount >= 1) {
|
||||||
cc.mainAnim.setCurrPos(getTotalUsed)
|
cc.mainAnim.setCurrPos(getTotalUsed)
|
||||||
@ -137,8 +140,6 @@ export default {
|
|||||||
} catch(e) {
|
} catch(e) {
|
||||||
this.$message.error(e.message)
|
this.$message.error(e.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$message.error('Get the number of explorations')
|
this.$message.error('Get the number of explorations')
|
||||||
|
2154
src/views/home/index copy.vue
Normal file
2154
src/views/home/index copy.vue
Normal file
File diff suppressed because it is too large
Load Diff
@ -78,6 +78,7 @@ export class Wallet {
|
|||||||
} else if (this.walletName == 'connect') {
|
} else if (this.walletName == 'connect') {
|
||||||
this.provider = await connectWc();
|
this.provider = await connectWc();
|
||||||
}
|
}
|
||||||
|
this.chainId = process.env.chainData.id
|
||||||
this.subscribeToEvents();
|
this.subscribeToEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +133,9 @@ export class Wallet {
|
|||||||
async changeChain(){
|
async changeChain(){
|
||||||
const chainId = chainData.id
|
const chainId = chainData.id
|
||||||
const hexChainId = toHexChainId(chainId)
|
const hexChainId = toHexChainId(chainId)
|
||||||
|
if (this.chainId == chainId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const onChainChange = (chainId) => {
|
const onChainChange = (chainId) => {
|
||||||
console.log('switchEthereumChain: ', chainId)
|
console.log('switchEthereumChain: ', chainId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user