diff --git a/package-lock.json b/package-lock.json index f843dc4..14b59aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "postcss-px-to-viewport": "^1.1.1", "swiper": "^5.4.5", "vue": "^2.6.14", + "vue-gtag": "^1.16.1", "vue-loader": "^15.10.1", "vue-router": "^3.5.1", "vuex": "^3.6.2", @@ -12992,6 +12993,14 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/vue-gtag": { + "version": "1.16.1", + "resolved": "https://registry.npmmirror.com/vue-gtag/-/vue-gtag-1.16.1.tgz", + "integrity": "sha512-5vs0pSGxdqrfXqN1Qwt0ZFXG0iTYjRMu/saddc7QIC5yp+DKgjWQRpGYVa7Pq+KbThxwzzMfo0sGi7ISa6NowA==", + "peerDependencies": { + "vue": "^2.0.0" + } + }, "node_modules/vue-hot-reload-api": { "version": "2.3.4", "resolved": "https://registry.npmmirror.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz", diff --git a/package.json b/package.json index ba0ea2f..2ba182f 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "vue-loader": "^15.10.1", "vue-router": "^3.5.1", "vuex": "^3.6.2", + "vue-gtag": "^1.16.1", "web3": "^4.5.0" }, "devDependencies": { diff --git a/src/assets/username/Azuki.jpg b/src/assets/username/Azuki.jpg new file mode 100644 index 0000000..2688f58 Binary files /dev/null and b/src/assets/username/Azuki.jpg differ diff --git a/src/assets/username/Forge.jpg b/src/assets/username/Forge.jpg new file mode 100644 index 0000000..a086368 Binary files /dev/null and b/src/assets/username/Forge.jpg differ diff --git a/src/assets/username/Game Theory.jpg b/src/assets/username/Game Theory.jpg new file mode 100644 index 0000000..56d694d Binary files /dev/null and b/src/assets/username/Game Theory.jpg differ diff --git a/src/assets/username/My Pet Hooligan.jpg b/src/assets/username/My Pet Hooligan.jpg new file mode 100644 index 0000000..82948ab Binary files /dev/null and b/src/assets/username/My Pet Hooligan.jpg differ diff --git a/src/assets/username/Pudgy Penguins.jpg b/src/assets/username/Pudgy Penguins.jpg new file mode 100644 index 0000000..69c29fd Binary files /dev/null and b/src/assets/username/Pudgy Penguins.jpg differ diff --git a/src/assets/username/Xociety.jpg b/src/assets/username/Xociety.jpg new file mode 100644 index 0000000..bf2118d Binary files /dev/null and b/src/assets/username/Xociety.jpg differ diff --git a/src/components/checkBtn.vue b/src/components/checkBtn.vue index f92721b..4ecbf53 100644 --- a/src/components/checkBtn.vue +++ b/src/components/checkBtn.vue @@ -35,6 +35,8 @@ export default { if (data.status === 2) { this.$emit('stateupdate', data.status); return; + // } else if(data.status === 1) { + // this.$showErr('Please try again') } this.beginCountdown(); @@ -47,6 +49,7 @@ export default { let timer = setInterval(() => { this.timeLeft--; if (this.timeLeft <= 0) { + this.$showErr('Please try again') clearInterval(timer); } }, 1000); diff --git a/src/components/walletDialog/index.vue b/src/components/walletDialog/index.vue index 8a7320e..3c26c5c 100644 --- a/src/components/walletDialog/index.vue +++ b/src/components/walletDialog/index.vue @@ -74,7 +74,7 @@ export default { localStorage.setItem('walletName',val) localStorage.setItem('myAddress',res) this.myAddress = res - await this.getWalletConnected() + await this.getWalletConnected(val) }, async disconnect() { let walletName = localStorage.getItem('walletName') @@ -85,9 +85,13 @@ export default { }, // 登录 - async getWalletConnected() { - await this.$store.dispatch('user/login', this.activity) + async getWalletConnected(val) { + let require = {activity: this.activity, val} + await this.$store.dispatch('user/login', require) await this.$store.dispatch('user/fetchUserState') + this.$gtag.event("login_info", { + address_type: this.myAddress, + }) location.reload() }, diff --git a/src/main.js b/src/main.js index bc03638..1c8068a 100644 --- a/src/main.js +++ b/src/main.js @@ -7,6 +7,7 @@ import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' import moment from 'moment' import axios from 'axios' +import VueGtag from "vue-gtag"; import iErrorMsg from './components/errorDialog/index.js' Vue.prototype.$axios = axios @@ -22,6 +23,10 @@ Vue.filter('formatDate', function (value) { return moment(value).format('YYYY-MM-DD HH:mm:ss') }) +Vue.use(VueGtag, { + config: { id: "G-4KSHDJ3MGL" } +}, router); + // Vue.config.errorHandler = function(err, vm, info){ // //todo: show error message // console.error('[vue error handler|error]: ', err) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 58faedf..bead695 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -24,8 +24,8 @@ const actions = { commit('updateToken', token) commit('updateLoginStatus', true) }, - async login({ state, commit}, activity) { - let token = await new Wallet().loginWithEthereum(activity) + async login({ state, commit}, activityList) { + let token = await new Wallet().loginWithEthereum(activityList) commit('updateToken', token) }, async fetchUserState({ state, commit }) { diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 009cdaf..d1db712 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -914,7 +914,7 @@ export default { await apiCheckActivity(id); await this.getProgress(); }, - async loginTwitter() { + async loginTwitter(id) { // const _address = "0x8c10Ae04BF525734eaC00d5F7c062567461c207F"; const clientId = "aG1Jdm1YX0NhSU9rYU5sM0xQeVI6MTpjaQ"; // const codeChallenge = crypto.randomUUID() @@ -935,7 +935,7 @@ export default { } }, 10); // location.href = url; - await this.getActivitrStatue(data.id); + await this.getActivitrStatue(id); }, async loginDiscord() { const _address = this.$store.state.user.address; @@ -987,6 +987,7 @@ export default { } } else { if (data?.status == 3) { + console.log(data ,'这里') // alert(`领取成功, 获得积分: ${data.score}`) this.isLoading = false; this.activityDialog(data); @@ -1902,6 +1903,7 @@ export default { .bar-no { display: flex; align-items: center; + font-size: 16px; font-weight: 700; color: #fbc059; } diff --git a/src/views/home/nftPartner.vue b/src/views/home/nftPartner.vue index 91d1479..7842b3d 100644 --- a/src/views/home/nftPartner.vue +++ b/src/views/home/nftPartner.vue @@ -151,7 +151,6 @@ export default { this.$emit('toNavIndex') } if(discordId) { - console.log('zheli') try { let { errcode, errmsg, data } = await apiClaimNft(itemData.contract); if (!errcode) { @@ -173,7 +172,6 @@ export default { } } } catch (err) { - console.log(err) // this.$message.error(`claim partner reward error: ${err}`); } } else { @@ -428,6 +426,7 @@ export default { padding: 5px 4px; border-radius: 15px; margin-left: 10px; + cursor: pointer; } } > diff --git a/src/views/home/ranking.vue b/src/views/home/ranking.vue index 9509572..4fbbb25 100644 --- a/src/views/home/ranking.vue +++ b/src/views/home/ranking.vue @@ -283,7 +283,7 @@ export default { async getLeaderBoard () { let res = await this.$axios.get(process.env.VUE_APP_API_URL+`/api/activity/leaderboard/uaw_activity/0`) this.rankingTableData = res.data.data - console.log('rankingTableData' ,this.rankingTableData) + // console.log('rankingTableData' ,this.rankingTableData) }, // 获取用户状态 getUserState() { diff --git a/src/wallet/index.js b/src/wallet/index.js index 6ae374b..8402137 100644 --- a/src/wallet/index.js +++ b/src/wallet/index.js @@ -147,7 +147,7 @@ export class Wallet { } return new Promise((resolve, reject) => { const onChainChange = (chainId) => { - console.log('switchEthereumChain: ', chainId) + // console.log('switchEthereumChain: ', chainId) this.provider.removeListener('chainChanged', onChainChange) resolve && resolve() } @@ -156,9 +156,9 @@ export class Wallet { method: 'wallet_switchEthereumChain', params: [{ chainId: hexChainId }] }).then(() => { - console.log('switch chain success') + // console.log('switch chain success') }).catch(e => { - console.log('switch chain error: ', e) + // console.log('switch chain error: ', e) if (e.code === 4902 || e.message.indexOf('Unrecognized chain ID') >= 0) { const data = chainData this.provider.request({ @@ -177,7 +177,7 @@ export class Wallet { } ] }).then(() => { - console.log('add chain success') + // console.log('add chain success') }).catch(addError => { console.error('add chain error: ', addError) this.provider.removeListener('chainChanged', onChainChange) @@ -200,7 +200,7 @@ export class Wallet { subscribeToEvents(){ // Subscribe to accounts change this.provider.on('accountsChanged', async (accounts) => { - console.log('accountsChanged: ', accounts) + // console.log('accountsChanged: ', accounts) if (accounts && accounts.length > 0) { this.address = accounts[0] store.commit('wallet/updateAddress', this.address) @@ -215,13 +215,19 @@ export class Wallet { // Subscribe to session disconnection this.provider.on('disconnect', (err) => { - console.log('disconnect', err) + // console.log('disconnect', err) store.commit('wallet/updateConnected', false) }) } - async loginWithEthereum(activity) { + async loginWithEthereum(activityList) { + let walletType + if(activityList.val == 'ethereum') { + walletType = 'metamask' + } else if(activityList.val == 'okxwallet') { + walletType = 'okx' + } const web3 = new Web3(this.provider); let addresses = await web3.eth.getAccounts(); let tryCount = 0; @@ -239,7 +245,7 @@ export class Wallet { // console.log(chainId, "----"); const nonce = await loginNonce(address); // console.log(nonce, "nonce-------------"); - const nonceStr = `${nonce}|okx`; + const nonceStr = `${nonce}| ${walletType}`; const nonceEncrypt = hexToBase58(aesEncrypt(nonceStr, 'uaw_activity')); const message = new SiweMessage({ domain: document.location.host, @@ -255,14 +261,14 @@ export class Wallet { method: 'personal_sign', params: [web3.utils.utf8ToHex(msgSign), address], }); - let resLogin = await loginWithSignature(message, signature, activity); - console.log(resLogin.errcode, '61'); + let resLogin = await loginWithSignature(message, signature, activityList.activity); + // console.log(resLogin.errcode, '61'); if (!resLogin.errcode) { new GlobalData().token = resLogin.data.token; localStorage.setItem('token', resLogin.data.token); setToken(resLogin.data.token); // console.log(resLogin.data.token); - console.log(parseTokenData(resLogin.data.token), '------------------'); + // console.log(parseTokenData(resLogin.data.token), '------------------'); return resLogin.data.token; } else { throw new Error(resLogin.errmsg); @@ -275,7 +281,7 @@ export class Wallet { let gasPrice = await web3.eth.getGasPrice() gasPrice = gasPrice * 2n // const gasPrice = 100000000n; - console.log('gasPrice: ',gasPrice) + // console.log('gasPrice: ',gasPrice) // return let sendObj = { from: address, @@ -284,7 +290,7 @@ export class Wallet { data } let gasLimit = await web3.eth.estimateGas(sendObj) - console.log('gasLimit: ', gasLimit,sendObj) + // console.log('gasLimit: ', gasLimit,sendObj) Object.assign(sendObj, {gasPrice, gasLimit}) return web3.eth.sendTransaction(sendObj) } @@ -301,7 +307,7 @@ export class Wallet { let web3 = this.web3; const instance = this.initInstance(web3, process.env.VUE_APP_CONTRACT, treasureAbi, address); let gasPrice = await web3.eth.getGasPrice() - console.log('chainCheckIn gasPrice: ', gasPrice) + // console.log('chainCheckIn gasPrice: ', gasPrice) gasPrice = gasPrice * 2n let gasLimit = await instance.methods.dailyCheckin().estimateGas(); return instance.methods.dailyCheckin().send({ from: address, gasPrice, gasLimit });