import React, {Component} from 'react'; import {Layout, Card, Button, Avatar, Spin, Icon, Row, Col, notification, Tag} from 'antd'; import lo from '../../../images/lo.png' import './index.css' import {graphqlUrl} from "../../../config"; import {SHOW_ALL_CASE, SHOW_CASE, SEARCH_SCHEMA} 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 {Content} = Layout; const {Meta} = Card; // caseshow 与 usercustom 展示于一个三目运算符 // 因此刷新 usercustom 将不存在,并且他没有路径 class CaseShow extends Component { constructor(props) { super(props); this.state = { examplesIoobot: [], examplesOthers: [], showCustom: false, chosenSchemaID: '' } } 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; // console.log(cases); let examplesIoobot = cases.filter(case1 => case1.user_id.id === 'ioobot'); let IooList = this.examplesFilter(examplesIoobot); let examplesOthers = cases.filter(case2 => case2.user_id.id !== 'ioobot'); let UserList = this.examplesFilter(examplesOthers); if (this._isMounted) { this.setState({ examplesIoobot: IooList, examplesOthers: UserList }) } } ) } examplesFilter(example) { // console.log('examples',example); let hash = {}, i = 0, list = []; example.forEach(function (item) { let {title} = item; hash[title] ? list[hash[title] - 1].content.push(item) : hash[title] = ++i && list.push({ title, content: [item], }); }); // console.log('list',list); return list; } componentWillUnmount() { this._isMounted = false; } schemaIDChangeBucket = async (schemaID) => { let bucketname = await request(graphqlUrl, SEARCH_SCHEMA, {id: schemaID}) console.log(bucketname.schema_by_id.schemaName, 'is schemaName,is equal to bucketName') return bucketname.schema_by_id.schemaName; }; backToMe = () => { this.setState({ showCustom: false }) }; showCustom = (item) => { this.setState({ showCustom: true, chosenSchemaID: item }) }; render() { let {userID, showCustom, chosenSchemaID} = this.state; return (
{ !showCustom ?

我们永久无年费      告别高成本

省钱、更省心

数据完全私有      安全更可靠

数据分析图表为您提供更细致的服务

模板不满意      快来定制化吧!

上手有困难,联系我们即可

{ this.state.examplesIoobot.length === 0 ? : this.state.examplesIoobot.map((item, index) => { let exampleList = item.content; let gzh = exampleList.filter(case1 => case1.description === '微信公众号'); let xcx = exampleList.filter(case1 => case1.description === '微信小程序'); let value = exampleList[0]; return (
{value.title}
模板简介:
{value.detailDescription ? value.detailDescription : '暂无简介'}

{value.detailAttention ?
适用行业:    {value.detailAttention}
: '' }

   { value.user_id.email ? value.user_id.email : '该作者未留下联系方式' }
   { value.codeAddress ? 查看源码 可自行修改使用 : '该作者未留下代码仓库地址' }
{gzh.length ? :
敬请期待
} {xcx.length ? :
敬请期待
}
) }) }
: }
) } } export default CaseShow; class CaseShowDetail extends Component { constructor(props) { super(props); this.state = {} } render() { let caseDetail = this.props.caseContent[0]; // console.log('caseDetail',caseDetail); return (
{ ({loading, error, data}) => { if (loading) { return } if (error) { return 'error!'; } let thisCase = data.case_by_id; return (
{caseDetail.description}
{caseDetail.title
微信扫一扫立即体验
) } }
) } }