From a07ab0da0e99ee1143b2cb456e8f7623f633a8ee Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Wed, 11 Nov 2020 18:42:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8A=BD=E5=A5=96,=E5=96=82?= =?UTF-8?q?=E9=A3=9F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_pigPet.js | 174 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 169 insertions(+), 5 deletions(-) diff --git a/jd_pigPet.js b/jd_pigPet.js index f874aa2..98c1548 100644 --- a/jd_pigPet.js +++ b/jd_pigPet.js @@ -1,14 +1,15 @@ /* 京东金融养猪猪 -目前只有一键开完所有的宝箱功能。耗时70秒 -12 13 * * * +一键开完所有的宝箱功能。耗时70秒 +抽奖 +喂食 +12 * * * * */ const $ = new Env('金融养猪'); let cookiesArr = [], cookie = ''; const JD_API_HOST = 'https://ms.jr.jd.com/gw/generic/uc/h5/m'; const notify = $.isNode() ? require('./sendNotify') : ''; -let jdNotify = false;//是否开启推送互助码 //Node.js用户请在jdCookie.js处填写京东ck; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; if ($.isNode()) { @@ -59,7 +60,89 @@ if ($.isNode()) { }) async function jdPigPet() { await pigPetOpenBox(); + await pigPetLotteryIndex(); + await pigPetLottery(); + await pigPetUserBag(); } +async function pigPetLottery() { + if ($.currentCount > 0) { + for (let i = 0; i < $.currentCount; i ++) { + await pigPetLotteryPlay(); + } + } +} +//查询背包食物 +function pigPetUserBag() { + return new Promise(async resolve => { + const body = {"source":0,"channelLV":"yqs","riskDeviceParam":"{}","t":Date.now(),"skuId":"1001003004","category":"1001"}; + $.post(taskUrl('pigPetUserBag', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData && data.resultData.resultData.goods) { + console.log(`\n食物名称 数量`); + for (let item of data.resultData.resultData.goods) { + console.log(`${item.goodsName} ${item.count}g`); + } + for (let item of data.resultData.resultData.goods) { + if (item.count > 20) { + console.log(`10秒后开始喂食${item.goodsName},当前数量为${item.count}g`) + await $.wait(10000); + await pigPetAddFood(item.sku); + } + } + } else { + console.log(`暂无食物`) + } + } else { + console.log(`开宝箱其他情况:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//喂食 +function pigPetAddFood(skuId) { + return new Promise(async resolve => { + console.log(`skuId::::${skuId}`) + const body = {"source":0,"channelLV":"yqs","riskDeviceParam":"{}","t":1605073588888, skuId ,"category":"1001"} + $.post(taskUrl('pigPetAddFood', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data); + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//开宝箱 function pigPetOpenBox() { return new Promise(async resolve => { const body = {"source":0,"channelLV":"yqs","riskDeviceParam":"{}","no":5,"category":"1001","t": Date.now()} @@ -100,6 +183,87 @@ function pigPetOpenBox() { }) }) } +//查询大转盘的次数 +function pigPetLotteryIndex() { + $.currentCount = 0; + return new Promise(async resolve => { + const body = { + "source":0, + "channelLV":"juheye", + "riskDeviceParam": "{}" + } + $.post(taskUrl('pigPetLotteryIndex', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData) { + console.log(`当前大转盘剩余免费抽奖次数::${data.resultData.resultData.currentCount}`); + $.currentCount = data.resultData.resultData.currentCount; + } + } else { + console.log(`查询大转盘的次数:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//抽奖 +function pigPetLotteryPlay() { + return new Promise(async resolve => { + const body = { + "source":0, + "channelLV":"juheye", + "riskDeviceParam":"{}", + "t":Date.now(), + "type":0, + } + $.post(taskUrl('pigPetLotteryPlay', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData) { + // console.log(`当前大转盘剩余免费抽奖次数::${data.resultData.resultData.currentCount}`); + $.currentCount = data.resultData.resultData.currentCount; + } + } else { + console.log(`其他情况:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} function TotalBean() { return new Promise(async resolve => { const options = { @@ -142,7 +306,7 @@ function TotalBean() { } function taskUrl(function_id, body) { return { - url: `${JD_API_HOST}/${function_id}`, + url: `${JD_API_HOST}/${function_id}?_=${Date.now()}`, body: `reqData=${encodeURIComponent(JSON.stringify(body))}`, headers: { 'Accept' : `application/json`, @@ -153,7 +317,7 @@ function taskUrl(function_id, body) { 'Host' : `ms.jr.jd.com`, 'Connection' : `keep-alive`, 'User-Agent' : `jdapp;iPhone;9.0.0;13.4.1;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;ADID/F75E8AED-CB48-4EAC-A213-E8CE4018F214;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167237;supportBestPay/0;jdSupportDarkMode/0;pv/1287.19;apprpd/MyJD_GameMain;ref/https%3A%2F%2Fuua.jr.jd.com%2Fuc-fe-wxgrowing%2Fmoneytree%2Findex%2F%3Fchannel%3Dyxhd%26lng%3D113.325843%26lat%3D23.204628%26sid%3D2d98e88cf7d182f60d533476c2ce777w%26un_area%3D19_1601_50258_51885;psq/1;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|3485;jdv/0|kong|t_1000170135|tuiguang|notset|1593059927172|1593059927;adk/;app_device/IOS;pap/JA2015_311210|9.0.0|IOS 13.4.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, - 'Referer' : `https://uua.jr.jd.com/uc-fe-wxgrowing/moneytree/index`, + 'Referer' : `https://uua.jr.jd.com`, 'Accept-Language' : `zh-cn` } }