123456789101112131415161718192021222324252627282930313233 |
- import React from 'react';
- import './index.less';
- import Page from '@src/containers/Page';
- import { WechatH5AppId } from '../../../../Constant';
- import { User } from '../../../stores/user';
- export default class extends Page {
- init() {
- const { code, url } = this.props.core.query;
- if (code) {
- User.loginWechat(code).then(info => {
- if (info.bindMobile) {
- if (url) {
- toLink(url);
- } else {
- replaceLink('/');
- }
- } else {
- replaceLink(`/bind?url=${url}`);
- }
- });
- } else {
- const authUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${WechatH5AppId}&redirect_uri=${encodeURIComponent(
- `${window.location.href}`,
- )}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`;
- window.location.href = authUrl;
- }
- }
- renderView() {
- return <div />;
- }
- }
|