wechat.js 801 B

12345678910111213141516171819202122232425262728293031323334
  1. import BaseStore from './base';
  2. const wwwAppId = '';
  3. const h5AppId = '';
  4. export default class WeChatStore extends BaseStore {
  5. initState() {
  6. return {};
  7. }
  8. wwwQrCode() {
  9. const url = encodeURIComponent(window.location.href);
  10. setTimeout(() => {
  11. const wx = new WxLogin({
  12. id: 'qrCode',
  13. appid: wwwAppId,
  14. scope: 'snsapi_login',
  15. redirect_uri: url,
  16. });
  17. return wx;
  18. }, 100);
  19. }
  20. wwwLogin() {}
  21. h5Auth() {
  22. const url = encodeURIComponent(window.location.href);
  23. window.location = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${h5AppId}&redirect_uri=${url}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
  24. }
  25. h5Login() {}
  26. }
  27. export const User = new WeChatStore({ key: 'wx', local: true });