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

Method loginByCode

wxapp/yichengtong.js:208–227  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

206 }
207
208 async loginByCode() {
209 const code = await this.getWxCode();
210 const session = await request("post", "/client/web/wechatSession", {
211 params: { code },
212 data: {},
213 });
214 if (session.status !== 200 || !ok(session.data)) {
215 throw new Error(`wechatSession失败[${session.status}]: ${session.text.slice(0, 500)}`);
216 }
217 const data = session.data.data || {};
218 this.wxInfo = data.wxInfo || {};
219 this.userInfo = data.userInfo || {};
220 if (this.wxInfo.openid && !this.openid) this.openid = this.wxInfo.openid;
221 const token = this.userInfo.token || data.token || "";
222 if (!token) return false;
223 this.token = token;
224 this.saveCache({ loginType: "wechatSession" });
225 $.log(`账号[${this.index}] code登录成功: ${mask(this.userInfo.userId || this.token)}`);
226 return true;
227 }
228
229 async loginByOperateData() {
230 const op = await this.getOperateData();

Callers 1

ensureLoginMethod · 0.95

Calls 6

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

Tested by

no test coverage detected