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

Method loginByWxCode

wxapp/hrj.js:204–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

202 }
203
204 async loginByWxCode() {
205 try {
206 const code = await this.getLoginCode();
207 const loginBody = {
208 appid: MINI_APP_ID,
209 basicInfo: { ...FORM_BASIC_INFO },
210 env: "production",
211 extendInfo: { ...EXTEND_INFO },
212 is_pre_fetch_open: true,
213 parentVid: 0,
214 pid: "",
215 storeId: "",
216 code,
217 queryAuthConfig: true,
218 };
219 delete loginBody.basicInfo.productInstanceId;
220
221 const res = await axios.post(`${API_HOST}/fe/mapi/user/loginX`, loginBody, {
222 headers: {
223 "Content-Type": "application/json",
224 "User-Agent": USER_AGENT,
225 "Referer": `https://servicewechat.com/${MINI_APP_ID}/${PAGE_VERSION}/page-frame.html`,
226 "weimob-bosId": FORM_BASIC_INFO.bosId,
227 "weimob-cid": FORM_BASIC_INFO.cid,
228 },
229 timeout: 20000,
230 validateStatus: () => true,
231 });
232 if (res.status !== 200 || Number(res.data?.errcode) !== 0) {
233 throw new Error(res.data?.errmsg || res.data?.errormsg || `HTTP ${res.status}`);
234 }
235 this.session = res.data.data || {};
236 this.saveCachedToken();
237 $.log(`账号[${this.index}] 登录成功: wid ${this.session.wid || ""}`);
238 } catch (e) {
239 $.log(`账号[${this.index}] 登录失败: ${e.message || e}`);
240 }
241 }
242
243 async checkToken() {
244 try {

Callers 1

runMethod · 0.95

Calls 4

getLoginCodeMethod · 0.95
saveCachedTokenMethod · 0.95
postMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected