From 618be6eaa509463288c77be100c57971e82c1631 Mon Sep 17 00:00:00 2001 From: KingRan Date: Thu, 14 Sep 2023 23:51:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_cleancart_nolan.js | 74 +++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/jd_cleancart_nolan.js b/jd_cleancart_nolan.js index 7314056..315dd7d 100644 --- a/jd_cleancart_nolan.js +++ b/jd_cleancart_nolan.js @@ -234,30 +234,34 @@ function toSDS(name){ } return res } -function jdApi(functionId,body) { - if(!functionId || !body) return - return new Promise(resolve => { - $.post(taskPostUrl(`/client.action?functionId=${functionId}`, body), async (err, resp, data) => { - try { - if (err) { - console.log(`${$.toStr(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - let res = $.toObj(data,data); - if(typeof res == 'object'){ - if(res.mainTitle) console.log(res.mainTitle) - if(res.resultCode == 0){ - resolve(res); +function jdApi(functionId, body) { + if (!functionId || !body) return + return new Promise(resolve => { + $.post(taskPostUrl(`/client.action?functionId=${functionId}`, body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.toStr(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + // console.log(data) + let res = $.toObj(data, data); + if (typeof res == 'object') { + if (res.mainTitle) console.log(res.mainTitle) + if (res.resultCode == 0) { + resolve(res); + } else if (res.tips && res.tips.includes("正在努力加载")) { + console.log("请求太快,ip被限制了") + $.out = true + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(''); } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(''); - } + }) }) - }) } function jdSign(fn, body) { @@ -319,20 +323,20 @@ function jdSign(fn, body) { function taskPostUrl(url, body) { - return { - url: `https://api.m.jd.com${url}`, - body: body, - headers: { - "Accept": "*/*", - "Accept-Language": "zh-cn", - "Accept-Encoding": "gzip, deflate, br", - "Connection": "keep-alive", - "Content-Type": "application/x-www-form-urlencoded", - 'Cookie': `${cookie}`, - "Host": "api.m.jd.com", - "User-Agent": "JD4iPhone/167853 (iPhone; iOS; Scale/2.00)" , + return { + url: `https://api.m.jd.com${url}&${body}`, + //body: body, + headers: { + "Accept": "*/*", + "Accept-Language": "zh-cn", + "Accept-Encoding": "gzip, deflate, br", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + 'Cookie': `${cookie}`, + "Host": "api.m.jd.com", + "User-Agent": "JD4iPhone/167853 (iPhone; iOS; Scale/2.00)", + } } - } } function randomString(e) {