diff --git a/src/store/modules/wallet.js b/src/store/modules/wallet.js index 8c2527c..81f4e6d 100644 --- a/src/store/modules/wallet.js +++ b/src/store/modules/wallet.js @@ -34,6 +34,7 @@ const mutations = { updateAddress(state, _address) { console.log('update address: ', _address); state.address = _address; + state.connected = true; }, updateChain(state, _chainId) { console.log('update chain: ', _chainId); diff --git a/src/utils/chainapi.js b/src/utils/chainapi.js index 10002f6..dfdbf28 100644 --- a/src/utils/chainapi.js +++ b/src/utils/chainapi.js @@ -1,4 +1,5 @@ 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)) { 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}"}` if (type === 'check') { dataStr = 'data:,{"p":"cf-20","op":"check"}'; diff --git a/src/views/home/gameView.vue b/src/views/home/gameView.vue index 775dc1c..6a4666b 100644 --- a/src/views/home/gameView.vue +++ b/src/views/home/gameView.vue @@ -2,6 +2,7 @@
+
hhhhhhhhhhhhhhhhhhhhhhh
@@ -75,6 +76,7 @@ export default { async sendOneAction(step) { let address = this.$store.state.user.address; if (!this.$store.state.wallet.connected || !address) { + console.log('====') throw new Error('wallet not connected') } const preRes = await apiPreStep(step) @@ -100,6 +102,9 @@ export default { } } else { alert(`领取成功, 播放动画, 并显示奖励: ${JSON.stringify(data)}`) + // cc.mainAnim.setCurrPos(getTotalUsed) + // cc.mainAnim.setData(step) + // this.$emit('awardDialog', JSON.stringify(data)) localStorage.removeItem(storeageKey) clearInterval(serTimeId) } @@ -111,8 +116,6 @@ export default { // 行动 async stepBtn(getTotalUsed,amount) { let myAddress = localStorage.getItem("myAddress") - // console.log(myAddress,getTotalUsed,amount,'--------------------------------') - // return if(await isWalletConnected()) { if(amount >= 1) { cc.mainAnim.setCurrPos(getTotalUsed) @@ -137,8 +140,6 @@ export default { } catch(e) { this.$message.error(e.message) } - - } } else { this.$message.error('Get the number of explorations') diff --git a/src/views/home/index copy.vue b/src/views/home/index copy.vue new file mode 100644 index 0000000..b63c09c --- /dev/null +++ b/src/views/home/index copy.vue @@ -0,0 +1,2154 @@ + + + + + \ No newline at end of file diff --git a/src/wallet/index.js b/src/wallet/index.js index bf29852..e8a0ce0 100644 --- a/src/wallet/index.js +++ b/src/wallet/index.js @@ -78,6 +78,7 @@ export class Wallet { } else if (this.walletName == 'connect') { this.provider = await connectWc(); } + this.chainId = process.env.chainData.id this.subscribeToEvents(); } @@ -132,6 +133,9 @@ export class Wallet { async changeChain(){ const chainId = chainData.id const hexChainId = toHexChainId(chainId) + if (this.chainId == chainId) { + return + } return new Promise((resolve, reject) => { const onChainChange = (chainId) => { console.log('switchEthereumChain: ', chainId)