MCPcopy Create free account
hub / github.com/6dylan6/jdm / extraTaskPrize

Function extraTaskPrize

jd_computer.js:227–280  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

225 })
226}
227function extraTaskPrize() {
228 if($.outFlag != 0) return
229 return new Promise(async resolve => {
230 let sign = getSign(`/tzh/combination/extraTaskPrize`,{"activityId": activityId})
231 $.post({
232 url: `https://combination.m.jd.com/tzh/combination/extraTaskPrize`,
233 body: `activityId=${activityId}&t=${sign.timestamp}`,
234 headers: {
235 'Accept': 'application/json, text/plain, */*',
236 "Accept-Language": "zh-cn",
237 "Connection": "keep-alive",
238 "Accept-Encoding": "gzip, deflate, br",
239 "Content-Type": "application/x-www-form-urlencoded",
240 'Cookie': cookie,
241 'User-Agent': $.UA,
242 'sign': sign.sign,
243 'timestamp': sign.timestamp
244 }
245 }, async (err, resp, data) => {
246 try {
247 if (err) {
248 console.log(`${$.toStr(err)}`)
249 console.log(`${$.name} API请求失败,请检查网路重试`)
250 } else {
251 // console.log(data)
252 let res = $.toObj(data)
253 if(typeof res == 'object'){
254 if(res.code == 200 && res.data){
255 let msg = res.data.jdNum && res.data.jdNum+"京豆" || ''
256 if(res.data.jdNum){
257 console.log(`获得 ${msg}`)
258 $.bean += Number(res.data.jdNum) || 0
259 }else{
260 console.log(data)
261 }
262 }else if(res.msg){
263 if(res.msg.indexOf('活动太火爆') > -1){
264 $.hotFlag = true
265 }
266 console.log(res.msg)
267 }else{
268 console.log(`活动获取失败\n${data}`)
269 console.log(data)
270 }
271 }
272 }
273 } catch (e) {
274 $.logErr(e, resp)
275 } finally {
276 resolve();
277 }
278 })
279 })
280}
281function getData(url) {
282 return new Promise(async resolve => {
283 const options = {

Callers 1

runFunction · 0.85

Calls 6

getSignFunction · 0.70
postMethod · 0.45
logMethod · 0.45
toStrMethod · 0.45
toObjMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected