| 98 | } |
| 99 | |
| 100 | async function request(options) { |
| 101 | const res = await axios.request({ |
| 102 | timeout: 25000, |
| 103 | validateStatus: () => true, |
| 104 | ...options, |
| 105 | headers: { |
| 106 | "User-Agent": "Mozilla/5.0 MicroMessenger MiniProgramEnv/Windows", |
| 107 | Accept: "application/json, text/plain, */*", |
| 108 | "content-type": "application/json", |
| 109 | Referer: `https://servicewechat.com/${MINI_APP_ID}/${PACKAGE_VERSION}/page-frame.html`, |
| 110 | ...(options.headers || {}), |
| 111 | }, |
| 112 | }); |
| 113 | return { status: res.status, data: res.data, headers: res.headers || {} }; |
| 114 | } |
| 115 | |
| 116 | async function getWxCode(openid) { |
| 117 | if (!WX_AUTH) throw new Error("未配置 wx_auth,无法从 wx_server 获取 code"); |