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

Method loginByWxCode

wxapp/mxbc.js:194–226  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

192 }
193 }
194 async loginByWxCode() {
195 try {
196 const ok = await this.getOpenId();
197 if (!ok) return;
198 let options = {
199 method: 'POST',
200 url: `${API_BASE}/v1/app/regByUnionid`,
201 headers: this.getMiniHeaders(),
202 data: this.getSignedBody({
203 code: this.loginCode,
204 openId: this.openId,
205 unionid: this.unionId,
206 third: "wxmini",
207 miniAppId: MINI_APP_ID
208 })
209 };
210 let { data: result } = await axios.request(options);
211 if (result.code == 0) {
212 this.ck = result.data.accessToken;
213 this.ckStatus = !!this.ck;
214 this.mobilePhone = result.data.mobilePhone;
215 this.saveCachedToken();
216 $.log(`账号[${this.index}] 登录成功: [${maskPhone(this.mobilePhone) || "未绑定手机号"}]`);
217 } else {
218 $.log(`账号[${this.index}] 登录失败❌ ${result.msg || ""}`);
219 this.ckStatus = false;
220 console.log(result);
221 }
222 } catch (e) {
223 $.log(`账号[${this.index}] 登录异常❌ ${e.response?.data?.msg || e.message || e}`);
224 this.ckStatus = false;
225 }
226 }
227 async user_info() {
228 let time = Date.now()
229 try {

Callers 1

runMethod · 0.95

Calls 7

getOpenIdMethod · 0.95
getMiniHeadersMethod · 0.95
getSignedBodyMethod · 0.95
saveCachedTokenMethod · 0.95
maskPhoneFunction · 0.70
requestMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected