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

Method miniLogin

wxapp/txdt.js:202–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

200 }
201
202 async miniLogin() {
203 if (!this.account.openid) throw new Error("账号格式错误,请配置 wx_server 里的 openid");
204 const code = await getWxCode(this.account.openid);
205 const body = {
206 seqid: uuid(),
207 app_id: APP.appid,
208 auth_code: code,
209 devHeader: {},
210 };
211 const { status, data } = await request({
212 method: "POST",
213 url: `${MINI_LOGIN_BASE}/minLogin/v2/login`,
214 headers: {
215 "content-type": "application/json",
216 ...loginSign({ appId: APP.appid, postBody: body }),
217 },
218 data: body,
219 });
220 if (status !== 200 || Number(data?.err_code) !== 0) throw new Error(`登录失败 HTTP ${status}: ${short(data)}`);
221 this.loginInfo = { ...data, appId: APP.appid };
222 $.log(`登录:成功 userId=${data.user_id || "未知"},openid=${data.openid || "未知"}`);
223 }
224
225 async queryUser() {
226 const user = this.loginInfo;

Callers 1

runMethod · 0.95

Calls 6

loginSignFunction · 0.85
getWxCodeFunction · 0.70
uuidFunction · 0.70
requestFunction · 0.70
shortFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected