| 163 | } |
| 164 | |
| 165 | async function h5Api(pathname, data, account) { |
| 166 | const cookies = []; |
| 167 | if (account.ticket) cookies.push(`cticket=${account.ticket}`); |
| 168 | if (account.duid) cookies.push(`DUID=${encodeURIComponent(account.duid)}`); |
| 169 | if (account.udl) cookies.push(`_udl=${account.udl}`); |
| 170 | cookies.push(`GUID=${CLIENT_ID}`); |
| 171 | const res = await axios.post(`${API_BASE}${pathname}`, JSON.stringify(data || {}), { |
| 172 | timeout: 30000, |
| 173 | validateStatus: () => true, |
| 174 | headers: { |
| 175 | "Content-Type": "application/json", |
| 176 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 MicroMessenger/3.9.12 MiniProgramEnv/Windows WindowsWechat/WMPF", |
| 177 | Referer: "https://m.ctrip.com/", |
| 178 | Cookie: `${cookies.join("; ")};`, |
| 179 | }, |
| 180 | }); |
| 181 | return { |
| 182 | status: res.status, |
| 183 | data: res.data, |
| 184 | text: typeof res.data === "string" ? res.data : JSON.stringify(res.data), |
| 185 | }; |
| 186 | } |
| 187 | |
| 188 | class Task { |
| 189 | constructor(raw) { |