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

Method getWxCode

wxapp/mengxiangjia.js:156–176  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

154 }
155
156 async getWxCode() {
157 const wxServerUrl = process.env.wx_server_url;
158 const wxAuth = process.env.wx_auth;
159 if (!wxServerUrl || !wxAuth) throw new Error("未配置 wx_server_url 或 wx_auth");
160
161 const { status, data } = await axios.post(
162 `${wxServerUrl.replace(/\/$/, "")}/wx/getuserinfo`,
163 { appid: MINI_APP_ID, openid: this.openid },
164 {
165 headers: {
166 auth: wxAuth,
167 "content-type": "application/json",
168 },
169 timeout: 15000,
170 validateStatus: () => true,
171 }
172 );
173 const code = data?.code || data?.data?.code;
174 if (status !== 200 || !code) throw new Error(`wx_server 获取code失败: HTTP ${status} ${JSON.stringify(data)}`);
175 return code;
176 }
177
178 async loginByWxCode() {
179 try {

Callers 1

loginByWxCodeMethod · 0.95

Calls 1

postMethod · 0.45

Tested by

no test coverage detected