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

Method getWxCode

wxapp/aiguoyue.js:177–197  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

loginByWxCodeMethod · 0.95

Calls 1

postMethod · 0.45

Tested by

no test coverage detected