增加瓜分

This commit is contained in:
star
2021-06-05 20:33:56 +08:00
parent 6caa8910d2
commit b8b62a5e56

View File

@@ -199,51 +199,106 @@ async function main() {
} }
async function xdz(){ async function xdz(){
$.xdzInfo = {}; // $.xdzInfo = {};
await getXdzInfo(); // await getXdzInfo();
if(JSON.stringify($.xdzInfo) === '{}'){ // if(JSON.stringify($.xdzInfo) === '{}'){
console.log(`获取活动数据为空`); // console.log(`获取活动数据为空`);
return ; // return ;
} // }
$.xdzUseInfo = []; // $.xdzUseInfo = {};
await getXdzUseInfo(); // await getXdzUseInfo();
if(JSON.stringify($.xdzUseInfo) === '{}'){ // if(JSON.stringify($.xdzUseInfo) === '{}'){
console.log(`获取用户数据为空`); // console.log(`获取用户数据为空`);
return ; // return ;
} // }
let tasksList = $.xdzUseInfo.tasks; // let tasksList = $.xdzUseInfo.tasks;
for (let i = 0; i < tasksList.length; i++) { // for (let i = 0; i < tasksList.length; i++) {
$.oneTask = tasksList[i]; // $.oneTask = tasksList[i];
if($.oneTask.status !== 1){ // if($.oneTask.status !== 1){
continue; // continue;
} // }
if($.oneTask.taskType !== '22' && $.oneTask.taskType !== '6'){ // if($.oneTask.taskType !== '22' && $.oneTask.taskType !== '6'){
console.log(`执行任务:${$.oneTask.taskName}`); // console.log(`执行任务:${$.oneTask.taskName}`);
let subItem = $.oneTask.subItem; // let subItem = $.oneTask.subItem;
for (let j = 0; j < subItem.length; j++) { // for (let j = 0; j < subItem.length; j++) {
$.subItemInfo = subItem[j]; // $.subItemInfo = subItem[j];
if(!$.subItemInfo.itemToken && $.subItemInfo.status !==1 ){ // if(!$.subItemInfo.itemToken && $.subItemInfo.status !==1 ){
continue; // continue;
} // }
await doXdzTask(); // await doXdzTask();
await $.wait(2000); // await $.wait(2000);
} // }
}else if($.oneTask.taskType === '6'){ // }else if($.oneTask.taskType === '6'){
if($.oneTask.subItem && $.oneTask.subItem.length>0 && $.oneTask.times === 0){ // if($.oneTask.subItem && $.oneTask.subItem.length>0 && $.oneTask.times === 0){
$.xdzHelpCodeList.push($.oneTask.subItem[0].itemToken); // $.xdzHelpCodeList.push($.oneTask.subItem[0].itemToken);
console.log(`助力码:${$.oneTask.subItem[0].itemToken}`); // console.log(`助力码:${$.oneTask.subItem[0].itemToken}`);
} // }
} // }
} // }
let awardVoList = $.xdzInfo.awardVoList; // let awardVoList = $.xdzInfo.awardVoList;
for (let i = 0; i < awardVoList.length; i++) { // for (let i = 0; i < awardVoList.length; i++) {
$.oneAwardInfo = awardVoList[i]; // $.oneAwardInfo = awardVoList[i];
if($.oneAwardInfo.status === 1 && $.oneAwardInfo.grade === 1){ // if($.oneAwardInfo.status === 1 && $.oneAwardInfo.grade === 1){
console.log(`执行抽奖`); // console.log(`执行抽奖`);
drawAward(); // drawAward();
// await $.wait(2000);
// }
// }
console.log(`执行瓜分`);
await guafen();
await $.wait(2000); await $.wait(2000);
}
async function guafen(){
let a = (new Date()).Format("yyyy-MM-ddThh:mm:ss.SZ");
console.log(a);
const url = `https://api.m.jd.com/?body=%7B%22shopId%22:%22${$.shopId}%22,%22nowTime%22:%22${a}%22,%22token%22:%22${$.tokenId}%22%7D&appid=xdz&functionId=mcxhd_starmall_getRedPacketAward&t=${Date.now()}&loginWQBiz=`;
const method = `GET`;
const headers = {
'Origin': `https://h5.m.jd.com`,
'Cookie': $.cookie,
'Accept-Encoding': `gzip, deflate, br`,
'Accept-Language': `zh-cn`,
'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.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"),
'Referer': `https://h5.m.jd.com/babelDiy/Zeus/3Vuj8Uw26NEDNRjaT2uspf2pphK/index.html`,
'Content-Type':`application/x-www-form-urlencoded;charset=UTF-8`,
'Accept': `application/json, text/plain, */*`,
'Host': `api.m.jd.com`,
};
const myRequest = {url: url, method: method, headers: headers,};
return new Promise(async resolve => {
$.get(myRequest, (err, resp, data) => {
try {
console.log(data);
data = JSON.parse(data);
if(data.retCode === '200'){
console.log(`瓜分获得:${data.result.quota}`);
} }
} catch (e) {
$.logErr(e, resp)
} finally {
resolve();
} }
})
})
}
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getUTCMonth() + 1, //月份
"d+": this.getUTCDate(), //日
"h+": this.getUTCHours(), //小时
"m+": this.getUTCMinutes(), //分
"s+": this.getUTCSeconds(), //秒
"q+": Math.floor((this.getUTCMonth() + 3) / 3), //季度
"S": this.getUTCMilliseconds() //毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getUTCFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
} }
async function help(){ async function help(){
const url = `https://api.m.jd.com/?body=%7B%22shopId%22:%22${$.shopId}%22,%22itemToken%22:%22${$.helpCode}%22,%22token%22:%22${$.tokenId}%22%7D&appid=xdz&functionId=mcxhd_starmall_doTask&t=${Date.now()}&loginWQBiz=`; const url = `https://api.m.jd.com/?body=%7B%22shopId%22:%22${$.shopId}%22,%22itemToken%22:%22${$.helpCode}%22,%22token%22:%22${$.tokenId}%22%7D&appid=xdz&functionId=mcxhd_starmall_doTask&t=${Date.now()}&loginWQBiz=`;