(method, path, data = {})
| 181 | } |
| 182 | |
| 183 | async h5Request(method, path, data = {}) { |
| 184 | const upperMethod = method.toUpperCase(); |
| 185 | const { status, data: result } = await request({ |
| 186 | method: upperMethod, |
| 187 | url: `${H5_API}${path}`, |
| 188 | headers: this.h5Headers(), |
| 189 | params: upperMethod === "GET" ? data : undefined, |
| 190 | data: upperMethod === "GET" ? undefined : data, |
| 191 | }); |
| 192 | if (status !== 200) throw new Error(`${path} HTTP ${status}: ${short(result)}`); |
| 193 | if (Number(result?.code) !== 200 && result?.succeed !== true) { |
| 194 | throw new Error(`${path} 失败: ${result?.message || result?.errorMessage || short(result)}`); |
| 195 | } |
| 196 | return result; |
| 197 | } |
| 198 | |
| 199 | async login() { |
| 200 | if (!this.account.openid) throw new Error("账号格式错误,请配置 wx_server 里的 openid"); |
no test coverage detected