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

Method login

wxapp/junpinhui.js:222–238  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

220 }
221
222 async login() {
223 const code = await this.getWxCode();
224 const data = assertOk(
225 await request("post", FM_BASE, "/api/v2/login/wxMiniSilentLogin", {
226 data: { code },
227 }),
228 "静默登录"
229 );
230 if (!data?.token) throw new Error(`静默登录未返回 token: ${JSON.stringify(data)}`);
231 this.token = data.token;
232 this.saveCache({
233 unionId: data.unionId || "",
234 phone: data.phone || "",
235 mainOpenId: data.openId || "",
236 });
237 $.log(`账号[${this.index}] 登录成功: ${mask(data.phone || data.openId || this.token)}`);
238 }
239
240 async ensureLogin() {
241 if (!this.token) this.token = this.getCached().token || "";

Callers 2

ensureLoginMethod · 0.95
withReloginMethod · 0.95

Calls 6

getWxCodeMethod · 0.95
saveCacheMethod · 0.95
assertOkFunction · 0.70
requestFunction · 0.70
maskFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected