main
KingRan 2023-09-14 23:51:27 +08:00
parent b6bfa5ed10
commit 618be6eaa5
1 changed files with 39 additions and 35 deletions

View File

@ -234,8 +234,8 @@ function toSDS(name){
} }
return res return res
} }
function jdApi(functionId,body) { function jdApi(functionId, body) {
if(!functionId || !body) return if (!functionId || !body) return
return new Promise(resolve => { return new Promise(resolve => {
$.post(taskPostUrl(`/client.action?functionId=${functionId}`, body), async (err, resp, data) => { $.post(taskPostUrl(`/client.action?functionId=${functionId}`, body), async (err, resp, data) => {
try { try {
@ -243,11 +243,15 @@ function jdApi(functionId,body) {
console.log(`${$.toStr(err)}`) console.log(`${$.toStr(err)}`)
console.log(`${$.name} API请求失败请检查网路重试`) console.log(`${$.name} API请求失败请检查网路重试`)
} else { } else {
let res = $.toObj(data,data); // console.log(data)
if(typeof res == 'object'){ let res = $.toObj(data, data);
if(res.mainTitle) console.log(res.mainTitle) if (typeof res == 'object') {
if(res.resultCode == 0){ if (res.mainTitle) console.log(res.mainTitle)
if (res.resultCode == 0) {
resolve(res); resolve(res);
} else if (res.tips && res.tips.includes("正在努力加载")) {
console.log("请求太快ip被限制了")
$.out = true
} }
} }
} }
@ -320,8 +324,8 @@ function jdSign(fn, body) {
function taskPostUrl(url, body) { function taskPostUrl(url, body) {
return { return {
url: `https://api.m.jd.com${url}`, url: `https://api.m.jd.com${url}&${body}`,
body: body, //body: body,
headers: { headers: {
"Accept": "*/*", "Accept": "*/*",
"Accept-Language": "zh-cn", "Accept-Language": "zh-cn",
@ -330,7 +334,7 @@ function taskPostUrl(url, body) {
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
'Cookie': `${cookie}`, 'Cookie': `${cookie}`,
"Host": "api.m.jd.com", "Host": "api.m.jd.com",
"User-Agent": "JD4iPhone/167853 (iPhone; iOS; Scale/2.00)" , "User-Agent": "JD4iPhone/167853 (iPhone; iOS; Scale/2.00)",
} }
} }
} }