import React from 'react';
import './index.less';
import Page from '@src/containers/Page';
import { User } from '../../../stores/user';

export default class extends Page {
  init() {
    const { code } = this.props.core.query;
    if (code) {
      User.loginWechat(code).then(() => {
        replaceLink('/');
      });
    } else {
      const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=1&redirect_uri=${encodeURIComponent(
        '/login',
      )}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
      window.location.href = url;
    }
  }

  renderView() {
    return <div />;
  }
}
