import React, {Component} from 'react'; import {Layout, Card, Button, Avatar, Spin, Icon, Row, Col, notification, Tabs, Select} from 'antd'; import lo from '../../../images/lo.png' import './index.css' import {graphqlUrl} from "../../../config"; import {SHOW_ALL_CASE, SHOW_CASE} from "../../../gql"; import {FormattedMessage} from 'react-intl'; import {request} from 'graphql-request' import UserCustom from "./UserCustom"; import {Query} from "react-apollo"; import gql from "graphql-tag"; import {getCookie} from "../../../cookie"; const TabPane = Tabs.TabPane; const {Content} = Layout; const {Meta} = Card; class CaseShow extends Component { constructor(props) { super(props); this.state = { examplesMP: [], examplesPublic: [], examplesH5: [], showCustom: false, chosenSchemaID: '', activeKey: '1', showCaseID: 'order-react-CaseID' } } componentWillMount() { this._isMounted = true; // 查询是否登录 let userID = getCookie('user_id'); if (userID !== undefined && userID !== '') { this.setState({ userID }); } request(graphqlUrl, SHOW_ALL_CASE, {}).then(data => { let cases = data.case_by_props; let examplesMP = cases.filter(case1 => case1.description === '小程序'); let examplesPublic = cases.filter(case2 => case2.description === '公众号'); let examplesH5 = cases.filter(case2 => case2.description === 'H5'); if (this._isMounted) { this.setState({ examplesMP, examplesPublic, examplesH5 }) } } ) } componentWillUnmount() { this._isMounted = false; } schemaIDChangeBucket = (schemaID) => { if (this.props.location && this.props.location.state) { switch (schemaID) { case 'order_schemaID': return 'appointment'; case 'ecommerce_schemaID': return 'e-commerce'; case 'bills_schemaID': return 'bills'; default: break; } } }; backToMe = () => { this.setState({ showCustom: false }) }; render() { let {userID, showCustom, chosenSchemaID, activeKey, showCaseID} = this.state; const tabStyle = { paddingTop: '50px', paddingBottom: '50px', height: '550px', display: 'inline-block', }; return (
{ !showCustom ?
{ ({loading, error, data}) => { if (loading) { return } if (error) { return 'error!'; } let thisCase = data.case_by_id; return (
{thisCase.title}
{thisCase.detailDescription ? thisCase.detailDescription : '暂无简介'}
) } }
{ this.state.examplesMP.map((item, index) => (
{ this.setState({ showCaseID: item.id }) }} > {item.title
{item.title}
)) }
这个地方是截图,可以放在 detailImage 里面
{/*下面这串代码仅供参考,可以整体删除*/} { this.state.examplesMP.map((item, index) => ( { ({loading, error, data}) => { if (loading) { return } if (error) { return 'error!'; } let thisCase = data.case_by_id; return (
{thisCase.detailAttention ?
{thisCase.detailAttention}
: '' }
{thisCase.detailDescription ? thisCase.detailDescription : '暂无简介'}
) } }
想要定制化该案例
联系作者
{ item.user_id.email ? item.user_id.email : '该作者未留下联系方式' }
自行修改代码
{ item.codeAddress ? item.codeAddress : '该作者未留下代码仓库地址' }
{item.title
} actions={[ 已部署: {item.deployedNum}, : {item.like}, ]} > } title={item.title} description={item.description} />
)) }
{ this.setState({activeKey: '2'}) }} tab="小程序" key="2">Content of Tab 2 { this.setState({activeKey: '3'}) }} tab="H5 网页" key="3">Content of Tab 3
: } ) } } export default CaseShow;