import React, { Component } from "react"; import { Modal, Button, message } from "antd"; import { withRouter, RouteComponentProps } from "react-router-dom"; import { inject, observer } from "mobx-react"; import { IUserStore } from "@/models/user"; import { AccountStatus } from "@/api/service/AccountService"; import Api from "@/api"; import { HTTP_STATUS, ApplyStatus } from "@/shared/common/constants"; type P = RouteComponentProps & { userStore?: IUserStore; }; type S = { visible: boolean; tips: string; visibleApplyNotes: boolean; }; @inject("userStore") @observer class Welcome extends Component
{ state = { visibleApplyNotes: false, visible: false, tips: "" }; accountConfirmOk = () => { this.props.history.push("/apply"); }; accountConfirmSwitch = () => { Api.auth.logout().then(r => { if (HTTP_STATUS.SUCCESSS === r.ret) { sessionStorage.clear(); this.props.userStore.clear(); this.props.history.replace("/"); } else { message.error(r.msg); } }); }; toggleVisible = () => { const { visible } = this.state; this.setState({ visible: !visible }); }; toggleApplyNotes = () => { const { visibleApplyNotes } = this.state; this.setState({ visibleApplyNotes: !visibleApplyNotes }); }; apply = () => { const { accountInfo } = this.props.userStore; //未注册开发者账号 , 点击申请后直接进入申请页面 if (AccountStatus.NON_DEVELOPER === accountInfo.accountStatus) { this.props.history.push({ pathname: "/apply", state: { applyStatus: ApplyStatus.NON_DEVELOPER } }); } else if (AccountStatus.NON_CSP === accountInfo.accountStatus) { //已成为开发者账号,未入驻城市服务商 const companyName = accountInfo && accountInfo.extra ? accountInfo.extra.companyName : ""; this.setState({ visible: true, tips: `当前登录账号已绑定公司【${companyName}】,是否确认使用该公司信息申请成为服务商?` }); // this.props.history.push({ // pathname: "/apply", // state: { // applyStatus: ApplyStatus.NON_CSP // } // }); } else { } }; render() { const { visible, visibleApplyNotes, tips } = this.state; return ( <>
————欢迎申请成为喜马拉雅商户
{tips}