| 211 | } |
| 212 | |
| 213 | async getOperateData() { |
| 214 | if (!process.env.wx_auth) throw new Error("缺少 wx_auth,无法从 wx_server 获取登录数据"); |
| 215 | const url = (process.env.wx_server_url || "http://192.168.31.196:8787").replace(/\/$/, ""); |
| 216 | const { data } = await axios.post(`${url}/wx/getuserinfo`, { |
| 217 | appid: MINI_APP_ID, |
| 218 | openid: this.accountId, |
| 219 | }, { |
| 220 | headers: { auth: process.env.wx_auth }, |
| 221 | timeout: 45000, |
| 222 | validateStatus: () => true, |
| 223 | }); |
| 224 | const result = data?.data || {}; |
| 225 | if (!data?.status || !result.code || !result.encryptedData || !result.iv) { |
| 226 | throw new Error(`wx_server 未返回完整登录数据: ${JSON.stringify(data)}`); |
| 227 | } |
| 228 | return result; |
| 229 | } |
| 230 | |
| 231 | async getArticleIds() { |
| 232 | try { |