获取微信用户信息
1. 重定向到 https://m.qxwz.com/bffportal/thirdparty/weixin/mp/auth?scope=snsapi_base&authType=qxwz&redirectUrl=https://hd.qxwz.com/wx-user
- redirectUrl 改成当前 window.location.href (比如 https://hd.qxwz.com/wx-user )
2. 自动重定向回来后,地址变成了 https://hd.qxwz.com/wx-user?userKey=31ee4d84-d2ae-485b-8fe3-37f57720b592&state=1592969366473
3. 通过 ajax 调用:/bffportal/thirdparty/weixin/mp/user?key=31ee4d84-d2ae-485b-8fe3-37f57720b592&state=1592969366473
- 建议配置当前域名下 /bffportal 的 location 转发,避免跨域问题
- state: 来自 url query 中的参数 state(用于和 cookie 中的 ostate 进行校验)
- key: 来自 url query 中的参数 userKey(用于去 redis 里面查找对应的微信用户信息)
- Demo: https://hd.qxwz.com/wx-user
4. 本地调试的时候
- vite 启动当前项目(venus-page/wx-user)
- 修改 bff-portal/src/modules/thirdparty/services/weixin.service.ts 中的 redirectUrl 和 mpRedirectUrl 的 https 为 http
- 绑定 host 为 127.0.0.1 m.qxwz.com
- 微信开发者工具访问: http://m.qxwz.com