| 135 | } |
| 136 | |
| 137 | async function qrcodeAuth(openid, uuid) { |
| 138 | const { data, status } = await axios.request({ |
| 139 | method: "POST", |
| 140 | url: `${WX_SERVER_URL}/wx/qrcodeauth`, |
| 141 | headers: { |
| 142 | auth: WX_AUTH, |
| 143 | "Content-Type": "application/json", |
| 144 | }, |
| 145 | data: { openid, uuid }, |
| 146 | timeout: 30000, |
| 147 | validateStatus: () => true, |
| 148 | }); |
| 149 | if (status !== 200) throw new Error(`/wx/qrcodeauth HTTP ${status}: ${JSON.stringify(data)}`); |
| 150 | const code = |
| 151 | data?.code || |
| 152 | data?.wxCode || |
| 153 | data?.data?.code || |
| 154 | data?.data?.wxCode || |
| 155 | data?.data?.data?.code || |
| 156 | data?.data?.data?.wxCode; |
| 157 | if (!code) throw new Error(`/wx/qrcodeauth 未返回 code: ${JSON.stringify(data)}`); |
| 158 | return code; |
| 159 | } |
| 160 | |
| 161 | async function loginByCode(authCode, guid) { |
| 162 | const { data } = await axios.request({ |