| 95 | } |
| 96 | |
| 97 | async function getWxCode(openid) { |
| 98 | if (!WX_AUTH) throw new Error("未配置 wx_auth,无法从 wx_server 获取 code"); |
| 99 | const { status, data } = await request({ |
| 100 | method: "POST", |
| 101 | url: `${WX_SERVER_URL}/wx/code`, |
| 102 | headers: { auth: WX_AUTH, "content-type": "application/json" }, |
| 103 | data: { appid: APP.appid, openid }, |
| 104 | }); |
| 105 | const code = data?.data?.code || data?.code; |
| 106 | if (status !== 200 || !code) throw new Error(`获取code失败 HTTP ${status}: ${short(data)}`); |
| 107 | return code; |
| 108 | } |
| 109 | |
| 110 | class ZtoExpress { |
| 111 | constructor(account, index) { |