()
| 579 | } |
| 580 | |
| 581 | async sign() { |
| 582 | try { |
| 583 | const reward = await this.getReward(); |
| 584 | if (!reward.isEnabled) return "未开启签到"; |
| 585 | |
| 586 | const progress = await this.getProgress(reward.signCycle); |
| 587 | const state = this.getSignedState(reward, progress); |
| 588 | $.log(`${this.prefix()} 签到状态: signType=${state.signType} signMode=${state.signMode} currentDay=${state.currentDay} signed=${state.signed}`); |
| 589 | |
| 590 | if (state.signed) return "今日已签到"; |
| 591 | |
| 592 | const result = await this.ctx.request({ |
| 593 | method: "POST", |
| 594 | apiPath: state.apiPath, |
| 595 | shopId: this.shop.shopId, |
| 596 | token: this.token, |
| 597 | data: { longitude: 0, latitude: 0 }, |
| 598 | bizCode: createGuid(), |
| 599 | }); |
| 600 | if (!result.success) throw new Error(result.msg || JSON.stringify(result)); |
| 601 | const data = result.data || {}; |
| 602 | return `签到成功${data.rewardName || data.prizeName ? ` 奖励=${data.rewardName || data.prizeName}` : ""}`; |
| 603 | } catch (e) { |
| 604 | return `签到失败: ${e.message || e}`; |
| 605 | } |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | !(async () => { |
no test coverage detected