| 114 | } |
| 115 | |
| 116 | async function getWxCode(openid) { |
| 117 | if (!WX_AUTH) throw new Error("未配置 wx_auth,无法从 wx_server 获取 code"); |
| 118 | const { status, data } = await request({ |
| 119 | method: "POST", |
| 120 | url: `${WX_SERVER_URL}/wx/code`, |
| 121 | headers: { auth: WX_AUTH }, |
| 122 | data: { appid: MINI_APP_ID, openid }, |
| 123 | }); |
| 124 | const code = data?.data?.code || data?.code; |
| 125 | if (status !== 200 || !code) throw new Error(`获取 code 失败 HTTP ${status}: ${short(data)}`); |
| 126 | return code; |
| 127 | } |
| 128 | |
| 129 | class Skyworth { |
| 130 | constructor(rawAccount, index) { |