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

Function awardTask

jd_cfd.js:1361–1434  ·  view source on GitHub ↗
(taskType, taskinfo, bizCode = "jxbfd")

Source from the content-addressed store, hash-verified

1359
1360//领取奖励
1361function awardTask(taskType, taskinfo, bizCode = "jxbfd") {
1362 return new Promise((resolve) => {
1363 const {taskId, taskName} = taskinfo;
1364 const {ddwTaskId, strTaskName} = taskinfo;
1365 switch (taskType) {
1366 case 0://日常任务
1367 $.get(taskListUrl(`Award`, `taskId=${taskId}`, bizCode), (err, resp, data) => {
1368 try {
1369 if (err) {
1370 console.log(`${JSON.stringify(err)}`)
1371 console.log(`${$.name} Award API请求失败,请检查网路重试`)
1372 } else {
1373 const {msg, ret, data: {prizeInfo = ''} = {}} = JSON.parse(data.match(new RegExp(/jsonpCBK.?\((.*);*/))[1]);
1374 let str = '';
1375 if (msg.indexOf('活动太火爆了') !== -1) {
1376 str = '任务为成就任务或者未到任务时间';
1377 } else {
1378 str = msg + prizeInfo ? `获得金币 ¥ ${JSON.parse(prizeInfo).ddwCoin}` : '';
1379 }
1380 console.log(`【领日常奖励】${taskName} ${str}\n${$.showLog ? data : ''}`);
1381 }
1382 } catch (e) {
1383 $.logErr(e, resp);
1384 } finally {
1385 resolve();
1386 }
1387 });
1388 break
1389 case 1://成就奖励
1390 $.get(taskListUrl(`Award`, `taskId=${taskId}`), (err, resp, data) => {
1391 try {
1392 if (err) {
1393 console.log(`${JSON.stringify(err)}`)
1394 console.log(`${$.name} AchieveAward API请求失败,请检查网路重试`)
1395 } else {
1396 const {msg, ret, data: {prizeInfo = ''} = {}} = JSON.parse(data.match(new RegExp(/jsonpCBK.?\((.*);*/))[1]);
1397 if(msg.indexOf('活动太火爆了') !== -1) {
1398 console.log(`活动太火爆了`)
1399 } else {
1400 console.log(`【领成就奖励】${taskName} 获得财富值 ¥ ${JSON.parse(prizeInfo).ddwMoney}\n${$.showLog ? data : ''}`);
1401 }
1402 }
1403 } catch (e) {
1404 $.logErr(e, resp);
1405 } finally {
1406 resolve();
1407 }
1408 });
1409 break
1410 case 2:
1411 $.get(taskListUrl(`Award`, `taskId=${ddwTaskId}`, `jxbfdprop`), (err, resp, data) => {
1412 try {
1413 if (err) {
1414 console.log(`${JSON.stringify(err)}`)
1415 console.log(`${$.name} Award API请求失败,请检查网路重试`)
1416 } else {
1417 const {msg, ret, data: {prizeInfo = ''} = {}} = JSON.parse(data.match(new RegExp(/jsonpCBK.?\((.*);*/))[1]);
1418 if(msg.indexOf('活动太火爆了') !== -1) {

Callers 2

getPropTaskFunction · 0.70
browserTaskFunction · 0.70

Calls 4

taskListUrlFunction · 0.70
getMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected