diff --git a/.env.production b/.env.production index c7982a9..3044f8d 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,5 @@ # API -VUE_APP_API_URL = 'https://oauth-svr.cebggame.com/task/' +VUE_APP_API_URL = 'https://oauth-svr.cebggame.com/task' VUE_APP_WL_URL = 'https://nftwl.counterfire.games/wl_test' VUE_APP_CONFIG_URL = 'https://sepolia.infura.io/v3/b6bf7d3508c941499b10025c0776eaf8' diff --git a/src/utils/chainapi.js b/src/utils/chainapi.js index 4ba741f..83baa3c 100644 --- a/src/utils/chainapi.js +++ b/src/utils/chainapi.js @@ -2,13 +2,7 @@ const targetAddress = '0x50A8e60041A206AcaA5F844a1104896224be6F39'; import Web3 from 'web3' - -// 签到 -export const sendDailyCheckIn = async (address) => { - // const web3 = Web3; - // console.log( web3.utils.utf8ToHex(dataStr)) - // return - const dataStr = 'data:,{"p":"cf-20","op":"check"}'; +export const sendScription = async (address, dataStr) => { const data = Web3.utils.utf8ToHex(dataStr) const provider = new Web3(window.ethereum); let gasPrice = await provider.eth.getGasPrice() @@ -27,85 +21,32 @@ export const sendDailyCheckIn = async (address) => { Object.assign(sendObj, {gasPrice, gasLimit}) return provider.eth.sendTransaction(sendObj) } +// 签到 +export const sendDailyCheckIn = async (address) => { + const dataStr = 'data:,{"p":"cf-20","op":"check"}'; + return sendScription(address, dataStr) +} // 开宝箱 export const sendOpenChest = async (address, chestId) => { - // const web3 = window.w3; - const openChestStr = `data:,{"p":"cf-20","op":"chest_open","id":"${chestId}"}` - const data = Web3.utils.utf8ToHex(openChestStr) - const provider = new Web3(window.ethereum); - let gasPrice = await provider.eth.getGasPrice() * 2n - // const gasPrice = 100000000n; - console.log('gasPrice: ',gasPrice) - let sendObj = { - from: address, - to: targetAddress, - value: '0x0', - data - } - let gasLimit = await provider.eth.estimateGas(sendObj) - console.log('gasLimit: ', gasLimit) - Object.assign(sendObj, {gasPrice, gasLimit}) - return provider.eth.sendTransaction(sendObj) + const dataStr = `data:,{"p":"cf-20","op":"chest_open","id":"${chestId}"}` + return sendScription(address, dataStr) } // 领积分 export const sendClaimTask = async (address, taskId) => { - const openClaimTaskStr = `data:,{"p":"cf-20","op":"task_claim","val":"${taskId}"}` - const data = Web3.utils.utf8ToHex(openClaimTaskStr) - const provider = new Web3(window.ethereum); - console.log(provider) - let gasPrice = await provider.eth.getGasPrice() * 2n - // const gasPrice = 100000000n; - console.log('gasPrice: ',gasPrice) - let sendObj = { - from: address, - to: targetAddress, - value: '0x0', - data - } - let gasLimit = await provider.eth.estimateGas(sendObj) - console.log('gasLimit: ', gasLimit) - Object.assign(sendObj, {gasPrice, gasLimit}) - return provider.eth.sendTransaction(sendObj) + const dataStr = `data:,{"p":"cf-20","op":"task_claim","val":"${taskId}"}` + return sendScription(address, dataStr) } // 探索 export const sendExplore = async (address, explore_id) => { const openCExploreStr = `data:,{"p":"cf-20","op":"explore","val":"${explore_id}"}` - const data = Web3.utils.utf8ToHex(openCExploreStr) - const provider = new Web3(window.ethereum); - let gasPrice = await provider.eth.getGasPrice() * 2n - // const gasPrice = 100000000n; - console.log('gasPrice: ',gasPrice) - let sendObj = { - from: address, - to: targetAddress, - value: '0x0', - data - } - let gasLimit = await provider.eth.estimateGas(sendObj) - console.log('gasLimit: ', gasLimit) - Object.assign(sendObj, {gasPrice, gasLimit}) - return provider.eth.sendTransaction(sendObj) + return sendScription(address, openCExploreStr) } // 助力 export const sendHelp = async (address, shareCode) => { const openHelpStr = `data:,{"p":"cf-20","op":"chest_enhance","val":"${shareCode}"}` - const data = Web3.utils.utf8ToHex(openHelpStr) - const provider = new Web3(window.ethereum); - let gasPrice = await provider.eth.getGasPrice() * 2n - // const gasPrice = 100000000n; - console.log('gasPrice: ',gasPrice) - let sendObj = { - from: address, - to: targetAddress, - value: '0x0', - data - } - let gasLimit = await provider.eth.estimateGas(sendObj) - console.log('gasLimit: ', gasLimit) - Object.assign(sendObj, {gasPrice, gasLimit}) - return provider.eth.sendTransaction(sendObj) + return sendScription(address, openHelpStr) } diff --git a/src/utils/utcdate.util.js b/src/utils/utcdate.util.js new file mode 100644 index 0000000..41a4463 --- /dev/null +++ b/src/utils/utcdate.util.js @@ -0,0 +1,16 @@ +export const formatDate = (date) => { + const year = date.getUTCFullYear() + const month = (date.getUTCMonth() + 1 + '').padStart(2, '0') + const day = (date.getUTCDate() + '').padStart(2, '0') + return `${year}${month}${day}` +} + +export const getDayBegin = (date) => { + let result = new Date(date.getTime()) + result.setUTCHours(0, 0, 0, 0) + return result +} +// check two dates are in the same day +export const isSameDay = (date1, date2) => { + return formatDate(date1) === formatDate(date2) +} \ No newline at end of file diff --git a/src/utils/webapi.js b/src/utils/webapi.js index 0128f0a..614e4b4 100644 --- a/src/utils/webapi.js +++ b/src/utils/webapi.js @@ -18,6 +18,17 @@ const httpPost = async (url, data) => { }).then(toJson); } +const httpGet = async (url) => { + let headers = {"Content-Type": "application/json"}; + if (token) { + headers['Authorization'] = `Bearer ${token}`; + } + return fetch(url, { + method: "GET", + headers + }).then(toJson); +} + const base58Alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; export const hexToBase58 = (hexString) => { @@ -156,9 +167,9 @@ export const apiGameStep = async (id) => { } // 签到列表 -export const apiCheckin = async () => { - const url = `${API_BASE}/api/user/checkin/list/tag`; - return httpPost(url, { }) +export const apiCheckin = async (tag) => { + const url = `${API_BASE}/api/user/checkin/list/${tag}`; + return httpGet(url) } // 连续签到奖励 diff --git a/src/views/home/calenView.vue b/src/views/home/calenView.vue index a7462d0..ac74cb8 100644 --- a/src/views/home/calenView.vue +++ b/src/views/home/calenView.vue @@ -4,6 +4,7 @@ -->
  • +
    @@ -11,6 +12,8 @@
  • {{ index+1 }}
    +
    {{ index+1 }}
    + @@ -18,6 +21,9 @@