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

Function doTask

activity/jd_nh.js:374–401  ·  view source on GitHub ↗
(taskType, value)

Source from the content-addressed store, hash-verified

372}
373// 完成任务
374function doTask(taskType, value) {
375 let body = `activityId=${ACT_ID}&pin=${encodeURIComponent($.pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${value}`
376 return new Promise(resolve => {
377 $.post(taskPostUrl('dingzhi/vm/template/saveTask', body), async (err, resp, data) => {
378 try {
379 if (err) {
380 console.log(`${err}`)
381 console.log(`${$.name} API请求失败,请检查网路重试`)
382 } else {
383 if (safeGet(data)) {
384 data = JSON.parse(data);
385 if (data.result && data.data) {
386 console.log(`任务完成成功,获得${data.data.score}金币`)
387 $.score += data.data.score
388 } else {
389 console.log(`任务完成失败,错误信息:${data.errorMessage}`)
390 }
391 }
392 }
393 } catch (e) {
394 $.logErr(e, resp)
395 } finally {
396 resolve(data);
397 }
398 })
399 })
400
401}
402function showMsg() {
403 return new Promise(resolve => {
404 message += `本次运行获得金币${$.score}枚`;

Callers 1

getActContentFunction · 0.70

Calls 5

taskPostUrlFunction · 0.70
safeGetFunction · 0.70
postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected