()
| 190 | } |
| 191 | |
| 192 | async loginByWxCode() { |
| 193 | try { |
| 194 | const code = await this.getLoginCode(); |
| 195 | const data = await this.request({ |
| 196 | method: "POST", |
| 197 | path: "/user/login/wx-jc", |
| 198 | auth: false, |
| 199 | data: { |
| 200 | jsCode: code, |
| 201 | clientId: CLIENT_ID, |
| 202 | myUnionId: "", |
| 203 | appPublishType: APP_PUBLISH_TYPE, |
| 204 | }, |
| 205 | }); |
| 206 | this.token = pickToken(data); |
| 207 | this.userInfo = data?.thirdUsrIf || {}; |
| 208 | if (!this.token) throw new Error(`登录响应未返回token: ${JSON.stringify(data)}`); |
| 209 | this.saveCachedToken(); |
| 210 | $.log(`账号[${this.index}] 登录成功: ${maskPhone(this.userInfo.phone) || this.userInfo.oid || ""}`); |
| 211 | } catch (e) { |
| 212 | $.log(`账号[${this.index}] 登录失败: ${e.message || e}`); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | async checkToken() { |
| 217 | try { |
no test coverage detected