()
| 192 | } |
| 193 | } |
| 194 | async loginByWxCode() { |
| 195 | try { |
| 196 | const ok = await this.getOpenId(); |
| 197 | if (!ok) return; |
| 198 | let options = { |
| 199 | method: 'POST', |
| 200 | url: `${API_BASE}/v1/app/regByUnionid`, |
| 201 | headers: this.getMiniHeaders(), |
| 202 | data: this.getSignedBody({ |
| 203 | code: this.loginCode, |
| 204 | openId: this.openId, |
| 205 | unionid: this.unionId, |
| 206 | third: "wxmini", |
| 207 | miniAppId: MINI_APP_ID |
| 208 | }) |
| 209 | }; |
| 210 | let { data: result } = await axios.request(options); |
| 211 | if (result.code == 0) { |
| 212 | this.ck = result.data.accessToken; |
| 213 | this.ckStatus = !!this.ck; |
| 214 | this.mobilePhone = result.data.mobilePhone; |
| 215 | this.saveCachedToken(); |
| 216 | $.log(`账号[${this.index}] 登录成功: [${maskPhone(this.mobilePhone) || "未绑定手机号"}]`); |
| 217 | } else { |
| 218 | $.log(`账号[${this.index}] 登录失败❌ ${result.msg || ""}`); |
| 219 | this.ckStatus = false; |
| 220 | console.log(result); |
| 221 | } |
| 222 | } catch (e) { |
| 223 | $.log(`账号[${this.index}] 登录异常❌ ${e.response?.data?.msg || e.message || e}`); |
| 224 | this.ckStatus = false; |
| 225 | } |
| 226 | } |
| 227 | async user_info() { |
| 228 | let time = Date.now() |
| 229 | try { |
no test coverage detected