()
| 457 | } |
| 458 | |
| 459 | async login() { |
| 460 | try { |
| 461 | const code = await this.ctx.getCode(this.account); |
| 462 | const result = await this.ctx.request({ |
| 463 | method: "POST", |
| 464 | apiPath: "/capp/account/login", |
| 465 | shopId: this.shop.shopId, |
| 466 | data: { code }, |
| 467 | }); |
| 468 | if (!result.success) throw new Error(result.msg || JSON.stringify(result)); |
| 469 | this.applyLogin(result.data || {}); |
| 470 | if (!this.token) throw new Error(`登录响应无token: ${JSON.stringify(result)}`); |
| 471 | this.saveToken(); |
| 472 | $.log(`${this.prefix()} 登录成功 token=${shortToken(this.token)}`); |
| 473 | } catch (e) { |
| 474 | $.log(`${this.prefix()} 登录失败: ${e.message || e}`); |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | async getAssets() { |
| 479 | const assets = { coin: 0, integral: 0, ticket: 0, coupon: 0 }; |
no test coverage detected