| 287 | } |
| 288 | |
| 289 | function doTask(taskId) { |
| 290 | let body = {"action": "MARK", "taskId": taskId} |
| 291 | return new Promise(async resolve => { |
| 292 | $.get(taskUrl('crazyJoy_task_viewPage', JSON.stringify(body)), async (err, resp, data) => { |
| 293 | try { |
| 294 | if (err) { |
| 295 | console.log(`${JSON.stringify(err)}`) |
| 296 | console.log(`${$.name} API请求失败,请检查网路重试`) |
| 297 | } else { |
| 298 | if (safeGet(data)) { |
| 299 | data = JSON.parse(data); |
| 300 | if (data.success && data.data && data.data.taskRecordId) { |
| 301 | console.log(`去做任务【${data.data.taskTitle}】,任务id: ${data.data.taskRecordId}`) |
| 302 | await $.wait(30000) |
| 303 | await recordTask(taskId, data.data.taskRecordId) |
| 304 | } else { |
| 305 | console.log(`获取信息失败`) |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | } catch (e) { |
| 310 | $.logErr(e, resp) |
| 311 | } finally { |
| 312 | resolve(); |
| 313 | } |
| 314 | }) |
| 315 | }) |
| 316 | } |
| 317 | |
| 318 | function recordTask(taskId, taskRecordId) { |
| 319 | let body = {"action": "INCREASE", "taskId": taskId, "taskRecordId": taskRecordId} |