bug fix: 任务列表有时无法显示按钮, 优化状态获取

This commit is contained in:
CounterFire2023 2024-04-11 20:28:32 +08:00
parent 5c33746861
commit f1ee519264
2 changed files with 50 additions and 44 deletions

View File

@ -220,3 +220,13 @@ export const retweetTwitter = async(desc) => {
const params = `${hashtags}`; const params = `${hashtags}`;
window.open(`${url}${params}`, '_blank'); window.open(`${url}${params}`, '_blank');
} }
export const followTwitter = async(name) => {
const url = `https://twitter.com/intent/follow?screen_name=${encodeURIComponent(name)}`
window.open(url, '_blank');
}
export const joinDiscord = (id) => {
const url = `https://discord.gg${id}`
window.open(url, '_blank');
}

View File

@ -492,6 +492,9 @@ import {
apiCheckinClaimSeq, apiCheckinClaimSeq,
checkReCaptcha, checkReCaptcha,
retweetTwitter, retweetTwitter,
followTwitter,
joinDiscord,
apiProgress,
} from "./../../utils/webapi.js"; } from "./../../utils/webapi.js";
import { sendDailyCheckIn, sendClaimTask, sendHelp } from "./../../utils/chainapi.js"; import { sendDailyCheckIn, sendClaimTask, sendHelp } from "./../../utils/chainapi.js";
@ -589,35 +592,25 @@ export default {
}); });
}, },
mounted() { mounted() {
// this.userData = JSON.parse(localStorage.getItem("userData")); this.initData();
// this.token = localStorage.getItem("token");
// this.$nextTick(() => {
// this.cloudHead();
this.getActivity();
// this.getUsercheckin()
// this.getCheckInit()
if(this.token) {
this.getActivity();
this.getProgress();
this.getGameStat();
this.getInvitesList()
this.myScoreTotal = this.userData.scoreTotal
this.myInviteCount = this.userData.inviteCount
this.myEnhanceCount = this.userData.enhanceCount
this.myAddress = localStorage.getItem("myAddress")
let walletName = localStorage.getItem("walletName")
if (walletName) {
linkWallet(walletName)
}
}
// if (this.$route.params.name != "undefined") {
// this.helpDialogVisible = true;
// // this.helpBtn();
// this.getHelpBoxLog();
// }
// });
}, },
methods: { methods: {
async initData() {
await this.getActivity();
if (this.token) {
this.getProgress();
this.getGameStat();
this.getInvitesList()
this.myScoreTotal = this.userData.scoreTotal
this.myInviteCount = this.userData.inviteCount
this.myEnhanceCount = this.userData.enhanceCount
this.myAddress = localStorage.getItem("myAddress")
let walletName = localStorage.getItem("walletName")
if (walletName) {
linkWallet(walletName)
}
}
},
// //
async getActivity() { async getActivity() {
await this.$axios await this.$axios
@ -629,6 +622,7 @@ export default {
TwitterConnect: "Connect", TwitterConnect: "Connect",
TwitterFollow: "Follow", TwitterFollow: "Follow",
TwitterRetweet: "Retweet", TwitterRetweet: "Retweet",
DiscordJoin: 'Join'
}; };
this.activeList.length = 0 this.activeList.length = 0
for (let data of res.data.data.tasks) { for (let data of res.data.data.tasks) {
@ -645,19 +639,16 @@ export default {
// //
async getProgress() { async getProgress() {
await this.getActivity() let { errcode, data } = await apiProgress()
await this.$axios if (!errcode) {
.post( let stateMap = new Map()
"/api/tasks/progress", data.forEach(item => {
{}, stateMap.set(item.id, item.status)
{ headers: { Authorization: `Bearer ${this.token}` } } })
) for (let i = 0; i < this.activeList.length; i++) {
.then(res => { this.$set(this.activeList[i], "status", stateMap.get(this.activeList[i].id) || 0)
for (let i = 0; i < res.data.data.length; i++) { }
if (res.data.data[i].id == this.activeList[i].id) }
this.$set(this.activeList[i], "status", res.data.data[i].status);
}
});
}, },
// //
@ -668,11 +659,13 @@ export default {
// console.log("", res, data); // console.log("", res, data);
} }
if (data.task == "TwitterConnect") { if (data.task == "TwitterConnect") {
this.loginTwitter(data.id); this.loginTwitter(data);
} else if(data.task == "TwitterFollow") { } else if(data.task == "TwitterFollow") {
retweetTwitter(data.desc) followTwitter(data.desc)
} else if(data.task == "TwitterRetweet") { } else if(data.task == "TwitterRetweet") {
retweetTwitter(data.desc) retweetTwitter(data.desc)
} else if(data.task == "DiscordJoin") {
joinDiscord(data.desc)
} }
}, },
// //
@ -685,7 +678,7 @@ export default {
await this.getProgress() await this.getProgress()
// console.log(res, "------------------"); // console.log(res, "------------------");
}, },
loginTwitter() { loginTwitter(data) {
// const _address = "0x8c10Ae04BF525734eaC00d5F7c062567461c207F"; // const _address = "0x8c10Ae04BF525734eaC00d5F7c062567461c207F";
const clientId = "aG1Jdm1YX0NhSU9rYU5sM0xQeVI6MTpjaQ"; const clientId = "aG1Jdm1YX0NhSU9rYU5sM0xQeVI6MTpjaQ";
// const codeChallenge = crypto.randomUUID() // const codeChallenge = crypto.randomUUID()
@ -722,7 +715,9 @@ export default {
} }
}, 10); }, 10);
}, },
async joinDiscord() {
},
// //
async getTaskClaim(id) { async getTaskClaim(id) {
let address = localStorage.getItem("myAddress") let address = localStorage.getItem("myAddress")
@ -754,6 +749,7 @@ export default {
if(data?.status == 3) { if(data?.status == 3) {
alert(`领取成功, 获得积分: ${data.score}`) alert(`领取成功, 获得积分: ${data.score}`)
this.getActivitrStatue(id) this.getActivitrStatue(id)
localStorage.removeItem(storeageKey)
clearInterval(serTimeId) clearInterval(serTimeId)
} }
} }