Skip to content

Commit fe661b7

Browse files
committedMar 18, 2022
Update
1 parent 04a1588 commit fe661b7

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed
 

‎jd_plantBean.js

+34-12
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ console.log('\n====================Hello World====================\n')
3030
//Node.js用户请在jdCookie.js处填写京东ck;
3131
//ios等软件用户直接用NobyDa的jd cookie
3232
let jdNotify = true; //是否开启静默运行。默认true开启
33-
let cookiesArr = [], cookie = '', jdPlantBeanShareArr = [], isBox = false, notify, newShareCodes, option, message, subTitle;
33+
let cookiesArr = [], cookie = '', jdPlantBeanShareArr = [], isBox = false, notify, newShareCodes, option, message,
34+
subTitle;
3435
//京东接口地址
3536
const JD_API_HOST = 'https://api.m.jd.com/client.action';
3637
//助力好友分享码(最多3个,否则后面的助力失败)
@@ -281,14 +282,18 @@ async function doTask() {
281282
const {data} = $.shopTaskListRes;
282283
let goodShopListARR = [], moreShopListARR = [], shopList = [];
283284
const {goodShopList, moreShopList} = data;
284-
for (let i of goodShopList) {
285-
if (i.taskState === '2') {
286-
goodShopListARR.push(i);
285+
if (goodShopList) {
286+
for (let i of goodShopList) {
287+
if (i.taskState === '2') {
288+
goodShopListARR.push(i);
289+
}
287290
}
288291
}
289-
for (let j of moreShopList) {
290-
if (j.taskState === '2') {
291-
moreShopListARR.push(j);
292+
if (moreShopList) {
293+
for (let j of moreShopList) {
294+
if (j.taskState === '2') {
295+
moreShopListARR.push(j);
296+
}
292297
}
293298
}
294299
shopList = goodShopListARR.concat(moreShopListARR);
@@ -498,7 +503,10 @@ async function collectUserNutr(paradiseUuid) {
498503
}
499504

500505
async function receiveNutrients() {
501-
$.receiveNutrientsRes = await request('receiveNutrients', {"roundId": currentRoundId, "monitor_refer": "plant_receiveNutrients"})
506+
$.receiveNutrientsRes = await request('receiveNutrients', {
507+
"roundId": currentRoundId,
508+
"monitor_refer": "plant_receiveNutrients"
509+
})
502510
// console.log(`定时领取营养液结果:${JSON.stringify($.receiveNutrientsRes)}`)
503511
}
504512

@@ -851,7 +859,11 @@ function Env(t, e) {
851859
i = i ? i.replace(/\n/g, "").trim() : i;
852860
let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");
853861
r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r;
854-
const [o, h] = i.split("@"), n = {url: `http://${h}/v1/scripting/evaluate`, body: {script_text: t, mock_type: "cron", timeout: r}, headers: {"X-Key": o, Accept: "*/*"}};
862+
const [o, h] = i.split("@"), n = {
863+
url: `http://${h}/v1/scripting/evaluate`,
864+
body: {script_text: t, mock_type: "cron", timeout: r},
865+
headers: {"X-Key": o, Accept: "*/*"}
866+
};
855867
this.post(n, (t, e, i) => s(i))
856868
}).catch(t => this.logErr(t))
857869
}
@@ -860,7 +872,8 @@ function Env(t, e) {
860872
if (!this.isNode()) return {};
861873
{
862874
this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
863-
const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e);
875+
const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile),
876+
s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e);
864877
if (!s && !i) return {};
865878
{
866879
const i = s ? t : e;
@@ -876,7 +889,8 @@ function Env(t, e) {
876889
writedata() {
877890
if (this.isNode()) {
878891
this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
879-
const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data);
892+
const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile),
893+
s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data);
880894
s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r)
881895
}
882896
}
@@ -980,7 +994,15 @@ function Env(t, e) {
980994

981995
time(t, e = null) {
982996
const s = e ? new Date(e) : new Date;
983-
let i = {"M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds()};
997+
let i = {
998+
"M+": s.getMonth() + 1,
999+
"d+": s.getDate(),
1000+
"H+": s.getHours(),
1001+
"m+": s.getMinutes(),
1002+
"s+": s.getSeconds(),
1003+
"q+": Math.floor((s.getMonth() + 3) / 3),
1004+
S: s.getMilliseconds()
1005+
};
9841006
/(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length)));
9851007
for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length)));
9861008
return t

0 commit comments

Comments
 (0)
Please sign in to comment.