import React, {Component} from 'react'
import {withRouter} from 'react-router-dom'
import {Query} from "react-apollo"
import gql from "graphql-tag"
import {NavBar, Icon, ActivityIndicator, Badge} from 'antd-mobile'
import {productbyid} from "../../../utils/gql"
import './index.css'
class Detail extends Component {
constructor(props) {
super(props)
this.state = {
id: ''
}
}
componentWillMount() {
let {location} = this.props
if(location && location.state) {
this.setState({
id: location.state.id
})
}
}
render() {
let {id} = this.state
let contentHeight = window.innerHeight
return (
}
onLeftClick={() => {this.props.history.go(-1)}}
>商品详情
{
({loading, error, data}) => {
if (loading) {
return (
)
}
if (error) {
return 'error!'
}
return (
)
}
}
)
}
}
export default withRouter(Detail)
class DetailRender extends Component {
constructor(props) {
super(props)
this.state = {
cartCount:sessionStorage.getItem('cartCount')
}
}
render() {
let {data} = this.props
let {cartCount} = this.state
return (
{data.name}
¥{data.price}
¥{data.price}
库存 {data.stock}
{this.props.history.push({pathname: '/home'})}}>
{this.props.history.push({pathname: '/cart'})}}>
{}}>加入购物车
{}}>立即购买
)
}
}