Skip to content

Commit

Permalink
chore: api update
Browse files Browse the repository at this point in the history
  • Loading branch information
qiin committed Oct 19, 2023
1 parent 918b9ef commit fa54f16
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,32 +252,47 @@ export default class MonkeyMaster {
const addrsMsg = addrs
.map(
(addr, index) =>
`[${index}]: ${addr.addressName}-${addr.fullAddress}-${addr.mobile}`
`[${index}]: ${addr.Name}-${addr.Where}-${addr.Mobile}`
)
.join('\n');
const index = prompt(
`选择下单地址: 默认为首个 \n${addrsMsg} \n`,
0
);
this.addr = addrs[index];
this.areaId = genAreaId(this.addr);

const { Id, address } = addrs[index]
this.addr = {
...addrs[index],
id: Id
};
this.areaId = address.split(',').join('_');
console.log(`area id 获取成功: ${this.areaId}`);
}
}

async getUserAddr() {
const url = buildUrl('https://cd.jd.com/usual/address', {
queryParams: {
callback: `jQuery${random.int(1000000, 9999999)}`,
_: String(Date.now()),
},
});

this.headers.set('Referer', 'https://item.jd.com/');
const url = 'https://api.m.jd.com/api?functionId=j_getAddressByPin';
const urlencoded = makeCommonPostFormData();
const headers = new Headers(this.headers);
headers.set('Origin', 'https://fq.jr.jd.com');
urlencoded.append(
'body',
JSON.stringify({
coordtype: '2',
jsToken: this.eid,
skuId: this.skuids[0],
rid: Date.now(),
})
);

const res = await mFetch(url, { headers: this.headers });
const res = await fetchAndRetry(url, {
method: 'POST',
referer: 'https://fq.jr.jd.com/',
headers,
body: urlencoded,
}).then((r) => r.json());

return str2Json(await res.text());
return res.addressList;
}

saveCookie(cookie) {
Expand Down

0 comments on commit fa54f16

Please sign in to comment.