const { inject, observer } = mobxReact; const ProductItem = ecodeSDK.imp(ProductItem); const ProductDialog = ecodeSDK.imp(ProductDialog); const { toJS } = mobx; // const { product } = ecodeSDK.imp(productDataSource); const { WeaDialog } = ecCom; const { createRef } = React; @inject("projectStore") @observer class ProductIndex extends React.Component { constructor() { super(); this.state = { dialogParams: { visible: false, productId: "", }, dialogWidth: 1200, dialogHeight: 100, }; this.productRef = createRef(); } componentDidMount() { window.addEventListener("resize", this.resizeWidthHeight); this.resizeWidthHeight(); this.init(); } conponentWillUnmount() { window.removeEventListener("resize", this.resizeWidthHeight); } resizeWidthHeight = () => { requestAnimationFrame(() => { if (!this.productRef.current) { return; } const { offsetWidth, offsetHeight } = this.productRef.current; this.setState({ dialogWidth: offsetWidth - 100, // offsetHeight / 2 dialogHeight: 80, }); }); }; init = () => { const { projectStore: { init }, } = this.props; init(); }; handlePickProduct = async (productId) => { const { projectStore: { viewProject, init }, } = this.props; const { api_status } = await viewProject(productId); if (api_status) init(); this.setState({ dialogParams: { ...this.state.dialogParams, visible: true, productId }, }); }; render() { const { dialogParams, dialogHeight, dialogWidth } = this.state; const { projectStore: { product }, } = this.props; return (
{subTitle}
*/}