()
| 172 | } |
| 173 | |
| 174 | async loginByWxCode() { |
| 175 | try { |
| 176 | const code = await this.getLoginCode(); |
| 177 | const result = await this.request("auth/login_by_weixin", { |
| 178 | method: "POST", |
| 179 | auth: false, |
| 180 | data: { |
| 181 | code, |
| 182 | userInfo: {}, |
| 183 | shareUserId: 1, |
| 184 | }, |
| 185 | }); |
| 186 | const token = result?.data?.token || ""; |
| 187 | if (!token) throw new Error(`登录响应未返回token: ${JSON.stringify(result)}`); |
| 188 | this.token = token; |
| 189 | this.userInfo = result?.data?.userInfo || {}; |
| 190 | this.saveCachedToken(); |
| 191 | $.log(`账号[${this.index}] 登录成功: ${this.userInfo.nickname || maskPhone(this.userInfo.mobile) || this.userId}`); |
| 192 | } catch (e) { |
| 193 | $.log(`账号[${this.index}] 登录失败: ${e.message || e}`); |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | async checkToken() { |
| 198 | try { |
no test coverage detected