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

Method getWxCode

wxapp/lvbizi.js:176–196  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

loginByWxCodeMethod · 0.95

Calls 1

postMethod · 0.45

Tested by

no test coverage detected