(force = false)
| 156 | }; |
| 157 | } |
| 158 | async getLoginCode(force = false) { |
| 159 | if (this.loginCode && !force) return this.loginCode; |
| 160 | const { data: codeRes } = await wechat.getCode(this.wcsid); |
| 161 | const code = codeRes?.code || codeRes?.data?.code; |
| 162 | if (!code) throw new Error(`wx_server 未返回 code: ${JSON.stringify(codeRes)}`); |
| 163 | this.loginCode = code; |
| 164 | return this.loginCode; |
| 165 | } |
| 166 | async getOpenId() { |
| 167 | try { |
| 168 | let options = { |