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

Method loginByWxCode

wxapp/sinsin.js:192–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

190 }
191
192 async loginByWxCode() {
193 try {
194 const code = await this.getWxCode();
195 const { status, data } = await axios.post(
196 `${UIC_BASE}/passport/general/auth.json`,
197 {
198 appId: MINI_APP_ID,
199 code,
200 platformName: "weapp",
201 signature: "Windows",
202 },
203 {
204 headers: {
205 "Content-Type": "application/json",
206 "User-Agent": USER_AGENT,
207 "Referer": `https://servicewechat.com/${MINI_APP_ID}/54/page-frame.html`,
208 "X-Requested-With": "XMLHttpRequest",
209 },
210 timeout: 15000,
211 validateStatus: () => true,
212 }
213 );
214 if (status !== 200 || data?.code !== 0 || !data?.data?.sessionId) {
215 throw new Error(`UIC登录失败: HTTP ${status} ${typeof data === "string" ? data.slice(0, 200) : JSON.stringify(data)}`);
216 }
217 this.token = data.data || {};
218 this.saveCachedToken();
219 $.log(`账号[${this.index}] 登录成功: ${data.data?.nickName || data.data?.nickname || ""} ${maskPhone(data.data?.mobile)}`);
220 } catch (e) {
221 $.log(`账号[${this.index}] 登录失败: ${e.message || e}`);
222 }
223 }
224
225 async checkToken() {
226 try {

Callers 1

runMethod · 0.95

Calls 5

getWxCodeMethod · 0.95
saveCachedTokenMethod · 0.95
maskPhoneFunction · 0.70
postMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected