更新年兽组队、加入品牌会员任务
This commit is contained in:
224
jd_nian.js
224
jd_nian.js
@@ -49,6 +49,10 @@ const inviteCodes = [
|
||||
`cgxZaDXWZPCmiUa2akPVmFMI27K6antJzucULQPYNim_BPEW1Dwd@cgxZdTXtIrPYuAqfDgSpusxr97nagU6hwFa3TXxnqM95u3ib-xt4nWqZdz8@cgxZdTXtIO-O6QmYDVf67KCEJ19JcybuMB2_hYu8NSNQg0oS2Z_FpMce45g@cgxZdTXtILiLvg7OAASp61meehou4OeZvqbjghsZlc3rI5SBk7b3InUqSQ0@cgxZ9_MZ8gByP7FZ368dN8oTZBwGieaH5HvtnvXuK1Epn_KK8yol8OYGw7h3M2j_PxSZvYA`,
|
||||
`cgxZaDXWZPCmiUa2akPVmFMI27K6antJzucULQPYNim_BPEW1Dwd@cgxZdTXtIrPYuAqfDgSpusxr97nagU6hwFa3TXxnqM95u3ib-xt4nWqZdz8@cgxZdTXtIO-O6QmYDVf67KCEJ19JcybuMB2_hYu8NSNQg0oS2Z_FpMce45g@cgxZdTXtILiLvg7OAASp61meehou4OeZvqbjghsZlc3rI5SBk7b3InUqSQ0@cgxZdTXtIumO4w2cDgSqvYcqHwjaAzLxu0S371Dh_fctFJtN0tXYzdR7JaY`
|
||||
];
|
||||
const pkInviteCodes = [
|
||||
'IgNWdiLGaPadvlqJQnnKp27-YpAvKvSYNTSkTGvZylf_0wcvqD9EMkohEd8@IgNWdiLGaPaZskfACQyhgLSpZWps-WtQEW3McifV@IgNWdiLGaPaAvmHPAQf769XqjJjMyRirPzN9-AS-WHY9Y_G7t9Cwe5gdiI2qEvHZ',
|
||||
'IgNWdiLGaPadvlqJQnnKp27-YpAvKvSYNTSkTGvZylf_0wcvqD9EMkohEd8@IgNWdiLGaPaZskfACQyhgLSpZWps-WtQEW3McifV@IgNWdiLGaPaAvmHPAQf769XqjJjMyRirPzN9-AS-WHY9Y_G7t9Cwe5gdiI2qEvHZ'
|
||||
]
|
||||
!(async () => {
|
||||
await requireConfig();
|
||||
if (!cookiesArr[0]) {
|
||||
@@ -74,6 +78,7 @@ const inviteCodes = [
|
||||
continue
|
||||
}
|
||||
await shareCodesFormat();
|
||||
// await shareCodesFormatPk()
|
||||
await jdNian()
|
||||
}
|
||||
}
|
||||
@@ -88,6 +93,14 @@ async function jdNian() {
|
||||
try {
|
||||
await getHomeData()
|
||||
if(!$.secretp) return
|
||||
let hour = new Date().getUTCHours()
|
||||
if (1<=hour && hour<=14) {
|
||||
// 北京时间9点-22点做pk任务
|
||||
$.hasGroup = false
|
||||
await pkTaskDetail()
|
||||
if ($.hasGroup) await pkInfo()
|
||||
// await helpFriendsPK()
|
||||
}
|
||||
await $.wait(2000)
|
||||
await killCouponList()
|
||||
await $.wait(2000)
|
||||
@@ -139,6 +152,14 @@ async function helpFriends() {
|
||||
await $.wait(1000)
|
||||
}
|
||||
}
|
||||
async function helpFriendsPK() {
|
||||
for (let code of $.newShareCodesPk) {
|
||||
if (!code) continue
|
||||
console.log(`去助力PK好友${code}`)
|
||||
await pkAssignGroup(code)
|
||||
await $.wait(1000)
|
||||
}
|
||||
}
|
||||
async function doTask() {
|
||||
for (let item of $.taskVos) {
|
||||
if (item.taskType === 14) {
|
||||
@@ -199,6 +220,18 @@ async function doTask() {
|
||||
} else if(item.status===2){
|
||||
console.log(`${item.taskName}已做完`)
|
||||
}
|
||||
} else if (item.taskType === 21) {
|
||||
if (item.status === 1) {
|
||||
console.log(`准备做此任务:${item.taskName}`)
|
||||
for (let task of item.brandMemberVos) {
|
||||
if (task.status === 1) {
|
||||
await collectScore(item.taskId, task.itemId);
|
||||
}
|
||||
await $.wait(3000)
|
||||
}
|
||||
} else if(item.status===2){
|
||||
console.log(`${item.taskName}已做完`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -398,6 +431,69 @@ function collectScore(taskId,itemId,actionType=null,inviteId=null,shopSign=null)
|
||||
})
|
||||
})
|
||||
}
|
||||
function pkCollectScore(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_pk_collectScore", body, "nian_pk_collectScore"), 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(`任务上报成功`)
|
||||
await $.wait(10*1000)
|
||||
if(data.data.result.taskToken){
|
||||
await doTask2(data.data.result.taskToken)
|
||||
}
|
||||
}
|
||||
// $.userInfo = data.data.result.userInfo;
|
||||
}
|
||||
else{
|
||||
console.log(data.data.bizMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
function doTask2(taskToken) {
|
||||
let body = {
|
||||
"dataSource":"newshortAward",
|
||||
@@ -667,30 +763,18 @@ function pkInfo() {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
$.group = true
|
||||
if (safeGet(data)) {
|
||||
data = JSON.parse(data);
|
||||
console.log(data)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
function pkCollectScore() {
|
||||
return new Promise(resolve => {
|
||||
$.post(taskPostUrl("nian_pk_collectScore", {}, "nian_pk_collectScore"), async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
if (safeGet(data)) {
|
||||
data = JSON.parse(data);
|
||||
console.log(data)
|
||||
if(data.code===0 && data.data && data.data.bizCode===0){
|
||||
console.log(`您的好友PK助力码为${data.data.result.groupInfo.groupAssistInviteId}`)
|
||||
let info = data.data.result.groupPkInfo
|
||||
console.log(`当前关卡:${info.dayAward}元红包,完成进度 ${info.dayTotalValue}/${info.dayTargetSell}`)
|
||||
}
|
||||
else{
|
||||
$.group = false
|
||||
console.log(`获取组队信息失败,请检查`)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -711,7 +795,30 @@ function pkTaskDetail() {
|
||||
} else {
|
||||
if (safeGet(data)) {
|
||||
data = JSON.parse(data);
|
||||
console.log(data)
|
||||
if(data.code===0 && data.data && data.data.bizCode===0){
|
||||
await $.wait(2000)
|
||||
$.hasGroup = true
|
||||
for(let item of data.data.result.taskVos){
|
||||
if (item.taskType === 3 || item.taskType === 26) {
|
||||
if(item.shoppingActivityVos) {
|
||||
if (item.status === 1) {
|
||||
console.log(`准备做此任务:${item.taskName}`)
|
||||
for (let task of item.shoppingActivityVos) {
|
||||
if (task.status === 1) {
|
||||
await pkCollectScore(item.taskId, task.itemId);
|
||||
}
|
||||
await $.wait(3000)
|
||||
}
|
||||
} else if (item.status === 2) {
|
||||
console.log(`${item.taskName}已做完`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
console.log(`组队尚未开启,请先去开启组队或是加入队伍!`)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -746,7 +853,13 @@ function pkAssignGroup(inviteId) {
|
||||
} else {
|
||||
if (safeGet(data)) {
|
||||
data = JSON.parse(data);
|
||||
console.log(data)
|
||||
if(data.data && data.data.bizMsg) {
|
||||
console.log(data.data.bizMsg)
|
||||
}
|
||||
else {
|
||||
console.log(`助力失败,未知错误:${JSON.stringify(data)}`)
|
||||
$.canhelp = false
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -850,6 +963,30 @@ function readShareCode() {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
function readShareCodePk() {
|
||||
console.log(`开始`)
|
||||
return new Promise(async resolve => {
|
||||
$.get({url: `http://jd.turinglabs.net/api/v2/jd/nian_pk/read/${randomCount}/`, 'timeout': 10000}, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
if (data) {
|
||||
console.log(`随机取${randomCount}个PK助力码放到您固定的互助码后面(不影响已有固定互助)`)
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
} finally {
|
||||
resolve(data);
|
||||
}
|
||||
})
|
||||
await $.wait(10000);
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
//格式化助力码
|
||||
function shareCodesFormat() {
|
||||
return new Promise(async resolve => {
|
||||
@@ -870,6 +1007,26 @@ function shareCodesFormat() {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
|
||||
function shareCodesFormatPk() {
|
||||
return new Promise(async resolve => {
|
||||
// console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`)
|
||||
$.newShareCodesPk = [];
|
||||
if ($.shareCodesPkArr[$.index - 1]) {
|
||||
$.newShareCodesPk = $.shareCodesPkArr[$.index - 1].split('@');
|
||||
} else {
|
||||
console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`)
|
||||
const tempIndex = $.index > pkInviteCodes.length ? (pkInviteCodes.length - 1) : ($.index - 1);
|
||||
$.newShareCodesPk = pkInviteCodes[tempIndex].split('@');
|
||||
}
|
||||
const readShareCodeRes = await readShareCodePk();
|
||||
if (readShareCodeRes && readShareCodeRes.code === 200) {
|
||||
$.newShareCodesPk = [...new Set([...$.newShareCodesPk, ...(readShareCodeRes.data || [])])];
|
||||
}
|
||||
console.log(`第${$.index}个京东账号将要助力的PK好友${JSON.stringify($.newShareCodesPk)}`)
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
function requireConfig() {
|
||||
return new Promise(resolve => {
|
||||
console.log(`开始获取${$.name}配置文件\n`);
|
||||
@@ -891,7 +1048,24 @@ function requireConfig() {
|
||||
}
|
||||
})
|
||||
}
|
||||
console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`);
|
||||
let shareCodesPK = []
|
||||
console.log(`共${cookiesArr.length}个京东账号\n`);
|
||||
if ($.isNode() && process.env.JDNIANPK_SHARECODES) {
|
||||
if (process.env.JDNIANPK_SHARECODES.indexOf('\n') > -1) {
|
||||
shareCodesPK = process.env.JDNIANPK_SHARECODES.split('\n');
|
||||
} else {
|
||||
shareCodesPK = process.env.JDNIANPK_SHARECODES.split('&');
|
||||
}
|
||||
}
|
||||
$.shareCodesPkArr = [];
|
||||
if ($.isNode()) {
|
||||
Object.keys(shareCodesPK).forEach((item) => {
|
||||
if (shareCodesPK[item]) {
|
||||
$.shareCodesPkArr.push(shareCodesPK[item])
|
||||
}
|
||||
})
|
||||
}
|
||||
console.log(`您提供了${$.shareCodesPkArr.length}个账号的${$.name}PK助力码\n`);
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user