MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / loginByWxCode

Method loginByWxCode

wxapp/wb.js:215–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

213 }
214
215 async loginByWxCode() {
216 try {
217 const code = await this.getLoginCode();
218 const wxLogin = await this.request("marketing/v1/wechat-user-auth/miniapp-login", {
219 authorizerAppid: MINI_APP_ID,
220 jsCode: code,
221 }, "GET");
222 this.appOpenid = wxLogin.data?.openid || "";
223 const login = await this.request("marketing/v1/customer-login/wechat-openid", {
224 serviceSign: wxLogin.data?.serviceSign,
225 openid: this.appOpenid,
226 appId: MINI_APP_ID,
227 appType: 2,
228 }, "POST");
229 this.applyToken({
230 token: login.data?.token,
231 appOpenid: this.appOpenid,
232 userId: login.data?.id,
233 userType: login.data?.userType,
234 mobile: login.data?.mobile || "",
235 });
236 this.saveCachedToken();
237 $.log(`账号[${this.index}] 登录成功: userId=${this.userId || "未知"}`);
238 } catch (e) {
239 $.log(`账号[${this.index}] 登录失败: ${e.message || e}`);
240 }
241 }
242
243 async checkToken() {
244 try {

Callers 1

runMethod · 0.95

Calls 5

getLoginCodeMethod · 0.95
requestMethod · 0.95
applyTokenMethod · 0.95
saveCachedTokenMethod · 0.95
logMethod · 0.45

Tested by

no test coverage detected