import { Select, message, Modal } from "antd"; import { connect } from "dva/index"; import router from "umi/router"; import { Component } from "react"; import { businessStateEnum } from "@/utils/utils"; import styles from "./index.less"; @connect(({ store }) => ({ store, })) export default class BusinessStateSelector extends Component { constructor(props) { super(props); this.state = { stateList: Object.keys(businessStateEnum).map((key) => ({ name: businessStateEnum[key], value: Number(key), })), currentBusinessState: "", visible: false, }; } handleChange = (value) => { const { dispatch } = this.props; dispatch({ type: "store/update_business_state", payload: { businessState: value, }, callback: (res) => { if (res.state === 200) { if (res.data) { this.setState({ visible: true }); } else { message.success("设置成功"); this.setState({ currentBusinessState: value }); } } else { message.error(res.msg); } }, }); }; componentDidMount() { const { dispatch } = this.props; dispatch({ type: "store/get_business_state", callback: (res) => { if (res.state === 200) { this.setState({ currentBusinessState: res.data }); } else { this.setState({ currentBusinessState: 2 }); message.error(res.msg); } }, }); } confirmModal = () => { if (this.props.confirmModal) { this.props.confirmModal(); } else { router.push({ pathname: "/store/decorate_pc", query: { tab: "2", }, }); } this.setState({ visible: false }); }; cancelModel = () => { this.setState({ visible: false }); }; render() { const { stateList, currentBusinessState, visible } = this.state; return stateList.length ? (
经营状态
请先在【店铺装修-首页装修】内,装修首页并将“启用状态”更改为“启用”
) : null; } }