import BaseStore from './base';

const wwwAppId = '';
const h5AppId = '';

export default class WeChatStore extends BaseStore {
  initState() {
    return {};
  }

  wwwQrCode() {
    const url = encodeURIComponent(window.location.href);
    setTimeout(() => {
      const wx = new WxLogin({
        id: 'qrCode',
        appid: wwwAppId,
        scope: 'snsapi_login',
        redirect_uri: url,
      });
      return wx;
    }, 100);
  }

  wwwLogin() {}

  h5Auth() {
    const url = encodeURIComponent(window.location.href);
    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`;
  }

  h5Login() {}
}

export const User = new WeChatStore({ key: 'wx', local: true });
