(apiPath, data = {})
| 180 | } |
| 181 | |
| 182 | async request(apiPath, data = {}) { |
| 183 | const res = await axios.post(`${API_BASE}${apiPath}`, this.buildWosBody(data), { |
| 184 | headers: this.getHeaders(), |
| 185 | timeout: 20000, |
| 186 | validateStatus: () => true, |
| 187 | }); |
| 188 | if (res.status !== 200) throw new Error(`HTTP ${res.status}`); |
| 189 | if (`${res.data?.errcode}` !== "0") { |
| 190 | const error = new Error(res.data?.errmsg || `接口错误: ${res.data?.errcode || "unknown"}`); |
| 191 | error.data = res.data; |
| 192 | throw error; |
| 193 | } |
| 194 | return res.data?.data; |
| 195 | } |
| 196 | |
| 197 | async getLoginCode() { |
| 198 | const { data } = await wechat.getCode(this.openid); |
no test coverage detected