CaseShowBackup.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import React, {Component} from 'react';
  2. import {Layout, Butt, Spin, Row, Col, Tabs} from 'antd';
  3. import './index.css'
  4. import {graphqlUrl} from "../../../config";
  5. import {SHOW_ALL_CASE} from "../../../gql";
  6. import {FormattedMessage} from 'react-intl';
  7. import {request} from 'graphql-request'
  8. import UserCustom from "./UserCustom";
  9. import {getCookie} from "../../../cookie";
  10. const TabPane = Tabs.TabPane;
  11. const {Content} = Layout;
  12. class CaseShow extends Component {
  13. constructor(props) {
  14. super(props);
  15. this.state = {
  16. examplesFirst: [],
  17. examplesSecond: [],
  18. showCustom: false,
  19. chosenSchemaID: '',
  20. activeKey: '1',
  21. showCaseID: 'order-react-CaseID'
  22. }
  23. }
  24. componentWillMount() {
  25. this._isMounted = true;
  26. // 查询是否登录
  27. let userID = getCookie('user_id');
  28. if (userID !== undefined && userID !== '') {
  29. this.setState({
  30. userID
  31. });
  32. }
  33. request(graphqlUrl, SHOW_ALL_CASE, {}).then(data => {
  34. let cases = data.case_by_props;
  35. let examplesFirst = cases.filter(case1 => case1.title.includes('预约'));
  36. let examplesSecond = cases.filter(case2 => case2.title.includes('服装店'));
  37. if (this._isMounted) {
  38. this.setState({
  39. examplesFirst,
  40. examplesSecond,
  41. })
  42. }
  43. }
  44. )
  45. }
  46. componentWillUnmount() {
  47. this._isMounted = false;
  48. }
  49. schemaIDChangeBucket = (schemaID) => {
  50. if (this.props.location && this.props.location.state) {
  51. switch (schemaID) {
  52. case 'order_schemaID':
  53. return 'appointment';
  54. case 'ecommerce_schemaID':
  55. return 'e-commerce';
  56. case 'bills_schemaID':
  57. return 'bills';
  58. default:
  59. break;
  60. }
  61. }
  62. };
  63. backToMe = () => {
  64. this.setState({
  65. showCustom: false
  66. })
  67. };
  68. render() {
  69. let {userID, showCustom, chosenSchemaID, examplesFirst, examplesSecond} = this.state;
  70. const tabStyle = {
  71. paddingBottom: '50px',
  72. height: '550px',
  73. display: 'inline-block',
  74. };
  75. return (
  76. <div id="example-show">
  77. <Layout style={{padding: '24px', minHeight: '300px'}}>
  78. <Content className="content">
  79. {
  80. !showCustom ?
  81. <div>
  82. <Tabs tabPosition='left' size='large' tabBarStyle={tabStyle} tabBarGutter={100}>
  83. <TabPane tab="预约" key="1">
  84. <div style={{marginLeft: 100}}>
  85. {
  86. examplesFirst.length === 0 ?
  87. <Spin/> :
  88. <BaiduShow
  89. examples={examplesFirst}
  90. />
  91. }
  92. </div>
  93. </TabPane>
  94. <TabPane tab="电商" key="2">
  95. <div style={{marginLeft: 100}}>
  96. {
  97. examplesSecond.length === 0 ?
  98. <Spin/> :
  99. <BaiduShow
  100. examples={examplesSecond}
  101. />
  102. }
  103. </div>
  104. </TabPane>
  105. </Tabs>
  106. </div>
  107. :
  108. <UserCustom
  109. userID={userID}
  110. bucketName={this.schemaIDChangeBucket(chosenSchemaID)}
  111. history={this.props.history}
  112. backToMe={this.backToMe}
  113. />
  114. }
  115. </Content>
  116. </Layout>
  117. </div>
  118. )
  119. }
  120. }
  121. export default CaseShow;
  122. class BaiduShow extends Component {
  123. constructor(props) {
  124. super(props);
  125. console.log(props);
  126. this.state = {
  127. showCaseID: props.examples[0].id,
  128. index: 0
  129. }
  130. }
  131. render() {
  132. let {examples} = this.props;
  133. let {showCaseID, index} = this.state;
  134. let thisCase = examples[index];
  135. return (
  136. <Row>
  137. <Col span={12}>
  138. <Row>
  139. <div>
  140. <div className={'case-detail-title'}>{thisCase.title}</div>
  141. <div
  142. className={'case-detail-description'}>{thisCase.detailDescription ? thisCase.detailDescription : '暂无简介'}</div>
  143. <div className='cover-div'>
  144. <img
  145. className='cover-img'
  146. src={thisCase.img}
  147. alt={thisCase.title + '' + thisCase.description}
  148. />
  149. <div style={{marginTop: 5}}>—— 打开微信扫码体验 ——</div>
  150. </div>
  151. </div>
  152. </Row>
  153. <Row>
  154. {
  155. examples.map((item, index) => (
  156. <div
  157. className={showCaseID === item.id ? 'logo-cover-div logo-cover-div-on' : 'logo-cover-div'}
  158. onMouseEnter={() => {
  159. this.setState({
  160. showCaseID: item.id,
  161. index
  162. })
  163. }}
  164. key={index}
  165. >
  166. <img
  167. className='logo-cover-img'
  168. src={item.img}
  169. alt={item.title + '' + item.description}
  170. />
  171. <div>{item.description}</div>
  172. </div>
  173. ))
  174. }
  175. </Row>
  176. </Col>
  177. <Col span={6}>
  178. <div className={'detail-images'}>
  179. <img
  180. key={thisCase.detailImages[0]}
  181. src={thisCase.detailImages[0]}
  182. alt=""
  183. height="500"/>
  184. </div>
  185. </Col>
  186. </Row>
  187. )
  188. }
  189. }