bug fix: 任务列表有时无法显示按钮, 优化状态获取
This commit is contained in:
parent
5c33746861
commit
f1ee519264
@ -220,3 +220,13 @@ export const retweetTwitter = async(desc) => {
|
||||
const params = `${hashtags}`;
|
||||
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');
|
||||
}
|
||||
|
@ -492,6 +492,9 @@ import {
|
||||
apiCheckinClaimSeq,
|
||||
checkReCaptcha,
|
||||
retweetTwitter,
|
||||
followTwitter,
|
||||
joinDiscord,
|
||||
apiProgress,
|
||||
} from "./../../utils/webapi.js";
|
||||
import { sendDailyCheckIn, sendClaimTask, sendHelp } from "./../../utils/chainapi.js";
|
||||
|
||||
@ -589,35 +592,25 @@ export default {
|
||||
});
|
||||
},
|
||||
mounted() {
|
||||
// this.userData = JSON.parse(localStorage.getItem("userData"));
|
||||
// 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();
|
||||
// }
|
||||
// });
|
||||
this.initData();
|
||||
},
|
||||
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() {
|
||||
await this.$axios
|
||||
@ -629,6 +622,7 @@ export default {
|
||||
TwitterConnect: "Connect",
|
||||
TwitterFollow: "Follow",
|
||||
TwitterRetweet: "Retweet",
|
||||
DiscordJoin: 'Join'
|
||||
};
|
||||
this.activeList.length = 0
|
||||
for (let data of res.data.data.tasks) {
|
||||
@ -645,19 +639,16 @@ export default {
|
||||
|
||||
// 查看社交任务进度
|
||||
async getProgress() {
|
||||
await this.getActivity()
|
||||
await this.$axios
|
||||
.post(
|
||||
"/api/tasks/progress",
|
||||
{},
|
||||
{ headers: { Authorization: `Bearer ${this.token}` } }
|
||||
)
|
||||
.then(res => {
|
||||
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);
|
||||
}
|
||||
});
|
||||
let { errcode, data } = await apiProgress()
|
||||
if (!errcode) {
|
||||
let stateMap = new Map()
|
||||
data.forEach(item => {
|
||||
stateMap.set(item.id, item.status)
|
||||
})
|
||||
for (let i = 0; i < this.activeList.length; i++) {
|
||||
this.$set(this.activeList[i], "status", stateMap.get(this.activeList[i].id) || 0)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 开始任务
|
||||
@ -668,11 +659,13 @@ export default {
|
||||
// console.log("开始任务", res, data);
|
||||
}
|
||||
if (data.task == "TwitterConnect") {
|
||||
this.loginTwitter(data.id);
|
||||
this.loginTwitter(data);
|
||||
} else if(data.task == "TwitterFollow") {
|
||||
retweetTwitter(data.desc)
|
||||
followTwitter(data.desc)
|
||||
} else if(data.task == "TwitterRetweet") {
|
||||
retweetTwitter(data.desc)
|
||||
} else if(data.task == "DiscordJoin") {
|
||||
joinDiscord(data.desc)
|
||||
}
|
||||
},
|
||||
// 手动检查任务
|
||||
@ -685,7 +678,7 @@ export default {
|
||||
await this.getProgress()
|
||||
// console.log(res, "检查任务状态------------------");
|
||||
},
|
||||
loginTwitter() {
|
||||
loginTwitter(data) {
|
||||
// const _address = "0x8c10Ae04BF525734eaC00d5F7c062567461c207F";
|
||||
const clientId = "aG1Jdm1YX0NhSU9rYU5sM0xQeVI6MTpjaQ";
|
||||
// const codeChallenge = crypto.randomUUID()
|
||||
@ -722,7 +715,9 @@ export default {
|
||||
}
|
||||
}, 10);
|
||||
},
|
||||
async joinDiscord() {
|
||||
|
||||
},
|
||||
// 领取任务奖励
|
||||
async getTaskClaim(id) {
|
||||
let address = localStorage.getItem("myAddress")
|
||||
@ -754,6 +749,7 @@ export default {
|
||||
if(data?.status == 3) {
|
||||
alert(`领取成功, 获得积分: ${data.score}`)
|
||||
this.getActivitrStatue(id)
|
||||
localStorage.removeItem(storeageKey)
|
||||
clearInterval(serTimeId)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user