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

Method login

wxapp/ztkd.js:145–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

143 }
144
145 async login() {
146 if (this.token) {
147 $.log(`账号[${this.index}] 使用变量token: ${maskToken(this.token)}`);
148 return;
149 }
150 if (!this.account.openid) throw new Error("未配置 openid 或 token");
151
152 const code = await getWxCode(this.account.openid);
153 const res = await this.api(MAIN_HOST, "auth_wechatMini_authByCode", { code }, true);
154 const data = res.result || res.data || {};
155 if (!data.token) throw new Error(`登录失败: ${short(res)}`);
156
157 this.token = data.token;
158 this.openId = data.openId || this.openId;
159 this.user = data;
160 $.log(
161 `登录:成功 userId=${data.userId || "未知"} 手机=${maskPhone(data.mobile || "") || "未知"} openId=${data.openId || "未知"}`
162 );
163 }
164
165 async queryPoints() {
166 const res = await this.api(MEMBER_HOST, "member/getMemberPoints", {}, true);

Callers 1

runMethod · 0.95

Calls 6

apiMethod · 0.95
maskTokenFunction · 0.70
getWxCodeFunction · 0.70
shortFunction · 0.70
maskPhoneFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected