(apiPath, data = {}, token = this.session.token)
| 130 | } |
| 131 | |
| 132 | async request(apiPath, data = {}, token = this.session.token) { |
| 133 | const res = await axios.post(`${API_BASE}${apiPath}`, data || {}, { |
| 134 | headers: this.getHeaders(token), |
| 135 | timeout: 20000, |
| 136 | validateStatus: () => true, |
| 137 | }); |
| 138 | if (res.status !== 200) throw new Error(`HTTP ${res.status}`); |
| 139 | if (Number(res.data?.code) !== 200) { |
| 140 | const error = new Error(res.data?.msg || `接口错误: ${res.data?.code || "unknown"}`); |
| 141 | error.data = res.data; |
| 142 | throw error; |
| 143 | } |
| 144 | return res.data; |
| 145 | } |
| 146 | |
| 147 | async getLoginCode() { |
| 148 | const { data } = await wechat.getCode(this.openid); |
no test coverage detected