From c723e2d784783256bb31ac64f0efa3a5aa25c4b1 Mon Sep 17 00:00:00 2001 From: Faker Date: Thu, 18 Aug 2022 17:28:25 +0800 Subject: [PATCH] Update jd_joyopen.js --- jd_joyopen.js | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/jd_joyopen.js b/jd_joyopen.js index 567018d..d3d5462 100644 --- a/jd_joyopen.js +++ b/jd_joyopen.js @@ -148,6 +148,15 @@ async function run() { } } await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + console.log('\n开始领取完成全部任务奖励') + await getActivity(item.configCode, item.configName, 0) + if ($.hotFlag) continue; + if ($.task.showOrder) { + if ($.taskInfo.rewardStatus == 2) continue; + $.taskList = $.task.memberList || $.task.taskList || [] + $.oneTask = '' + await getRewards(`{"configCode":"${item.configCode}","groupType":5,"itemId":1,"eid":"${$.eid}","fp":"${$.fp}"}`) + } } } catch (e) { @@ -228,7 +237,7 @@ function getReward(body, flag = 0) { if (err) { console.log(`${$.name} API请求失败,请检查网路重试`) } else { - // console.log(data) + console.log(data) res = $.toObj(data) if (typeof res == 'object') { if (res.success == true) { @@ -248,6 +257,43 @@ function getReward(body, flag = 0) { }) } +function getRewards(body, flag = 0) { + return new Promise(async resolve => { + $.post({ + url: `https://jdjoy.jd.com/module/task/v2/getReward`, + body, + headers: { + 'Accept': 'application/json, text/plain, */*', + "Accept-Encoding": "gzip, deflate, br", + 'Content-Type': 'application/json;charset=UTF-8', + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + 'Cookie': cookie, + 'User-Agent': $.UA, + } + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + res = $.toObj(data) + if (typeof res == 'object') { + if (res.success == true) { + console.log(`奖励领取成功~`) + } else { + console.log(`${res.errorMessage}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + function statistic(body) { return new Promise(async resolve => { $.post({