From 8bed0c59400226e4ecccf0a1d89451d6d5906795 Mon Sep 17 00:00:00 2001 From: yuexin Date: Mon, 22 Apr 2024 20:35:57 +0800 Subject: [PATCH] opt the task --- src/views/home/index.vue | 85 ++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/src/views/home/index.vue b/src/views/home/index.vue index fbe4f2e..b34de9e 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -890,55 +890,74 @@ export default { // 开始任务 async toPost(data, onlyaction) { // debugger - if (data.status == 0 || !onlyaction) { - let res = await apiBeginActivity(data.id); - if (res.errcode == 0) { - await this.getProgress(); - } + let begintask = data.status == 0 && !onlyaction + if (begintask) { + this.rumGtag(data.task) } - this.rumGtag(data.task) + + let btw = false + let bdc = false if (data.task == "TwitterConnect") { + btw = true await this.loginTwitter(data.id); } else if(data.task == "TwitterFollow") { - //todo: panduan twitter id - if (!this.usesTwitterId) { - this.$showErr("Please complete the 'Connect Your X' quest first"); - } else { + btw = true + // if (!this.usesTwitterId) { + // this.$showErr("Please complete the 'Connect Your X' quest first"); + // } else { followTwitter(data.cfg.account) - } + // } } else if(data.task == "TwitterLike") { - //todo: panduan twitter id - if (!this.usesTwitterId) { - this.$showErr("Please complete the 'Connect Your X' quest first"); - } else { + btw = true + // if (!this.usesTwitterId) { + // this.$showErr("Please complete the 'Connect Your X' quest first"); + // } else { window.open(`https://twitter.com/intent/like?tweet_id=${data.cfg.content}`, '_blank'); - } + // } } else if(data.task == "TwitterTweet") { - //todo: panduan twitter id - if (!this.usesTwitterId) { - this.$showErr("Please complete the 'Connect Your X' quest first"); - } else { + btw = true + // if (!this.usesTwitterId) { + // this.$showErr("Please complete the 'Connect Your X' quest first"); + // } else { followTwitter(data.cfg.content) - } + // } } else if(data.task == "TwitterRetweet") { - //todo: panduan twitter id - if (!this.usesTwitterId) { - this.$showErr("Please complete the 'Connect Your X' quest first"); - } else { + btw = true + // if (!this.usesTwitterId) { + // this.$showErr("Please complete the 'Connect Your X' quest first"); + // } else { window.open(`https://twitter.com/intent/retweet?tweet_id=${data.cfg.content}`, '_blank'); - } + // } } else if(data.task == "DiscordJoin") { - //todo: panduan dc id - if (!this.usesDiscordId) { - this.$showErr( - "Please complete the 'Connect Your Discord' quest first" - ); - } else { + bdc = true + // if (!this.usesDiscordId) { + // this.$showErr( + // "Please complete the 'Connect Your Discord' quest first" + // ); + // } else { joinDiscord(data.cfg.account) - } + // } } else if (data.task == "DiscordConnect") { + bdc = true this.loginDiscord() } + + if (begintask) { + let res = await apiBeginActivity(data.id); + + if (res.errcode == 0) { + await this.getProgress(); + }else if(res.errcode == 14){ //pretask not complete + if(btw){ + this.$showErr("Please complete the 'Connect Your X' quest first"); + }else if(bdc){ + this.$showErr("Please complete the 'Connect Your Discord' quest first"); + } + }else{ + this.$showErr(`Unknown error[${res.errcode}]`); + } + } + }, // 手动检查任务 async toCheck() {