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

Function doTask

jd_computer.js:170–226  ·  view source on GitHub ↗
(type, id, taskId)

Source from the content-addressed store, hash-verified

168 })
169}
170function doTask(type, id, taskId) {
171 if($.outFlag != 0) return
172 return new Promise(async resolve => {
173 let sign = getSign(`/tzh/combination/${type}`,{"activityId": activityId,"id":id,"taskId":taskId})
174 $.post({
175 url: `https://combination.m.jd.com/tzh/combination/${type}`,
176 body: `activityId=${activityId}&id=${id}&taskId=${taskId}&t=${sign.timestamp}`,
177 headers: {
178 'Accept': 'application/json, text/plain, */*',
179 "Accept-Language": "zh-cn",
180 "Connection": "keep-alive",
181 "Accept-Encoding": "gzip, deflate, br",
182 "Content-Type": "application/x-www-form-urlencoded",
183 'Cookie': cookie,
184 'User-Agent': $.UA,
185 'sign': sign.sign,
186 'timestamp': sign.timestamp
187 }
188 }, async (err, resp, data) => {
189 try {
190 if (err) {
191 console.log(`${$.toStr(err)}`)
192 console.log(`${$.name} API请求失败,请检查网路重试`)
193 } else {
194 // console.log(data)
195 let res = $.toObj(data)
196 if(typeof res == 'object'){
197 if(res.code == 200 && res.data){
198 let msg = res.data.jdNum && res.data.jdNum+"京豆" || ''
199 if(res.data.jdNum){
200 console.log(`获得 ${msg}`)
201 $.bean += Number(res.data.jdNum) || 0
202 }else{
203 console.log(data)
204 }
205 }else if(res.msg){
206 if(res.msg.indexOf('活动太火爆') > -1){
207 $.hotFlag = true
208 }else if(res.msg.indexOf('京豆已被抢光') > -1){
209 message += res.msg+"\n"
210 $.outFlag = 1
211 }
212 console.log(res.msg)
213 }else{
214 console.log(`活动获取失败\n${data}`)
215 console.log(data)
216 }
217 }
218 }
219 } catch (e) {
220 $.logErr(e, resp)
221 } finally {
222 resolve();
223 }
224 })
225 })
226}
227function extraTaskPrize() {

Callers 1

runFunction · 0.70

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