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