(taskType, value)
| 372 | } |
| 373 | // 完成任务 |
| 374 | function doTask(taskType, value) { |
| 375 | let body = `activityId=${ACT_ID}&pin=${encodeURIComponent($.pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${value}` |
| 376 | return new Promise(resolve => { |
| 377 | $.post(taskPostUrl('dingzhi/vm/template/saveTask', body), async (err, resp, data) => { |
| 378 | try { |
| 379 | if (err) { |
| 380 | console.log(`${err}`) |
| 381 | console.log(`${$.name} API请求失败,请检查网路重试`) |
| 382 | } else { |
| 383 | if (safeGet(data)) { |
| 384 | data = JSON.parse(data); |
| 385 | if (data.result && data.data) { |
| 386 | console.log(`任务完成成功,获得${data.data.score}金币`) |
| 387 | $.score += data.data.score |
| 388 | } else { |
| 389 | console.log(`任务完成失败,错误信息:${data.errorMessage}`) |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | } catch (e) { |
| 394 | $.logErr(e, resp) |
| 395 | } finally { |
| 396 | resolve(data); |
| 397 | } |
| 398 | }) |
| 399 | }) |
| 400 | |
| 401 | } |
| 402 | function showMsg() { |
| 403 | return new Promise(resolve => { |
| 404 | message += `本次运行获得金币${$.score}枚`; |
no test coverage detected