| 316 | } |
| 317 | |
| 318 | function recordTask(taskId, taskRecordId) { |
| 319 | let body = {"action": "INCREASE", "taskId": taskId, "taskRecordId": taskRecordId} |
| 320 | return new Promise(async resolve => { |
| 321 | $.get(taskUrl('crazyJoy_task_viewPage', JSON.stringify(body)), async (err, resp, data) => { |
| 322 | try { |
| 323 | if (err) { |
| 324 | console.log(`${JSON.stringify(err)}`) |
| 325 | console.log(`${$.name} API请求失败,请检查网路重试`) |
| 326 | } else { |
| 327 | if (safeGet(data)) { |
| 328 | data = JSON.parse(data); |
| 329 | if (data.success) { |
| 330 | console.log(`任务【${data.data.taskTitle}】记录成功,去领奖`) |
| 331 | await awardTask(taskId) |
| 332 | } else { |
| 333 | console.log(`获取信息失败`) |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | } catch (e) { |
| 338 | $.logErr(e, resp) |
| 339 | } finally { |
| 340 | resolve(); |
| 341 | } |
| 342 | }) |
| 343 | }) |
| 344 | } |
| 345 | |
| 346 | function awardTask(taskId) { |
| 347 | let body = {"taskId": taskId} |