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

Method getWxCode

wxapp/feihe.js:174–194  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172 }
173
174 async getWxCode() {
175 const wxServerUrl = process.env.wx_server_url;
176 const wxAuth = process.env.wx_auth;
177 if (!wxServerUrl || !wxAuth) throw new Error("未配置 wx_server_url 或 wx_auth");
178
179 const { status, data } = await axios.post(
180 `${wxServerUrl.replace(/\/$/, "")}/wx/getuserinfo`,
181 { appid: MINI_APP_ID, openid: this.account },
182 {
183 headers: {
184 auth: wxAuth,
185 "content-type": "application/json",
186 },
187 timeout: 15000,
188 validateStatus: () => true,
189 }
190 );
191 const code = data?.code || data?.data?.code || data?.phoneCode || data?.data?.phoneCode;
192 if (status !== 200 || !code) throw new Error(`wx_server 获取code失败: HTTP ${status} ${JSON.stringify(data)}`);
193 return code;
194 }
195
196 async loginByCode() {
197 const code = await this.getWxCode();

Callers 1

loginByCodeMethod · 0.95

Calls 1

postMethod · 0.45

Tested by

no test coverage detected