MCPcopy Create free account
hub / github.com/Semporia/Scripts / getExtTask

Function getExtTask

activity/jd_festival.js:250–288  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

248}
249
250function getExtTask() {
251 return new Promise(resolve => {
252 $.get(taskUrl('extTask/extTaskInfo'), async (err, resp, data) => {
253 try {
254 if (err) {
255 console.log(`${JSON.stringify(err)}`)
256 console.log(`${$.name} API请求失败,请检查网路重试`)
257 } else {
258 if (safeGet(data)) {
259 data = JSON.parse(data);
260 if (data.code === 200) {
261 let type = ['shop', 'sku', 'venue']
262 for (let vo of type) {
263 for (let item of data.data[`${vo}List`]) {
264 if (item.status < 2) {
265 console.log(`去浏览${item.name}`)
266 await browseTask(item.id, vo)
267 await $.wait(6 * 1000)
268 } else if (item.status === 2) {
269 console.log(`${item.name}浏览完成,去领奖`)
270 await getPrize(item.id, vo)
271 } else {
272 console.log(`${item.name}已浏览过`)
273 }
274 }
275 }
276 } else {
277 console.log(`任务获取失败`)
278 }
279 }
280 }
281 } catch (e) {
282 $.logErr(e, resp)
283 } finally {
284 resolve();
285 }
286 })
287 })
288}
289
290function doTask(type) {
291 return new Promise(resolve => {

Callers 1

festivalFunction · 0.85

Calls 8

browseTaskFunction · 0.85
taskUrlFunction · 0.70
safeGetFunction · 0.70
getPrizeFunction · 0.70
getMethod · 0.45
logMethod · 0.45
waitMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected