()
| 179 | } |
| 180 | |
| 181 | async loginByWxCode() { |
| 182 | try { |
| 183 | const code = await this.getLoginCode(); |
| 184 | const result = await this.request("GET", `estore/member/onLogin/${code}/${WECHAT_ID}`, {}, { auth: true }); |
| 185 | const user = result.data || {}; |
| 186 | this.applyToken({ |
| 187 | token: user.token, |
| 188 | memberId: user.id, |
| 189 | customerNo: user.customerNo, |
| 190 | phone: user.phone, |
| 191 | levels: user.levels, |
| 192 | }); |
| 193 | this.saveCachedToken(); |
| 194 | $.log(`账号[${this.index}] 登录成功: ${this.levels || "会员"} ${this.customerNo || this.memberId || ""}`); |
| 195 | } catch (e) { |
| 196 | $.log(`账号[${this.index}] 登录失败: ${e.message || e}`); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | async checkToken() { |
| 201 | try { |
no test coverage detected