| 79 | } |
| 80 | |
| 81 | async function getWxCode(openid) { |
| 82 | if (!WX_AUTH) throw new Error("未配置 wx_auth,无法从 wx_server 获取 code"); |
| 83 | const { status, data } = await request({ |
| 84 | method: "POST", |
| 85 | url: `${WX_SERVER_URL}/wx/code`, |
| 86 | headers: { auth: WX_AUTH }, |
| 87 | data: { appid: APP.appid, openid }, |
| 88 | }); |
| 89 | const code = data?.data?.code || data?.code; |
| 90 | if (status !== 200 || !code) throw new Error(`获取 code 失败 HTTP ${status}: ${short(data)}`); |
| 91 | return code; |
| 92 | } |
| 93 | |
| 94 | class YouDianYunChuang { |
| 95 | constructor(rawAccount, index) { |