MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / login

Method login

wxapp/airui.js:168–194  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

166 }
167
168 async login() {
169 const code = await this.getWxCode();
170 const result = assertOk(
171 await apiRequest("POST", "/app/auth/authorization", {
172 params: {
173 code,
174 type: "register",
175 acceptCode: "",
176 },
177 }),
178 "登录授权"
179 );
180
181 if (Number(result.mobileAuthStatus) !== 1 || !result.token) {
182 throw new Error("账号未完成手机号授权,需先在小程序登录一次");
183 }
184
185 this.token = result.token;
186 this.userId = result.userId || "";
187 this.saveCache({
188 openid: result.openid || "",
189 unionid: result.unionid || "",
190 userName: result.userName || "",
191 inviteCode: result.inviteCode || "",
192 });
193 $.log(`账号[${this.index}] 登录成功: ${mask(this.userId || this.token)}`);
194 }
195
196 async ensureLogin() {
197 if (!this.token) this.token = this.getCached().token || "";

Callers 2

ensureLoginMethod · 0.95
requestWithReloginMethod · 0.95

Calls 6

getWxCodeMethod · 0.95
saveCacheMethod · 0.95
apiRequestFunction · 0.85
assertOkFunction · 0.70
maskFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected