| 385 | |
| 386 | // 抽奖 |
| 387 | function draw() { |
| 388 | let body = `activityId=${ACT_ID}&pin=${encodeURIComponent($.token)}&actorUuid=${$.actorUuid}` |
| 389 | return new Promise(resolve => { |
| 390 | $.post(taskPostUrl('dingzhi/book/develop/startDraw', body), async (err, resp, data) => { |
| 391 | try { |
| 392 | if (err) { |
| 393 | console.log(`${$.name} API请求失败,请检查网路重试`) |
| 394 | } else { |
| 395 | if (data && safeGet(data)) { |
| 396 | data = JSON.parse(data); |
| 397 | if (data.result && data.data) { |
| 398 | if (data.data.name) { |
| 399 | console.log(`抽奖成功,获得奖品:${data.data.name}`) |
| 400 | message += `抽奖成功,获得奖品:${data.data.name}\n` |
| 401 | } else { |
| 402 | console.log(`抽奖成功,获得空气`) |
| 403 | message += `抽奖成功,获得空气` |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | } catch (e) { |
| 409 | $.logErr(e, resp) |
| 410 | } finally { |
| 411 | resolve(data); |
| 412 | } |
| 413 | }) |
| 414 | }) |
| 415 | } |
| 416 | |
| 417 | // 获得图书 |
| 418 | function getAllBook() { |