东东工厂添加判断,减少部分用户获取的数据不全导致脚本出错

This commit is contained in:
lxk0301
2021-01-04 12:35:46 +08:00
parent c9c65b54f3
commit 5b1e8278a8
11 changed files with 32 additions and 28 deletions

View File

@ -283,7 +283,7 @@ function readShareCode() {
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(`随机取${randomCount}个码放到您固定的互助码后面`)
console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`)
data = JSON.parse(data);
}
}

View File

@ -498,7 +498,7 @@ function readShareCode() {
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(`随机取${randomCount}个码放到您固定的互助码后面`)
console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`)
data = JSON.parse(data);
}
}

View File

@ -330,7 +330,7 @@ function readShareCode() {
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(`随机取${randomCount}个码放到您固定的互助码后面`)
console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`)
data = JSON.parse(data);
}
}

View File

@ -666,7 +666,7 @@ function readShareCode() {
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(`随机取${randomCount}个码放到您固定的互助码后面`)
console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`)
data = JSON.parse(data);
}
}

View File

@ -1305,7 +1305,7 @@ function readShareCode() {
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(`随机取${randomCount}个码放到您固定的互助码后面`)
console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`)
data = JSON.parse(data);
}
}

View File

@ -1239,7 +1239,7 @@ function readShareCode() {
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(`随机取个${randomCount}码放到您固定的互助码后面`)
console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`)
data = JSON.parse(data);
}
}

View File

@ -265,7 +265,7 @@ function readShareCode() {
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(`随机取${randomCount}个码放到您固定的互助码后面`)
console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`)
data = JSON.parse(data);
}
}

View File

@ -108,8 +108,8 @@ function showMsg() {
} else {
$.log(`京东账号${$.index}${$.nickName}\n${message}`);
}
if (new Date().getHours() === 23) {
$.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`);
if (new Date().getHours() === 12) {
$.msg($.name, '', `${message}`);
}
resolve()
})
@ -181,6 +181,7 @@ async function algorithm() {
}
} else {
console.log(`\n此账号${$.index}${$.nickName}暂未选择商品\n`);
message += `京东账号${$.index} ${$.nickName}\n`;
message += `已选商品:暂无\n`;
message += `心仪商品:${wantProduct ? wantProduct : '暂无'}\n`;
if (wantProduct) {
@ -216,17 +217,17 @@ async function algorithm() {
} else {
console.log(`BoxJs或环境变量暂未提供心仪商品\n如需兑换心仪商品,请提供心仪商品名称\n`);
await jdfactory_getProductList(true);
message += `当前剩余最多商品:${$.canMakeList[0].name}\n`;
message += `兑换所需电量:${$.canMakeList[0].fullScore}\n`;
message += `当前剩余最多商品:${$.canMakeList[0] && $.canMakeList[0].name}\n`;
message += `兑换所需电量:${$.canMakeList[0] && $.canMakeList[0].fullScore}\n`;
message += `您当前总电量:${$.batteryValue * 1}\n`;
if ($.canMakeList[0].couponCount > 0 && $.batteryValue * 1 >= $.canMakeList[0].fullScore) {
if ($.canMakeList[0] && $.canMakeList[0].couponCount > 0 && $.batteryValue * 1 >= $.canMakeList[0] && $.canMakeList[0].fullScore) {
let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000);
if (new Date(nowTimes).getHours() === 12) {
$.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}【满足】兑换${$.canMakeList[0].name}所需总电量:${$.canMakeList[0].fullScore}\n请点击弹窗直达活动页面\n选择此心仪商品并手动投入电量兑换`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'});
if ($.isNode()) await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}${$.nickName}\n${message}【满足】兑换${$.canMakeList[0].name}所需总电量:${$.canMakeList[0].fullScore}\n请速去活动页面查看`);
$.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}【满足】兑换${$.canMakeList[0] && $.canMakeList[0] && [0].name}所需总电量:${$.canMakeList[0] && $.canMakeList[0].fullScore}\n请点击弹窗直达活动页面\n选择此心仪商品并手动投入电量兑换`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'});
if ($.isNode()) await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}${$.nickName}\n${message}【满足】兑换${$.canMakeList[0] && $.canMakeList[0].name}所需总电量:${$.canMakeList[0].fullScore}\n请速去活动页面查看`);
}
} else {
console.log(`\n目前电量${$.batteryValue * 1},不满足兑换 ${$.canMakeList[0].name}所需的 ${$.canMakeList[0].fullScore}电量\n`)
console.log(`\n目前电量${$.batteryValue * 1},不满足兑换 ${$.canMakeList[0] && $.canMakeList[0].name}所需的 ${$.canMakeList[0] && $.canMakeList[0].fullScore}电量\n`)
}
}
}
@ -535,7 +536,9 @@ function jdfactory_getProductList(flag = false) {
if (safeGet(data)) {
data = JSON.parse(data);
if (data.data.bizCode === 0) {
$.canMakeList = [];
$.canMakeList = data.data.result.canMakeList;//当前可选商品列表 sellOut:1为已抢光0为目前可选择
if ($.canMakeList && $.canMakeList.length > 0) {
$.canMakeList.sort(sortCouponCount);
console.log(`商品名称 可选状态 剩余量`)
for (let item of $.canMakeList) {
@ -549,6 +552,7 @@ function jdfactory_getProductList(flag = false) {
}
}
}
}
} else {
console.log(`异常:${JSON.stringify(data)}`)
}
@ -624,7 +628,7 @@ function readShareCode() {
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(`随机取${randomCount}个码放到您固定的互助码后面`)
console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`)
data = JSON.parse(data);
}
}

View File

@ -343,7 +343,7 @@ function readShareCode() {
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(`随机取${randomCount}个码放到您固定的互助码后面`)
console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`)
data = JSON.parse(data);
}
}

View File

@ -442,7 +442,7 @@ function readShareCode() {
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(`随机取个${randomCount}码放到您固定的互助码后面`)
console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`)
data = JSON.parse(data);
}
}

View File

@ -521,7 +521,7 @@ function readShareCode() {
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(`随机取个${randomCount}码放到您固定的互助码后面`)
console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`)
data = JSON.parse(data);
}
}