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

Method loginByWxCode

wxapp/aiguoyue.js:199–220  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

197 }
198
199 async loginByWxCode() {
200 try {
201 const code = await this.getWxCode();
202 const data = await this.request({
203 method: "POST",
204 apiPath: "wscshop/weapp/authorize.json",
205 skipToken: true,
206 data: {
207 appId: MINI_APP_ID,
208 clientId: CLIENT_ID,
209 clientSecret: CLIENT_SECRET,
210 grantType: GRANT_TYPE,
211 code,
212 },
213 });
214 this.token = data || {};
215 this.saveCachedToken();
216 $.log(`账号[${this.index}] 登录成功: ${data?.nick_name || data?.nickName || ""} ${maskPhone(data?.mobile)}`);
217 } catch (e) {
218 $.log(`账号[${this.index}] 登录失败: ${e.message || e}`);
219 }
220 }
221
222 async checkToken() {
223 try {

Callers 1

runMethod · 0.95

Calls 5

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

Tested by

no test coverage detected