()
| 211 | } |
| 212 | |
| 213 | async getWxCode() { |
| 214 | if (!this.openid) throw new Error("缺少 openid,无法自动登录"); |
| 215 | const { data } = await wechat.getCode(this.openid); |
| 216 | if (!data?.status) throw new Error(data?.message || "wx_server 获取 code 失败"); |
| 217 | const code = data.data?.code || data.code; |
| 218 | if (!code) throw new Error(`wx_server 未返回 code: ${JSON.stringify(data)}`); |
| 219 | return code; |
| 220 | } |
| 221 | |
| 222 | async login() { |
| 223 | const code = await this.getWxCode(); |