()
| 164 | return this.loginCode; |
| 165 | } |
| 166 | async getOpenId() { |
| 167 | try { |
| 168 | let options = { |
| 169 | method: 'POST', |
| 170 | url: `${API_BASE}/v1/app/code2Session`, |
| 171 | headers: this.getMiniHeaders(), |
| 172 | data: this.getSignedBody({ miniAppId: MINI_APP_ID, code: await this.getLoginCode(true) }) |
| 173 | } |
| 174 | let { data: result } = await axios.request(options); |
| 175 | if (result.code == 0) { |
| 176 | this.openId = result.data.openid |
| 177 | |
| 178 | this.unionId = result.data.unionid |
| 179 | $.log(`账号[${this.index}] code2Session成功`); |
| 180 | return true |
| 181 | } else { |
| 182 | $.log(`账号[${this.index}] code2Session失败❌ ${result.msg || ""}`); |
| 183 | this.ckStatus = false |
| 184 | |
| 185 | console.log(result); |
| 186 | return false |
| 187 | } |
| 188 | } catch (e) { |
| 189 | $.log(`账号[${this.index}] code2Session异常❌ ${e.message || e}`); |
| 190 | this.ckStatus = false |
| 191 | return false |
| 192 | } |
| 193 | } |
| 194 | async loginByWxCode() { |
| 195 | try { |
| 196 | const ok = await this.getOpenId(); |
no test coverage detected