()
| 226 | } |
| 227 | |
| 228 | async loginByWxCode() { |
| 229 | try { |
| 230 | await this.getIdentityInfo(); |
| 231 | const code = await this.getLoginCode(); |
| 232 | const result = await this.request({ |
| 233 | apiPath: "/tnew/myfoodiepet-member/v1/wechat/applet/authorizeV2", |
| 234 | params: { code }, |
| 235 | }); |
| 236 | const data = result.data || {}; |
| 237 | this.openId = data.openId || ""; |
| 238 | this.unionId = data.unionId || ""; |
| 239 | this.memberId = String(data.memberId || ""); |
| 240 | this.phone = data.phone || ""; |
| 241 | if (!this.memberId) throw new Error(`登录响应未返回 memberId: ${JSON.stringify(result)}`); |
| 242 | this.saveCachedToken(); |
| 243 | $.log(`账号[${this.index}] 登录成功: memberId=${shortValue(this.memberId)} ${maskPhone(this.phone)}`); |
| 244 | } catch (e) { |
| 245 | $.log(`账号[${this.index}] 登录失败: ${e.message || e}`); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | async checkLogin() { |
| 250 | try { |
no test coverage detected