From 721d057bc824e361a407e011c0d6be6510557aa5 Mon Sep 17 00:00:00 2001 From: shylocks Date: Mon, 1 Feb 2021 18:04:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A9=E9=99=8D=E7=88=86=E7=AB=B9=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E4=BA=92=E5=8A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_nian.js | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 179 insertions(+), 1 deletion(-) diff --git a/jd_nian.js b/jd_nian.js index 2d35b22e..ec61ea5b 100644 --- a/jd_nian.js +++ b/jd_nian.js @@ -29,7 +29,7 @@ const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 const randomCount = $.isNode() ? 20 : 5; //IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], cookie = '', message; +let cookiesArr = [], cookie = '', message, superAssist = []; if ($.isNode()) { Object.keys(jdCookieNode).forEach((item) => { cookiesArr.push(jdCookieNode[item]) @@ -82,6 +82,28 @@ const pkInviteCodes = [ await jdNian() } } + + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + await helpSuper() + } + } })() .catch((e) => { $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') @@ -121,6 +143,8 @@ async function jdNian() { await $.wait(2000) await helpFriends() await $.wait(2000) + await getSpecialGiftDetail() + await $.wait(2000) await getHomeData(true) await showMsg() } catch (e) { @@ -165,6 +189,15 @@ async function helpFriends() { } } +async function helpSuper(){ + $.secretp = null + await getHomeData(true) + if (!$.secretp) return + for(let item of superAssist){ + await collectSpecialScore(item.taskId, item.itemId, null, item.inviteId) + } +} + async function helpFriendsPK() { for (let code of $.newShareCodesPk) { if (!code) continue @@ -1065,6 +1098,151 @@ function killCoupon(skuId) { }) } +function getSpecialGiftDetail() { + return new Promise((resolve) => { + $.post(taskPostUrl('nian_getSpecialGiftDetail'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data && data.data['bizCode'] === 0) { + let flag = true + for(let item of data.data.result.taskVos){ + if (item.taskType === 3 || item.taskType === 26) { + if (item.shoppingActivityVos) { + if (item.status === 1) { + flag = false + console.log(`准备做此任务:${item.taskName}`) + for (let task of item.shoppingActivityVos) { + if (task.status === 1) { + await collectSpecialScore(item.taskId, task.itemId); + } + await $.wait(3000) + } + } else if (item.status === 2) { + console.log(`${item.taskName}已做完`) + } + } + } + else if (item.taskType === 0) { + if (item.status === 1) { + flag = false + console.log(`准备做此任务:${item.taskName}`) + await collectSpecialScore(item.taskId, item.simpleRecordInfoVo.itemId); + } else if (item.status === 2) { + console.log(`${item.taskName}已做完`) + } + } else{ + if (item.status === 1) { + flag = false + superAssist.push({ + "inviteId": data.data.result.inviteId, + "itemId": item.assistTaskDetailVo.itemId, + "taskId": item.taskId + }) + } else if (item.status === 2) { + console.log(`${item.taskName}已做完`) + } + } + } + if(flag){ + await getSpecialGiftInfo() + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +function getSpecialGiftInfo() { + return new Promise((resolve) => { + $.post(taskPostUrl('nian_getSpecialGiftInfo',"nian_getSpecialGiftInfo"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data && data.data['bizCode'] === 0) { + console.log(`领奖成功,获得${data.data.result.score}爆竹🧨`) + }else{ + console.log(data.data.bizMsg) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} + +function collectSpecialScore(taskId, itemId, actionType = null, inviteId = null, shopSign = null) { + let temp = { + "taskId": taskId, + "rnd": getRnd(), + "inviteId": "-1", + "stealId": "-1" + } + if (itemId) temp['itemId'] = itemId + if (actionType) temp['actionType'] = actionType + if (inviteId) temp['inviteId'] = inviteId + if (shopSign) temp['shopSign'] = shopSign + const extraData = { + "jj": 6, + "buttonid": "jmdd-react-smash_0", + "sceneid": "homePageh5", + "appid": '50073' + } + let body = { + ...encode(temp, $.secretp, extraData), + taskId: taskId, + itemId: itemId + } + if (actionType) body['actionType'] = actionType + if (inviteId) body['inviteId'] = inviteId + if (shopSign) body['shopSign'] = shopSign + return new Promise(resolve => { + $.post(taskPostUrl("nian_collectSpecialGift", body, "nian_collectSpecialGift"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0) { + if (data.data && data.data.bizCode === 0) { + if (data.data.result.score) + console.log(`任务完成,获得${data.data.result.score}爆竹🧨`) + else if (data.data.result.maxAssistTimes) { + console.log(`助力好友成功`) + } else { + console.log(`任务上报成功`) + } + // $.userInfo = data.data.result.userInfo; + } else { + console.log(data.data.bizMsg) + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + function readShareCode() { console.log(`开始`) return new Promise(async resolve => {