From 27d8f22289877045e98a2aa8cd8c917e02b3eb37 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 2 Apr 2021 14:00:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A6=96=E9=A1=B5=E8=B6=85?= =?UTF-8?q?=E7=BA=A7=E6=91=87=E4=B8=80=E6=91=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_club_lottery.js | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/jd_club_lottery.js b/jd_club_lottery.js index 86b271c7..e9216e16 100644 --- a/jd_club_lottery.js +++ b/jd_club_lottery.js @@ -26,7 +26,6 @@ cron "5 0,23 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/ */ const $ = new Env('摇京豆'); -let superShakeUlr = '';//超级摇一摇活动链接 const notify = $.isNode() ? require('./sendNotify') : ''; //Node.js用户请在jdCookie.js处填写京东ck; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; @@ -41,7 +40,12 @@ if ($.isNode()) { } else { cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); } -$.superShakeBeanFlag = false; +let superShakeBeanConfig = { + "superShakeUlr": "",//超级摇一摇活动链接 + "superShakeBeanFlag": false, + "superShakeTitle": "", + "taskVipName": "", +} const JD_API_HOST = 'https://api.m.jd.com/client.action'; !(async () => { if (!cookiesArr[0]) { @@ -49,7 +53,7 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action'; return; } await welcomeHome() - await getActInfo(superShakeUlr); + if (superShakeBeanConfig['superShakeUlr']) await getActInfo(superShakeBeanConfig['superShakeUlr']); for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { cookie = cookiesArr[i]; @@ -79,11 +83,11 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action'; if (allMessage) { if ($.isNode()) await notify.sendNotify($.name, allMessage); } - if ($.superShakeBeanFlag) { - const scaleUl = { "category": "jump", "des": "m", "url": superShakeUlr }; + if (superShakeBeanConfig.superShakeBeanFlag) { + const scaleUl = { "category": "jump", "des": "m", "url": superShakeBeanConfig['superShakeUlr'] }; const openjd = `openjd://virtual?params=${encodeURIComponent(JSON.stringify(scaleUl))}`; - if ($.isNode()) await notify.sendNotify($.name, `【超级摇一摇】活动再次开启\n【开通会员】如需做此任务,请点击链接直达活动页面\n${superShakeUlr}`, { url: openjd }); - $.msg($.name, '', `【超级摇一摇】活动再次开启\n【开通会员】如需做此任务,请点击弹窗直达活动页面`, { 'open-url': openjd }) + if ($.isNode()) await notify.sendNotify($.name, `【${superShakeBeanConfig['superShakeTitle']}】活动再次开启\n【${superShakeBeanConfig['taskVipName'] || '开通会员'}】如需做此任务,请点击链接直达活动页面\n${superShakeBeanConfig['superShakeUlr']}`, { url: openjd }); + $.msg($.name, superShakeBeanConfig['superShakeTitle'], `【超级摇一摇】活动再次开启\n【${superShakeBeanConfig['taskVipName'] || '开通会员'}】如需做此任务,请点击弹窗直达活动页面`, { 'open-url': openjd }) } })() .catch((e) => { @@ -424,8 +428,8 @@ function welcomeHome() { if (data['floorList'] && data['floorList'].length) { const jump = data['floorList'].filter(vo => !!vo && vo.type === 'shakeFloorNew')[0]['jump']; if (jump && jump.params && jump['params']['url']) { - superShakeUlr = jump.params.url; - console.log(`【超级摇一摇】活动链接:${superShakeUlr}`); + superShakeBeanConfig['superShakeUlr'] = jump.params.url; + console.log(`【超级摇一摇】活动链接:${superShakeBeanConfig['superShakeUlr']}`); } } } @@ -438,7 +442,7 @@ function welcomeHome() { }) }) } -function getActInfo(url= 'https://h5.m.jd.com/babelDiy/Zeus/2GXPFfQmeLgzZuQCWFZWCtwUqro5/index.html') { +function getActInfo(url) { return new Promise(resolve => { $.get({ url, @@ -456,9 +460,10 @@ function getActInfo(url= 'https://h5.m.jd.com/babelDiy/Zeus/2GXPFfQmeLgzZuQCWFZW data = data && data.match(/window\.__FACTORY__TAOYIYAO__STATIC_DATA__ = (.*)}/) if (data) { data = JSON.parse(data[1] + '}'); + if (data['pageConfig']) superShakeBeanConfig['superShakeTitle'] = data['pageConfig']['htmlTitle']; if (data['taskConfig']) { $.ActInfo = data['taskConfig']['taskAppId']; - console.log(`\n获取京东APP首页超级摇一摇活动ID成功:${$.ActInfo}\n`); + console.log(`\n获取【${superShakeBeanConfig['superShakeTitle']}】活动ID成功:${$.ActInfo}\n`); } } } @@ -486,14 +491,12 @@ function fc_getHomeData(appId, flag = false) { if (data) { data = JSON.parse(data); if (data && data['data']['bizCode'] === 0) { + const taskVos = data['data']['result']['taskVos'] || []; if (flag && $.index === 1) { - $.superShakeBeanFlag = true; - // const scaleUl = { "category": "jump", "des": "m", "url": superShakeUlr }; - // const openjd = `openjd://virtual?params=${encodeURIComponent(JSON.stringify(scaleUl))}`; - // if ($.isNode()) await notify.sendNotify($.name, `京东APP首页超级摇一摇再次开启\n如需做开通会员任务,请点击链接直达活动页面\n${superShakeUlr}`, { url: openjd }); - // $.msg($.name, '', `京东APP首页超级摇一摇再次开启\n如需做开通会员任务,请点击弹窗直达活动页面`, { 'open-url': openjd }) + superShakeBeanConfig['superShakeBeanFlag'] = true; + superShakeBeanConfig['taskVipName'] = taskVos.filter(vo => !!vo && vo['taskType'] === 21)[0]['taskName']; } - $.taskVos = data['data']['result']['taskVos'].filter(item => !!item && item['status'] === 1) || []; + $.taskVos = taskVos.filter(item => !!item && item['status'] === 1) || []; $.lotteryNum = parseInt(data['data']['result']['lotteryNum']); $.lotTaskId = parseInt(data['data']['result']['lotTaskId']); } else if (data && data['data']['bizCode'] === 101) { @@ -591,8 +594,8 @@ async function superShakeLottery(appId) { await $.wait(1000) } if ($.superShakeBeanNum > 0) { - message += `${message ? '\n' : ''}京东APP首页超级摇一摇:获得${$.superShakeBeanNum}京豆` - allMessage += `京东账号${$.index}${$.nickName || $.UserName}\n京东APP首页超级摇一摇:获得${$.superShakeBeanNum}京豆${$.index !== cookiesArr.length ? '\n\n' : ''}`; + message += `${message ? '\n' : ''}${superShakeBeanConfig['superShakeTitle']}:获得${$.superShakeBeanNum}京豆` + allMessage += `京东账号${$.index}${$.nickName || $.UserName}\n${superShakeBeanConfig['superShakeTitle']}:获得${$.superShakeBeanNum}京豆${$.index !== cookiesArr.length ? '\n\n' : ''}`; } } function fc_getLottery(appId) {