|
@@ -1,8 +1,8 @@
|
|
|
import React, {Component} from 'react'
|
|
import React, {Component} from 'react'
|
|
|
-import {Grid, Carousel, WhiteSpace, ActivityIndicator, Flex} from 'antd-mobile'
|
|
|
|
|
|
|
+import {Grid, Carousel, WhiteSpace, ActivityIndicator} from 'antd-mobile'
|
|
|
import './index.css'
|
|
import './index.css'
|
|
|
-import {Query} from "react-apollo";
|
|
|
|
|
-import gql from "graphql-tag";
|
|
|
|
|
|
|
+import {Query} from "react-apollo"
|
|
|
|
|
+import gql from "graphql-tag"
|
|
|
import {productbyprops} from "../../utils/gql"
|
|
import {productbyprops} from "../../utils/gql"
|
|
|
|
|
|
|
|
class Home extends Component {
|
|
class Home extends Component {
|
|
@@ -59,37 +59,45 @@ class Home extends Component {
|
|
|
<a
|
|
<a
|
|
|
key={val}
|
|
key={val}
|
|
|
href="http://www.alipay.com"
|
|
href="http://www.alipay.com"
|
|
|
- style={{ display: 'inline-block', width: '100%', height: 'auto', maxHeight: '200px', overflow: 'hidden' }}
|
|
|
|
|
|
|
+ style={{
|
|
|
|
|
+ display: 'inline-block',
|
|
|
|
|
+ width: '100%',
|
|
|
|
|
+ height: 'auto',
|
|
|
|
|
+ maxHeight: '200px',
|
|
|
|
|
+ overflow: 'hidden'
|
|
|
|
|
+ }}
|
|
|
>
|
|
>
|
|
|
<img
|
|
<img
|
|
|
src={`https://zos.alipayobjects.com/rmsportal/${val}.png`}
|
|
src={`https://zos.alipayobjects.com/rmsportal/${val}.png`}
|
|
|
alt=""
|
|
alt=""
|
|
|
- style={{ width: '100%', verticalAlign: 'top' }}
|
|
|
|
|
|
|
+ style={{width: '100%', verticalAlign: 'top'}}
|
|
|
/>
|
|
/>
|
|
|
</a>
|
|
</a>
|
|
|
))}
|
|
))}
|
|
|
</Carousel>
|
|
</Carousel>
|
|
|
- <Grid data={data} activeStyle={false} hasLine={false} isCarousel={true}/>
|
|
|
|
|
|
|
+ <Grid data={data} hasLine={false}/>
|
|
|
<WhiteSpace/>
|
|
<WhiteSpace/>
|
|
|
- <Query query={gql(productbyprops)} variables={{}}>
|
|
|
|
|
- {
|
|
|
|
|
- ({loading, error, data}) => {
|
|
|
|
|
- if (loading) {
|
|
|
|
|
|
|
+ <div className='guess-wrap'>
|
|
|
|
|
+ <Query query={gql(productbyprops)} variables={{status: '1'}}>
|
|
|
|
|
+ {
|
|
|
|
|
+ ({loading, error, data}) => {
|
|
|
|
|
+ if (loading) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div className="loading-center">
|
|
|
|
|
+ <ActivityIndicator text="Loading..." size="large"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ if (error) {
|
|
|
|
|
+ return 'error!'
|
|
|
|
|
+ }
|
|
|
return (
|
|
return (
|
|
|
- <div className="tab-center">
|
|
|
|
|
- <ActivityIndicator text="Loading..." size="large"/>z
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <Like data={data.productbyprops}/>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
- if (error) {
|
|
|
|
|
- return 'error!';
|
|
|
|
|
- }
|
|
|
|
|
- return (
|
|
|
|
|
- <Like data={data.productbyprops}/>
|
|
|
|
|
- )
|
|
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- </Query>
|
|
|
|
|
|
|
+ </Query>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
@@ -99,29 +107,31 @@ export default Home
|
|
|
|
|
|
|
|
class Like extends Component {
|
|
class Like extends Component {
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
- super(props);
|
|
|
|
|
- this.state = {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ super(props)
|
|
|
|
|
+ this.state = {}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
- let {data} = this.props;
|
|
|
|
|
- console.log(data)
|
|
|
|
|
|
|
+ let {data} = this.props
|
|
|
|
|
+ if (data % 2 !== 0) {
|
|
|
|
|
+ data.splice(0, 1)
|
|
|
|
|
+ }
|
|
|
return (
|
|
return (
|
|
|
- <div className='guess-wrap'>
|
|
|
|
|
|
|
+ <div className='guess-wrapper'>
|
|
|
<div className='guess-title'>- 猜你喜欢 -</div>
|
|
<div className='guess-title'>- 猜你喜欢 -</div>
|
|
|
- <Flex wrap="wrap">
|
|
|
|
|
- {
|
|
|
|
|
- data.map(data=>{
|
|
|
|
|
- return (
|
|
|
|
|
- <Flex.Item key={data.id}>
|
|
|
|
|
- <div className='guess-item-img' style={{backgroundImage: "url('"+ data.img + "')"}}/>
|
|
|
|
|
- </Flex.Item>
|
|
|
|
|
- )
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- </Flex>
|
|
|
|
|
|
|
+ <Grid data={data}
|
|
|
|
|
+ columnNum={2}
|
|
|
|
|
+ hasLine={false}
|
|
|
|
|
+ renderItem={dataItem => (
|
|
|
|
|
+ <div key={dataItem.id} className='guess-item'>
|
|
|
|
|
+ <div className='guess-item-img' style={{backgroundImage: "url('" + dataItem.img + "')"}}/>
|
|
|
|
|
+ <div className='guess-item-description'>
|
|
|
|
|
+ <div className='guess-item-name'>{dataItem.name}</div>
|
|
|
|
|
+ <div className='guess-item-price'>{dataItem.price}</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|