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