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

Method loginByWxCode

wxapp/zbs.js:174–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172 }
173
174 async loginByWxCode() {
175 try {
176 const code = await this.getLoginCode();
177 const result = await this.request("auth/login_by_weixin", {
178 method: "POST",
179 auth: false,
180 data: {
181 code,
182 userInfo: {},
183 shareUserId: 1,
184 },
185 });
186 const token = result?.data?.token || "";
187 if (!token) throw new Error(`登录响应未返回token: ${JSON.stringify(result)}`);
188 this.token = token;
189 this.userInfo = result?.data?.userInfo || {};
190 this.saveCachedToken();
191 $.log(`账号[${this.index}] 登录成功: ${this.userInfo.nickname || maskPhone(this.userInfo.mobile) || this.userId}`);
192 } catch (e) {
193 $.log(`账号[${this.index}] 登录失败: ${e.message || e}`);
194 }
195 }
196
197 async checkToken() {
198 try {

Callers 1

runMethod · 0.95

Calls 5

getLoginCodeMethod · 0.95
requestMethod · 0.95
saveCachedTokenMethod · 0.95
maskPhoneFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected