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

Function smtg_queryPrize

jd_blueCoin.js:239–284  ·  view source on GitHub ↗
(timeout = 0)

Source from the content-addressed store, hash-verified

237}
238//查询任务
239function smtg_queryPrize(timeout = 0){
240 $.queryPrizeData = [];
241 return new Promise((resolve) => {
242 setTimeout( ()=>{
243 let url = {
244 url : `${JD_API_HOST}&functionId=smt_queryPrizeAreas&clientVersion=8.0.0&client=m&body=%7B%22channel%22%3A%2218%22%7D&t=${Date.now()}`,
245 headers : {
246 'Origin' : `https://jdsupermarket.jd.com`,
247 'Cookie' : cookie,
248 'Connection' : `keep-alive`,
249 'Accept' : `application/json, text/plain, */*`,
250 'Referer' : `https://jdsupermarket.jd.com/game/?tt=1597540727225`,
251 'Host' : `api.m.jd.com`,
252 'Accept-Encoding' : `gzip, deflate, br`,
253 'Accept-Language' : `zh-cn`
254 }
255 }
256 $.post(url, async (err, resp, data) => {
257 try {
258 if (safeGet(data)) {
259 data = JSON.parse(data);
260 // $.queryPrizeData = data;
261 if (data.data.bizCode !== 0) {
262 console.log(`${data.data.bizMsg}\n`)
263 $.beanerr = `${data.data.bizMsg}`;
264 return
265 }
266 if (data.data.bizCode === 0) {
267 const { areas } = data.data.result;
268 const prizes = areas.filter(vo => vo['type'] === 4);
269 if (prizes && prizes[0]) {
270 $.areaId = prizes[0].areaId;
271 $.periodId = prizes[0].periodId;
272 $.queryPrizeData = prizes[0].prizes || [];
273 }
274 }
275 }
276 } catch (e) {
277 $.logErr(e, resp);
278 } finally {
279 resolve()
280 }
281 })
282 },timeout)
283 })
284}
285//换京豆
286function smtg_obtainPrize(prizeId, timeout = 0, functionId = 'smt_exchangePrize') {
287 //1000京豆,prizeId为4401379726

Callers 1

PrizeIndexFunction · 0.85

Calls 4

safeGetFunction · 0.70
postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected