| 454 | } |
| 455 | |
| 456 | function totalBean() { |
| 457 | return new Promise(async resolve => { |
| 458 | const options = { |
| 459 | "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, |
| 460 | "headers": { |
| 461 | "Accept": "application/json,text/plain, */*", |
| 462 | "Content-Type": "application/x-www-form-urlencoded", |
| 463 | "Accept-Encoding": "gzip, deflate, br", |
| 464 | "Accept-Language": "zh-cn", |
| 465 | "Connection": "keep-alive", |
| 466 | "Cookie": $.cookie, |
| 467 | "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", |
| 468 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") |
| 469 | }, |
| 470 | "timeout": 10000, |
| 471 | } |
| 472 | $.post(options, (err, resp, data) => { |
| 473 | try { |
| 474 | if (err) { |
| 475 | console.log(`${JSON.stringify(err)}`) |
| 476 | console.log(`${$.name} API请求失败,请检查网路重试`) |
| 477 | } else { |
| 478 | if (data) { |
| 479 | data = JSON.parse(data); |
| 480 | if (data['retcode'] === 13) { |
| 481 | $.isLogin = false; //cookie过期 |
| 482 | return |
| 483 | } |
| 484 | if (data['retcode'] === 0) { |
| 485 | $.nickName = (data['base'] && data['base'].nickname) || $.UserName; |
| 486 | } else { |
| 487 | $.nickName = $.UserName |
| 488 | } |
| 489 | } else { |
| 490 | console.log(`京东服务器返回空数据`) |
| 491 | } |
| 492 | } |
| 493 | } catch (e) { |
| 494 | $.logErr(e, resp) |
| 495 | } finally { |
| 496 | resolve(); |
| 497 | } |
| 498 | }) |
| 499 | }) |
| 500 | } |
| 501 | |
| 502 | function jsonParse(str) { |
| 503 | if (typeof str == "string") { |