MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / loginByWxCode

Method loginByWxCode

wxapp/haitian.js:245–272  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

243 }
244
245 async loginByWxCode() {
246 try {
247 const wxData = await this.getOperateData();
248 const articleIds = await this.getArticleIds();
249 const params = {
250 edata: wxData.encryptedData,
251 iv: wxData.iv,
252 code: wxData.code,
253 uuid: this.uuid,
254 article_ids: articleIds,
255 app_versions: "1.0.0",
256 };
257 const result = await this.request("/wechat/mini/phoneNew/login", {
258 method: "POST",
259 params,
260 auth: false,
261 });
262 const token = result?.access_token || result?.accessToken || "";
263 if (!result?.success || !token) throw new Error(`登录响应未返回token: ${JSON.stringify(result)}`);
264 this.token = token;
265 this.refreshToken = result.refresh_token || result.refreshToken || "";
266 await this.loginCommunityToken().catch(() => {});
267 this.saveCachedToken();
268 $.log(`账号[${this.index}] CODE登录成功: ${shortToken(this.token)}`);
269 } catch (e) {
270 $.log(`账号[${this.index}] CODE登录失败: ${e.message || e}`);
271 }
272 }
273
274 async loginCommunityToken() {
275 if (!this.token) return;

Callers 1

runMethod · 0.95

Calls 7

getOperateDataMethod · 0.95
getArticleIdsMethod · 0.95
requestMethod · 0.95
loginCommunityTokenMethod · 0.95
saveCachedTokenMethod · 0.95
shortTokenFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected