()
| 107 | } |
| 108 | |
| 109 | async loginByWxCode() { |
| 110 | try { |
| 111 | const code = await this.getLoginCode(); |
| 112 | const tokenInfo = await this.jscode2session(code); |
| 113 | const accountToken = tokenInfo?.accountToken; |
| 114 | if (!accountToken) throw new Error(`登录响应未返回 accountToken: ${JSON.stringify(tokenInfo)}`); |
| 115 | await this.queryUserInfo(accountToken); |
| 116 | this.token = accountToken; |
| 117 | $.log(`账号[${this.index}] CODE登录成功: ${maskToken(this.token)}`); |
| 118 | } catch (e) { |
| 119 | $.log(`账号[${this.index}] CODE登录失败: ${e.message || e}`); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | async jscode2session(code) { |
| 124 | const path = "/api-gw/oauthserver/applet/v1/jscode2session"; |
no test coverage detected