MCPcopy Create free account
hub / github.com/Semporia/Scripts / TotalBean

Function TotalBean

jd_pet.js:565–608  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

563 })
564}
565function TotalBean() {
566 return new Promise(async resolve => {
567 const options = {
568 "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`,
569 "headers": {
570 "Accept": "application/json,text/plain, */*",
571 "Content-Type": "application/x-www-form-urlencoded",
572 "Accept-Encoding": "gzip, deflate, br",
573 "Accept-Language": "zh-cn",
574 "Connection": "keep-alive",
575 "Cookie": cookie,
576 "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2",
577 "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")
578 }
579 }
580 $.post(options, (err, resp, data) => {
581 try {
582 if (err) {
583 console.log(`${JSON.stringify(err)}`)
584 console.log(`${$.name} TotalBean API请求失败,请检查网路重试`)
585 } else {
586 if (data) {
587 data = JSON.parse(data);
588 if (data['retcode'] === 13) {
589 $.isLogin = false; //cookie过期
590 return
591 }
592 if (data['retcode'] === 0) {
593 $.nickName = (data['base'] && data['base'].nickname) || $.UserName;
594 } else {
595 $.nickName = $.UserName
596 }
597 } else {
598 console.log(`京东服务器返回空数据`)
599 }
600 }
601 } catch (e) {
602 $.logErr(e, resp)
603 } finally {
604 resolve();
605 }
606 })
607 })
608}
609// 请求
610async function request(function_id, body = {}) {
611 await $.wait(3000); //歇口气儿, 不然会报操作频繁

Callers 1

jd_pet.jsFile · 0.70

Calls 5

isNodeMethod · 0.45
getdataMethod · 0.45
postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected