fix 点点券
This commit is contained in:
108
jd_necklace.js
108
jd_necklace.js
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* @Author: LXK9301 https://github.com/LXK9301
|
||||
* @Author: lxk0301 https://gitee.com/lxk0301
|
||||
* @Date: 2020-11-20 11:42:03
|
||||
* @Last Modified by: LXK9301
|
||||
* @Last Modified time: 2021-2-27 12:27:14
|
||||
* @Last Modified by: lxk0301
|
||||
* @Last Modified time: 2021-3-16 12:27:14
|
||||
*/
|
||||
/*
|
||||
点点券,可以兑换无门槛红包(1元,5元,10元,100元,部分红包需抢购)
|
||||
@ -88,7 +88,7 @@ async function jd_necklace() {
|
||||
await receiveBubbles();
|
||||
await sign();
|
||||
await necklace_homePage();
|
||||
// await necklace_exchangeGift(10);//自动兑换多少钱的无门槛红包,1000代表1元
|
||||
// await necklace_exchangeGift($.totalScore);//自动兑换多少钱的无门槛红包,1000代表1元,默认兑换全部点点券
|
||||
await showMsg();
|
||||
}
|
||||
function showMsg() {
|
||||
@ -107,18 +107,18 @@ function showMsg() {
|
||||
async function doTask() {
|
||||
for (let item of $.taskConfigVos) {
|
||||
if (item.taskStage === 0) {
|
||||
console.log(`${item.taskName}未完成`);
|
||||
await necklace_startTask(item.id);
|
||||
await $.wait(2000);
|
||||
console.log(`【${item.taskName}】 任务未领取,开始领取此任务`);
|
||||
await necklace_startTask(item.id);
|
||||
console.log(`【${item.taskName}】 任务领取成功,开始完成此任务`);
|
||||
await $.wait(1000);
|
||||
await reportTask(item);
|
||||
} else if (item.taskStage === 2) {
|
||||
console.log(`${item.taskName}任务已做完,奖励未领取`);
|
||||
console.log(`【${item.taskName}】 任务已做完,奖励未领取`);
|
||||
} else if (item.taskStage === 3) {
|
||||
console.log(`${item.taskName}奖励已领取`);
|
||||
} else if (item.taskStage === 1) {
|
||||
console.log(`${item.taskName}任务未完成,开始做此任务\n`);
|
||||
if (item['taskType'] === 3) await doAppTask('3');
|
||||
if (item['taskType'] === 4) await doAppTask('4');
|
||||
console.log(`\n【${item.taskName}】 任务已领取但未完成,开始完成此任务`);
|
||||
await reportTask(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,6 +135,24 @@ async function sign() {
|
||||
console.log(`当前${new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString()}已签到`)
|
||||
}
|
||||
}
|
||||
async function reportTask(item = {}) {
|
||||
//普通任务
|
||||
if (item['taskType'] !== 3 && item['taskType'] !== 4 && item['taskType'] !== 6) {
|
||||
await necklace_startTask(item.id, 'necklace_reportTask');
|
||||
}
|
||||
if (item['taskType'] === 6) {
|
||||
//浏览精选活动任务
|
||||
await necklace_getTask(item.id);
|
||||
$.taskItems = $.taskItems.filter(value => !!value && value['status'] === 0);
|
||||
for (let vo of $.taskItems) {
|
||||
console.log(`浏览精选活动 【${vo['title']}】`);
|
||||
await necklace_startTask(item.id, 'necklace_reportTask', vo['id']);
|
||||
}
|
||||
}
|
||||
//首页浏览XX秒的任务
|
||||
if (item['taskType'] === 3) await doAppTask('3');
|
||||
if (item['taskType'] === 4) await doAppTask('4');
|
||||
}
|
||||
//每日签到福利
|
||||
function necklace_sign() {
|
||||
return new Promise(resolve => {
|
||||
@ -231,18 +249,20 @@ function necklace_chargeScores(bubleId) {
|
||||
})
|
||||
})
|
||||
}
|
||||
function necklace_startTask(taskId) {
|
||||
function necklace_startTask(taskId, functionId = 'necklace_startTask', itemId = "") {
|
||||
return new Promise(resolve => {
|
||||
const body = {
|
||||
let body = {
|
||||
taskId,
|
||||
currentDate: $.lastRequestTime.replace(/:/g, "%3A"),
|
||||
}
|
||||
$.post(taskPostUrl("necklace_startTask", body), async (err, resp, data) => {
|
||||
if (itemId) body['itemId'] = itemId;
|
||||
$.post(taskPostUrl(functionId, body), async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
console.log(`${functionId === 'necklace_startTask' ? '领取任务结果' : '做任务结果'}:${data}`);
|
||||
if (safeGet(data)) {
|
||||
data = JSON.parse(data);
|
||||
if (data.rtn_code === 0) {
|
||||
@ -261,7 +281,39 @@ function necklace_startTask(taskId) {
|
||||
})
|
||||
})
|
||||
}
|
||||
function necklace_getTask(taskId) {
|
||||
return new Promise(resolve => {
|
||||
const body = {
|
||||
taskId,
|
||||
currentDate: $.lastRequestTime.replace(/:/g, "%3A"),
|
||||
}
|
||||
$.taskItems = [];
|
||||
$.post(taskPostUrl("necklace_getTask", body), 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.rtn_code === 0) {
|
||||
if (data.data.biz_code === 0) {
|
||||
$.taskItems = data.data.result && data.data.result.taskItems;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function necklace_homePage() {
|
||||
$.taskConfigVos = [];
|
||||
return new Promise(resolve => {
|
||||
$.post(taskPostUrl('necklace_homePage'), async (err, resp, data) => {
|
||||
try {
|
||||
@ -311,10 +363,10 @@ async function doAppTask(type = '3') {
|
||||
"childActivityUrl": "openapp.jdmobile%3a%2f%2fvirtual%3fparams%3d%7b%5c%22category%5c%22%3a%5c%22jump%5c%22%2c%5c%22des%5c%22%3a%5c%22couponCenter%5c%22%7d",
|
||||
"pageClickKey": "CouponCenter",
|
||||
"lat": "",
|
||||
"taskId": "necklace_89",
|
||||
"taskId": "necklace_142",
|
||||
"lng": "",
|
||||
}
|
||||
if (type === '4') body['taskId'] = 'necklace_91';
|
||||
if (type === '4') body['taskId'] = 'necklace_143';
|
||||
await $.wait(15500);
|
||||
await getCcTaskList('reportCcTask', body, type);
|
||||
}
|
||||
@ -324,8 +376,8 @@ function getCcTaskList(functionId, body, type = '3') {
|
||||
if (functionId === 'getCcTaskList') {
|
||||
url = `https://api.m.jd.com/client.action?functionId=${functionId}&body=${escape(JSON.stringify(body))}&uuid=8888888&client=apple&clientVersion=9.4.1&st=1614320848090&sign=d3259c0c19f6c792883485ae65f8991c&sv=111`
|
||||
}
|
||||
if (type === '3' && functionId === 'reportCcTask') url = `https://api.m.jd.com/client.action?functionId=${functionId}&body=${escape(JSON.stringify(body))}&uuid=8888888&client=apple&clientVersion=9.4.1&st=1614320901023&sign=26e637ba072ddbcfa44c5273ef928696&sv=111`
|
||||
if (type === '4' && functionId === 'reportCcTask') url = `https://api.m.jd.com/client.action?functionId=${functionId}&body=${escape(JSON.stringify(body))}&uuid=8888888&client=apple&clientVersion=9.4.1&st=1614323577039&sign=67f8f57a96816a6efe33b7c9676a5cec&sv=111`
|
||||
if (type === '3' && functionId === 'reportCcTask') url = `https://api.m.jd.com/client.action?functionId=${functionId}&body=${escape(JSON.stringify(body))}&uuid=8888888&client=apple&clientVersion=9.4.1&st=1615862880029&sign=65a8c7e54009ef2139bfe9fc6acd4390&sv=112`
|
||||
if (type === '4' && functionId === 'reportCcTask') url = `https://api.m.jd.com/client.action?functionId=${functionId}&body=${escape(JSON.stringify(body))}&uuid=8888888&client=apple&clientVersion=9.4.1&st=1615863447055&sign=d920e1397e0ed2de3c4abd123c523268&sv=122`
|
||||
// if (functionId === 'reportCcTask') {
|
||||
// url = `https://api.m.jd.com/client.action?functionId=${functionId}&body=${escape(JSON.stringify(body))}&uuid=8888888&client=apple&clientVersion=9.4.1&st=1614320901023&sign=26e637ba072ddbcfa44c5273ef928696&sv=111`
|
||||
// }
|
||||
@ -353,8 +405,8 @@ function getCcTaskList(functionId, body, type = '3') {
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
if (safeGet(data)) {
|
||||
if (type === '3') console.log(`点击首页领券图标(进入领券中心浏览15s)任务:${data}`)
|
||||
if (type === '4') console.log(`点击“券后9.9”任务:${data}`)
|
||||
if (type === '3' && functionId === 'reportCcTask') console.log(`点击首页领券图标(进入领券中心浏览15s)任务:${data}`)
|
||||
if (type === '4' && functionId === 'reportCcTask') console.log(`点击“券后9.9”任务:${data}`)
|
||||
// data = JSON.parse(data);
|
||||
}
|
||||
}
|
||||
@ -369,10 +421,20 @@ function getCcTaskList(functionId, body, type = '3') {
|
||||
function taskPostUrl(function_id, body = {}) {
|
||||
const time = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000;
|
||||
return {
|
||||
url: `${JD_API_HOST}?functionId=${function_id}&appid=jd_mp_h5&loginType=2&client=jd_mp_h5&t=${time}&body=${escape(JSON.stringify(body))}`,
|
||||
url: `${JD_API_HOST}?functionId=${function_id}&appid=coupon-necklace&loginType=2&client=coupon-necklace&t=${time}&body=${escape(JSON.stringify(body))}&uuid=88732f840b77821b345bf07fd71f609e6ff12f43`,
|
||||
// url: `${JD_API_HOST}?functionId=${function_id}&appid=jd_mp_h5&loginType=2&client=jd_mp_h5&t=${time}&body=${escape(JSON.stringify(body))}`,
|
||||
headers: {
|
||||
"Cookie": cookie,
|
||||
"User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"),
|
||||
"accept": "*/*",
|
||||
"accept-encoding": "gzip, deflate, br",
|
||||
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
||||
"content-length": "0",
|
||||
"cookie": cookie,
|
||||
"origin": "https://h5.m.jd.com",
|
||||
"referer": "https://h5.m.jd.com/",
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-site",
|
||||
"user-agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user