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

Method login

wxapp/oppo.js:199–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

197 }
198
199 async login() {
200 if (!this.account.openid) throw new Error("账号格式错误,请配置 wx_server 里的 openid");
201 const code = await getWxCode(this.account.openid);
202 const { status, data } = await request({
203 method: "POST",
204 url: `${MINI_API}/user/pre/auth`,
205 headers: {
206 "content-type": "application/json",
207 Referer: `https://servicewechat.com/${APP.appid}/${APP.version}/page-frame.html`,
208 },
209 data: { code },
210 });
211 if (status !== 200 || String(data?.ret) !== "1") throw new Error(`登录失败 HTTP ${status}: ${short(data)}`);
212 const info = data.data || {};
213 this.sessionId = info.sessionId || "";
214 this.encryptedSession = info.encryptedSession || "";
215 this.openId = info.openId || "";
216 if (!this.sessionId) throw new Error(`登录响应缺少 sessionId: ${short(data)}`);
217 this.log(`登录成功 openId=${this.openId || "未知"}`);
218 }
219
220 async queryMember() {
221 const member = await this.miniRequest("GET", "/member/info", { sessionId: this.sessionId });

Callers 1

runMethod · 0.95

Calls 4

logMethod · 0.95
getWxCodeFunction · 0.70
requestFunction · 0.70
shortFunction · 0.70

Tested by

no test coverage detected