| 173 | } |
| 174 | |
| 175 | headers(extra = {}, auth = true, isJson = false) { |
| 176 | const headers = { |
| 177 | "Connection": "keep-alive", |
| 178 | "envVersion": "release", |
| 179 | "Content-Type": isJson ? "application/json" : "application/x-www-form-urlencoded", |
| 180 | "uuid": this.uuid, |
| 181 | "Accept-Encoding": "gzip,compress,br,deflate", |
| 182 | "User-Agent": defaultUserAgent, |
| 183 | "Referer": `https://servicewechat.com/${MINI_APP_ID}/${PAGE_VERSION}/page-frame.html`, |
| 184 | ...extra, |
| 185 | }; |
| 186 | if (auth) { |
| 187 | headers.Authorization = this.token; |
| 188 | if (this.communityToken) headers["X-Haday-Token"] = this.communityToken; |
| 189 | } |
| 190 | return headers; |
| 191 | } |
| 192 | |
| 193 | async request(pathname, { method = "GET", params, data, auth = true, isJson = false, base = API_BASE } = {}) { |
| 194 | const options = { |