nft 合作发布
This commit is contained in:
parent
0524ae5df5
commit
ddc04eed65
9
package-lock.json
generated
9
package-lock.json
generated
@ -20,6 +20,7 @@
|
|||||||
"postcss-px-to-viewport": "^1.1.1",
|
"postcss-px-to-viewport": "^1.1.1",
|
||||||
"swiper": "^5.4.5",
|
"swiper": "^5.4.5",
|
||||||
"vue": "^2.6.14",
|
"vue": "^2.6.14",
|
||||||
|
"vue-gtag": "^1.16.1",
|
||||||
"vue-loader": "^15.10.1",
|
"vue-loader": "^15.10.1",
|
||||||
"vue-router": "^3.5.1",
|
"vue-router": "^3.5.1",
|
||||||
"vuex": "^3.6.2",
|
"vuex": "^3.6.2",
|
||||||
@ -12992,6 +12993,14 @@
|
|||||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||||
"dev": true
|
"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": {
|
"node_modules/vue-hot-reload-api": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.4",
|
||||||
"resolved": "https://registry.npmmirror.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",
|
"resolved": "https://registry.npmmirror.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
"vue-loader": "^15.10.1",
|
"vue-loader": "^15.10.1",
|
||||||
"vue-router": "^3.5.1",
|
"vue-router": "^3.5.1",
|
||||||
"vuex": "^3.6.2",
|
"vuex": "^3.6.2",
|
||||||
|
"vue-gtag": "^1.16.1",
|
||||||
"web3": "^4.5.0"
|
"web3": "^4.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
BIN
src/assets/username/Azuki.jpg
Normal file
BIN
src/assets/username/Azuki.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
BIN
src/assets/username/Forge.jpg
Normal file
BIN
src/assets/username/Forge.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
src/assets/username/Game Theory.jpg
Normal file
BIN
src/assets/username/Game Theory.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
BIN
src/assets/username/My Pet Hooligan.jpg
Normal file
BIN
src/assets/username/My Pet Hooligan.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
BIN
src/assets/username/Pudgy Penguins.jpg
Normal file
BIN
src/assets/username/Pudgy Penguins.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
src/assets/username/Xociety.jpg
Normal file
BIN
src/assets/username/Xociety.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 238 KiB |
@ -35,6 +35,8 @@ export default {
|
|||||||
if (data.status === 2) {
|
if (data.status === 2) {
|
||||||
this.$emit('stateupdate', data.status);
|
this.$emit('stateupdate', data.status);
|
||||||
return;
|
return;
|
||||||
|
// } else if(data.status === 1) {
|
||||||
|
// this.$showErr('Please try again')
|
||||||
}
|
}
|
||||||
this.beginCountdown();
|
this.beginCountdown();
|
||||||
|
|
||||||
@ -47,6 +49,7 @@ export default {
|
|||||||
let timer = setInterval(() => {
|
let timer = setInterval(() => {
|
||||||
this.timeLeft--;
|
this.timeLeft--;
|
||||||
if (this.timeLeft <= 0) {
|
if (this.timeLeft <= 0) {
|
||||||
|
this.$showErr('Please try again')
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -74,7 +74,7 @@ export default {
|
|||||||
localStorage.setItem('walletName',val)
|
localStorage.setItem('walletName',val)
|
||||||
localStorage.setItem('myAddress',res)
|
localStorage.setItem('myAddress',res)
|
||||||
this.myAddress = res
|
this.myAddress = res
|
||||||
await this.getWalletConnected()
|
await this.getWalletConnected(val)
|
||||||
},
|
},
|
||||||
async disconnect() {
|
async disconnect() {
|
||||||
let walletName = localStorage.getItem('walletName')
|
let walletName = localStorage.getItem('walletName')
|
||||||
@ -85,9 +85,13 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 登录
|
// 登录
|
||||||
async getWalletConnected() {
|
async getWalletConnected(val) {
|
||||||
await this.$store.dispatch('user/login', this.activity)
|
let require = {activity: this.activity, val}
|
||||||
|
await this.$store.dispatch('user/login', require)
|
||||||
await this.$store.dispatch('user/fetchUserState')
|
await this.$store.dispatch('user/fetchUserState')
|
||||||
|
this.$gtag.event("login_info", {
|
||||||
|
address_type: this.myAddress,
|
||||||
|
})
|
||||||
location.reload()
|
location.reload()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import ElementUI from 'element-ui'
|
|||||||
import 'element-ui/lib/theme-chalk/index.css'
|
import 'element-ui/lib/theme-chalk/index.css'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import VueGtag from "vue-gtag";
|
||||||
import iErrorMsg from './components/errorDialog/index.js'
|
import iErrorMsg from './components/errorDialog/index.js'
|
||||||
Vue.prototype.$axios = axios
|
Vue.prototype.$axios = axios
|
||||||
|
|
||||||
@ -22,6 +23,10 @@ Vue.filter('formatDate', function (value) {
|
|||||||
return moment(value).format('YYYY-MM-DD HH:mm:ss')
|
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){
|
// Vue.config.errorHandler = function(err, vm, info){
|
||||||
// //todo: show error message
|
// //todo: show error message
|
||||||
// console.error('[vue error handler|error]: ', err)
|
// console.error('[vue error handler|error]: ', err)
|
||||||
|
@ -24,8 +24,8 @@ const actions = {
|
|||||||
commit('updateToken', token)
|
commit('updateToken', token)
|
||||||
commit('updateLoginStatus', true)
|
commit('updateLoginStatus', true)
|
||||||
},
|
},
|
||||||
async login({ state, commit}, activity) {
|
async login({ state, commit}, activityList) {
|
||||||
let token = await new Wallet().loginWithEthereum(activity)
|
let token = await new Wallet().loginWithEthereum(activityList)
|
||||||
commit('updateToken', token)
|
commit('updateToken', token)
|
||||||
},
|
},
|
||||||
async fetchUserState({ state, commit }) {
|
async fetchUserState({ state, commit }) {
|
||||||
|
@ -914,7 +914,7 @@ export default {
|
|||||||
await apiCheckActivity(id);
|
await apiCheckActivity(id);
|
||||||
await this.getProgress();
|
await this.getProgress();
|
||||||
},
|
},
|
||||||
async loginTwitter() {
|
async loginTwitter(id) {
|
||||||
// const _address = "0x8c10Ae04BF525734eaC00d5F7c062567461c207F";
|
// const _address = "0x8c10Ae04BF525734eaC00d5F7c062567461c207F";
|
||||||
const clientId = "aG1Jdm1YX0NhSU9rYU5sM0xQeVI6MTpjaQ";
|
const clientId = "aG1Jdm1YX0NhSU9rYU5sM0xQeVI6MTpjaQ";
|
||||||
// const codeChallenge = crypto.randomUUID()
|
// const codeChallenge = crypto.randomUUID()
|
||||||
@ -935,7 +935,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
// location.href = url;
|
// location.href = url;
|
||||||
await this.getActivitrStatue(data.id);
|
await this.getActivitrStatue(id);
|
||||||
},
|
},
|
||||||
async loginDiscord() {
|
async loginDiscord() {
|
||||||
const _address = this.$store.state.user.address;
|
const _address = this.$store.state.user.address;
|
||||||
@ -987,6 +987,7 @@ export default {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (data?.status == 3) {
|
if (data?.status == 3) {
|
||||||
|
console.log(data ,'这里')
|
||||||
// alert(`领取成功, 获得积分: ${data.score}`)
|
// alert(`领取成功, 获得积分: ${data.score}`)
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
this.activityDialog(data);
|
this.activityDialog(data);
|
||||||
@ -1902,6 +1903,7 @@ export default {
|
|||||||
.bar-no {
|
.bar-no {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
font-size: 16px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #fbc059;
|
color: #fbc059;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,6 @@ export default {
|
|||||||
this.$emit('toNavIndex')
|
this.$emit('toNavIndex')
|
||||||
}
|
}
|
||||||
if(discordId) {
|
if(discordId) {
|
||||||
console.log('zheli')
|
|
||||||
try {
|
try {
|
||||||
let { errcode, errmsg, data } = await apiClaimNft(itemData.contract);
|
let { errcode, errmsg, data } = await apiClaimNft(itemData.contract);
|
||||||
if (!errcode) {
|
if (!errcode) {
|
||||||
@ -173,7 +172,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
|
||||||
// this.$message.error(`claim partner reward error: ${err}`);
|
// this.$message.error(`claim partner reward error: ${err}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -428,6 +426,7 @@ export default {
|
|||||||
padding: 5px 4px;
|
padding: 5px 4px;
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>>
|
</style>>
|
||||||
|
@ -283,7 +283,7 @@ export default {
|
|||||||
async getLeaderBoard () {
|
async getLeaderBoard () {
|
||||||
let res = await this.$axios.get(process.env.VUE_APP_API_URL+`/api/activity/leaderboard/uaw_activity/0`)
|
let res = await this.$axios.get(process.env.VUE_APP_API_URL+`/api/activity/leaderboard/uaw_activity/0`)
|
||||||
this.rankingTableData = res.data.data
|
this.rankingTableData = res.data.data
|
||||||
console.log('rankingTableData' ,this.rankingTableData)
|
// console.log('rankingTableData' ,this.rankingTableData)
|
||||||
},
|
},
|
||||||
// 获取用户状态
|
// 获取用户状态
|
||||||
getUserState() {
|
getUserState() {
|
||||||
|
@ -147,7 +147,7 @@ export class Wallet {
|
|||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const onChainChange = (chainId) => {
|
const onChainChange = (chainId) => {
|
||||||
console.log('switchEthereumChain: ', chainId)
|
// console.log('switchEthereumChain: ', chainId)
|
||||||
this.provider.removeListener('chainChanged', onChainChange)
|
this.provider.removeListener('chainChanged', onChainChange)
|
||||||
resolve && resolve()
|
resolve && resolve()
|
||||||
}
|
}
|
||||||
@ -156,9 +156,9 @@ export class Wallet {
|
|||||||
method: 'wallet_switchEthereumChain',
|
method: 'wallet_switchEthereumChain',
|
||||||
params: [{ chainId: hexChainId }]
|
params: [{ chainId: hexChainId }]
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
console.log('switch chain success')
|
// console.log('switch chain success')
|
||||||
}).catch(e => {
|
}).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) {
|
if (e.code === 4902 || e.message.indexOf('Unrecognized chain ID') >= 0) {
|
||||||
const data = chainData
|
const data = chainData
|
||||||
this.provider.request({
|
this.provider.request({
|
||||||
@ -177,7 +177,7 @@ export class Wallet {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
console.log('add chain success')
|
// console.log('add chain success')
|
||||||
}).catch(addError => {
|
}).catch(addError => {
|
||||||
console.error('add chain error: ', addError)
|
console.error('add chain error: ', addError)
|
||||||
this.provider.removeListener('chainChanged', onChainChange)
|
this.provider.removeListener('chainChanged', onChainChange)
|
||||||
@ -200,7 +200,7 @@ export class Wallet {
|
|||||||
subscribeToEvents(){
|
subscribeToEvents(){
|
||||||
// Subscribe to accounts change
|
// Subscribe to accounts change
|
||||||
this.provider.on('accountsChanged', async (accounts) => {
|
this.provider.on('accountsChanged', async (accounts) => {
|
||||||
console.log('accountsChanged: ', accounts)
|
// console.log('accountsChanged: ', accounts)
|
||||||
if (accounts && accounts.length > 0) {
|
if (accounts && accounts.length > 0) {
|
||||||
this.address = accounts[0]
|
this.address = accounts[0]
|
||||||
store.commit('wallet/updateAddress', this.address)
|
store.commit('wallet/updateAddress', this.address)
|
||||||
@ -215,13 +215,19 @@ export class Wallet {
|
|||||||
|
|
||||||
// Subscribe to session disconnection
|
// Subscribe to session disconnection
|
||||||
this.provider.on('disconnect', (err) => {
|
this.provider.on('disconnect', (err) => {
|
||||||
console.log('disconnect', err)
|
// console.log('disconnect', err)
|
||||||
store.commit('wallet/updateConnected', false)
|
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);
|
const web3 = new Web3(this.provider);
|
||||||
let addresses = await web3.eth.getAccounts();
|
let addresses = await web3.eth.getAccounts();
|
||||||
let tryCount = 0;
|
let tryCount = 0;
|
||||||
@ -239,7 +245,7 @@ export class Wallet {
|
|||||||
// console.log(chainId, "----");
|
// console.log(chainId, "----");
|
||||||
const nonce = await loginNonce(address);
|
const nonce = await loginNonce(address);
|
||||||
// console.log(nonce, "nonce-------------");
|
// console.log(nonce, "nonce-------------");
|
||||||
const nonceStr = `${nonce}|okx`;
|
const nonceStr = `${nonce}| ${walletType}`;
|
||||||
const nonceEncrypt = hexToBase58(aesEncrypt(nonceStr, 'uaw_activity'));
|
const nonceEncrypt = hexToBase58(aesEncrypt(nonceStr, 'uaw_activity'));
|
||||||
const message = new SiweMessage({
|
const message = new SiweMessage({
|
||||||
domain: document.location.host,
|
domain: document.location.host,
|
||||||
@ -255,14 +261,14 @@ export class Wallet {
|
|||||||
method: 'personal_sign',
|
method: 'personal_sign',
|
||||||
params: [web3.utils.utf8ToHex(msgSign), address],
|
params: [web3.utils.utf8ToHex(msgSign), address],
|
||||||
});
|
});
|
||||||
let resLogin = await loginWithSignature(message, signature, activity);
|
let resLogin = await loginWithSignature(message, signature, activityList.activity);
|
||||||
console.log(resLogin.errcode, '61');
|
// console.log(resLogin.errcode, '61');
|
||||||
if (!resLogin.errcode) {
|
if (!resLogin.errcode) {
|
||||||
new GlobalData().token = resLogin.data.token;
|
new GlobalData().token = resLogin.data.token;
|
||||||
localStorage.setItem('token', resLogin.data.token);
|
localStorage.setItem('token', resLogin.data.token);
|
||||||
setToken(resLogin.data.token);
|
setToken(resLogin.data.token);
|
||||||
// console.log(resLogin.data.token);
|
// console.log(resLogin.data.token);
|
||||||
console.log(parseTokenData(resLogin.data.token), '------------------');
|
// console.log(parseTokenData(resLogin.data.token), '------------------');
|
||||||
return resLogin.data.token;
|
return resLogin.data.token;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(resLogin.errmsg);
|
throw new Error(resLogin.errmsg);
|
||||||
@ -275,7 +281,7 @@ export class Wallet {
|
|||||||
let gasPrice = await web3.eth.getGasPrice()
|
let gasPrice = await web3.eth.getGasPrice()
|
||||||
gasPrice = gasPrice * 2n
|
gasPrice = gasPrice * 2n
|
||||||
// const gasPrice = 100000000n;
|
// const gasPrice = 100000000n;
|
||||||
console.log('gasPrice: ',gasPrice)
|
// console.log('gasPrice: ',gasPrice)
|
||||||
// return
|
// return
|
||||||
let sendObj = {
|
let sendObj = {
|
||||||
from: address,
|
from: address,
|
||||||
@ -284,7 +290,7 @@ export class Wallet {
|
|||||||
data
|
data
|
||||||
}
|
}
|
||||||
let gasLimit = await web3.eth.estimateGas(sendObj)
|
let gasLimit = await web3.eth.estimateGas(sendObj)
|
||||||
console.log('gasLimit: ', gasLimit,sendObj)
|
// console.log('gasLimit: ', gasLimit,sendObj)
|
||||||
Object.assign(sendObj, {gasPrice, gasLimit})
|
Object.assign(sendObj, {gasPrice, gasLimit})
|
||||||
return web3.eth.sendTransaction(sendObj)
|
return web3.eth.sendTransaction(sendObj)
|
||||||
}
|
}
|
||||||
@ -301,7 +307,7 @@ export class Wallet {
|
|||||||
let web3 = this.web3;
|
let web3 = this.web3;
|
||||||
const instance = this.initInstance(web3, process.env.VUE_APP_CONTRACT, treasureAbi, address);
|
const instance = this.initInstance(web3, process.env.VUE_APP_CONTRACT, treasureAbi, address);
|
||||||
let gasPrice = await web3.eth.getGasPrice()
|
let gasPrice = await web3.eth.getGasPrice()
|
||||||
console.log('chainCheckIn gasPrice: ', gasPrice)
|
// console.log('chainCheckIn gasPrice: ', gasPrice)
|
||||||
gasPrice = gasPrice * 2n
|
gasPrice = gasPrice * 2n
|
||||||
let gasLimit = await instance.methods.dailyCheckin().estimateGas();
|
let gasLimit = await instance.methods.dailyCheckin().estimateGas();
|
||||||
return instance.methods.dailyCheckin().send({ from: address, gasPrice, gasLimit });
|
return instance.methods.dailyCheckin().send({ from: address, gasPrice, gasLimit });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user