|
@@ -1,39 +1,98 @@
|
|
|
import React, {Component} from 'react'
|
|
import React, {Component} from 'react'
|
|
|
-import './index.css'
|
|
|
|
|
import {withRouter} from 'react-router-dom'
|
|
import {withRouter} from 'react-router-dom'
|
|
|
-import {SearchBar, NavBar, ActivityIndicator, List, Tabs} from 'antd-mobile'
|
|
|
|
|
import {Icon} from 'antd'
|
|
import {Icon} from 'antd'
|
|
|
|
|
+import {SearchBar, NavBar, ActivityIndicator, List, Tabs, Modal} from 'antd-mobile'
|
|
|
import {Query} from "react-apollo"
|
|
import {Query} from "react-apollo"
|
|
|
import gql from "graphql-tag"
|
|
import gql from "graphql-tag"
|
|
|
|
|
+
|
|
|
import {order_by_id, orderbyprops} from "../../../../utils/gql"
|
|
import {order_by_id, orderbyprops} from "../../../../utils/gql"
|
|
|
import {DisplayRender} from "../../order/display"
|
|
import {DisplayRender} from "../../order/display"
|
|
|
|
|
+import './index.css'
|
|
|
|
|
|
|
|
const Item = List.Item;
|
|
const Item = List.Item;
|
|
|
|
|
|
|
|
const tabs = [
|
|
const tabs = [
|
|
|
- { title: '待发货' },
|
|
|
|
|
- { title: '待收货' },
|
|
|
|
|
- { title: '已完成' },
|
|
|
|
|
- { title: '查询订单' }
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ key: '0',
|
|
|
|
|
+ orderStatus: '0',
|
|
|
|
|
+ title: '待付款',
|
|
|
|
|
+ id: 'pay'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ key: '1',
|
|
|
|
|
+ orderStatus: '1',
|
|
|
|
|
+ title: '待发货',
|
|
|
|
|
+ id: 'ship'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ key: '2',
|
|
|
|
|
+ orderStatus: '2',
|
|
|
|
|
+ title: '待收货',
|
|
|
|
|
+ id: 'unbox'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ key: '3',
|
|
|
|
|
+ orderStatus: '3',
|
|
|
|
|
+ title: '已完成',
|
|
|
|
|
+ id: 'judge'
|
|
|
|
|
+ }
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
class Orders extends Component {
|
|
class Orders extends Component {
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props)
|
|
super(props)
|
|
|
this.state = {
|
|
this.state = {
|
|
|
- tabValue: '0',
|
|
|
|
|
|
|
+ orderStatus: sessionStorage.getItem('select_orderStatus') || '0'
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ componentWillMount() {
|
|
|
|
|
+ const {location} = this.props
|
|
|
|
|
+ this.getOrderStatus(location)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ getOrderStatus = (location) => {
|
|
|
|
|
+ let orderStatus = sessionStorage.getItem('select_orderStatus') || '0'
|
|
|
|
|
+ if(orderStatus){
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ orderStatus
|
|
|
|
|
+ })
|
|
|
|
|
+ }else if (location && location.state) {
|
|
|
|
|
+ let orderStatus = '0'
|
|
|
|
|
+ const kind = location.state.kind
|
|
|
|
|
+ switch (kind) {
|
|
|
|
|
+ case 'pay':
|
|
|
|
|
+ orderStatus = '0'
|
|
|
|
|
+ break
|
|
|
|
|
+ case 'ship':
|
|
|
|
|
+ orderStatus = '1'
|
|
|
|
|
+ break
|
|
|
|
|
+ case 'unbox':
|
|
|
|
|
+ orderStatus = '2'
|
|
|
|
|
+ break
|
|
|
|
|
+ case 'judge':
|
|
|
|
|
+ orderStatus = '3'
|
|
|
|
|
+ break
|
|
|
|
|
+ default:
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ orderStatus
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
changeOrderStatus = (value) => {
|
|
changeOrderStatus = (value) => {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
- tabValue: value.tabValue
|
|
|
|
|
|
|
+ orderStatus: value.orderStatus
|
|
|
})
|
|
})
|
|
|
|
|
+ sessionStorage.setItem('select_orderStatus',value.orderStatus)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
const { history } = this.props
|
|
const { history } = this.props
|
|
|
- // console.log("Orders history",history)
|
|
|
|
|
|
|
+ let { orderStatus } = this.state
|
|
|
|
|
+ // console.log("Orders orderStatus",orderStatus)
|
|
|
return (
|
|
return (
|
|
|
<div className='goods-wrap'>
|
|
<div className='goods-wrap'>
|
|
|
<NavBar
|
|
<NavBar
|
|
@@ -46,17 +105,52 @@ class Orders extends Component {
|
|
|
>订单管理</NavBar>
|
|
>订单管理</NavBar>
|
|
|
<Tabs
|
|
<Tabs
|
|
|
tabs={tabs}
|
|
tabs={tabs}
|
|
|
- initialPage={0}
|
|
|
|
|
|
|
+ swipeable={false}
|
|
|
|
|
+ initialPage={orderStatus}
|
|
|
onChange={(tabValue, index) => {
|
|
onChange={(tabValue, index) => {
|
|
|
- console.log('onChange', index, tabValue);
|
|
|
|
|
|
|
+ // console.log('onChange', index, tabValue);
|
|
|
this.changeOrderStatus(tabValue)
|
|
this.changeOrderStatus(tabValue)
|
|
|
}}
|
|
}}
|
|
|
// onChange={(tab, index) => { console.log('onChange', index, tab); }}
|
|
// onChange={(tab, index) => { console.log('onChange', index, tab); }}
|
|
|
>
|
|
>
|
|
|
- <Shiping history={history} />
|
|
|
|
|
- <Unbox history={history} />
|
|
|
|
|
- <Completed history={history} />
|
|
|
|
|
- <Search history={history} />
|
|
|
|
|
|
|
+ <Query query={gql(orderbyprops)} variables={{orderStatus}}>
|
|
|
|
|
+ {
|
|
|
|
|
+ ({loading, error, data}) => {
|
|
|
|
|
+ if (loading) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div className="loading-center">
|
|
|
|
|
+ <ActivityIndicator text="加载中..." size="large"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ if (error) {
|
|
|
|
|
+ return 'error!'
|
|
|
|
|
+ }
|
|
|
|
|
+ data = data.orderbyprops
|
|
|
|
|
+ // console.log(data)
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div>
|
|
|
|
|
+ {
|
|
|
|
|
+ data.length === 0 ?
|
|
|
|
|
+ <div className='order-tip-wrap'>
|
|
|
|
|
+ <div className='order-tip'>还没有这种订单</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ :
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <Search/>
|
|
|
|
|
+ <DisplayRender
|
|
|
|
|
+ data={data}
|
|
|
|
|
+ orderStatus={orderStatus}
|
|
|
|
|
+ button={false}
|
|
|
|
|
+ history={this.props.history}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ }
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ </Query>
|
|
|
</Tabs>
|
|
</Tabs>
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
@@ -68,7 +162,8 @@ class Search extends Component {
|
|
|
super(props)
|
|
super(props)
|
|
|
this.state = {
|
|
this.state = {
|
|
|
value: '',
|
|
value: '',
|
|
|
- searchValue: ''
|
|
|
|
|
|
|
+ searchValue: '',
|
|
|
|
|
+ orderDetailModal: false
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -80,18 +175,35 @@ class Search extends Component {
|
|
|
this.setState({value});
|
|
this.setState({value});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ changeModal = (bool, e) => {
|
|
|
|
|
+ e.preventDefault()
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ orderDetailModal: bool
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
render() {
|
|
render() {
|
|
|
|
|
+ let {value, searchValue, orderDetailModal} = this.state
|
|
|
return (
|
|
return (
|
|
|
<div className='order-body'>
|
|
<div className='order-body'>
|
|
|
<SearchBar
|
|
<SearchBar
|
|
|
ref={ref => this.autoFocusInst = ref}
|
|
ref={ref => this.autoFocusInst = ref}
|
|
|
placeholder="请在此处输入订单编号"
|
|
placeholder="请在此处输入订单编号"
|
|
|
- value={this.state.value}
|
|
|
|
|
- onSubmit={searchValue => this.setState({searchValue})}
|
|
|
|
|
|
|
+ value={value}
|
|
|
|
|
+ onSubmit={searchValue => {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ searchValue,
|
|
|
|
|
+ orderDetailModal: true
|
|
|
|
|
+ })
|
|
|
|
|
+ }}
|
|
|
onCancel={() => this.setState({value: ''})}
|
|
onCancel={() => this.setState({value: ''})}
|
|
|
onChange={value => this.setState({value})}
|
|
onChange={value => this.setState({value})}
|
|
|
/>
|
|
/>
|
|
|
- <SearchQuery id={this.state.searchValue}/>
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ searchValue ?
|
|
|
|
|
+ <SearchQuery id={searchValue} changeModal={this.changeModal} orderDetailModal={orderDetailModal}/>
|
|
|
|
|
+ : ''
|
|
|
|
|
+ }
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
@@ -103,10 +215,6 @@ class SearchQuery extends Component {
|
|
|
this.state = {}
|
|
this.state = {}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- shouldComponentUpdate(nextProps) {
|
|
|
|
|
- return nextProps.id !== this.props.id;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
statusRender = (status) => {
|
|
statusRender = (status) => {
|
|
|
switch (status) {
|
|
switch (status) {
|
|
|
case '0':
|
|
case '0':
|
|
@@ -125,7 +233,7 @@ class SearchQuery extends Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
- let {id} = this.props
|
|
|
|
|
|
|
+ const {id, orderDetailModal} = this.props
|
|
|
return (
|
|
return (
|
|
|
<Query query={gql(order_by_id)} variables={{id}} className='search-query'>
|
|
<Query query={gql(order_by_id)} variables={{id}} className='search-query'>
|
|
|
{
|
|
{
|
|
@@ -137,20 +245,31 @@ class SearchQuery extends Component {
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
- if (error) {
|
|
|
|
|
- return 'error!'
|
|
|
|
|
- }
|
|
|
|
|
- data = data.orderbyid
|
|
|
|
|
- if (data === null) {
|
|
|
|
|
|
|
+ if (error) return 'error!'
|
|
|
|
|
+ const orderDetailData = data.orderbyid
|
|
|
|
|
+ if (!orderDetailData) {
|
|
|
return (
|
|
return (
|
|
|
- <div className='order-tip-wrap'>
|
|
|
|
|
- <div className='order-tip'>请输入正确的订单号</div>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <Modal
|
|
|
|
|
+ popup
|
|
|
|
|
+ visible={orderDetailModal}
|
|
|
|
|
+ onClose={(e)=>this.props.changeModal(false, e)}
|
|
|
|
|
+ animationType="slide-up"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div className='close-item'>
|
|
|
|
|
+ <div className='close-popup' onClick={(e)=>this.props.changeModal(false, e)}>
|
|
|
|
|
+ <Icon type="close" />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className='no-order-detail'>
|
|
|
|
|
+ <p>未查询到相关信息</p>
|
|
|
|
|
+ <p>请检查输入的订单编号是否有误!</p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </Modal>
|
|
|
)
|
|
)
|
|
|
} else {
|
|
} else {
|
|
|
- let {id, orderStatus, orderTotalPay, productTotalPay, count, remark, user_id, createdAt, orderLogistics_id, orderPay_id} = data
|
|
|
|
|
|
|
+ let {id, orderStatus, orderTotalPay, productTotalPay, count, remark, user_id, createdAt, orderLogistics_id, orderPay_id} = orderDetailData
|
|
|
let {telephone: telephoneUser, username: usernameUser, email} = user_id
|
|
let {telephone: telephoneUser, username: usernameUser, email} = user_id
|
|
|
- let {consigneeName, consigneeTel, consignAddress} = orderLogistics_id
|
|
|
|
|
|
|
+ let {expressDetailName, expressId, consigneeName, consigneeTel, consignAddress} = orderLogistics_id
|
|
|
let logisticsFee, LogisticsStatus, expressCreatedAt
|
|
let logisticsFee, LogisticsStatus, expressCreatedAt
|
|
|
if (orderLogistics_id !== null) {
|
|
if (orderLogistics_id !== null) {
|
|
|
logisticsFee = orderLogistics_id.logisticsFee
|
|
logisticsFee = orderLogistics_id.logisticsFee
|
|
@@ -177,163 +296,36 @@ class SearchQuery extends Component {
|
|
|
"用户电话": telephoneUser,
|
|
"用户电话": telephoneUser,
|
|
|
"物流费用": logisticsFee,
|
|
"物流费用": logisticsFee,
|
|
|
"物流状态": LogisticsStatus,
|
|
"物流状态": LogisticsStatus,
|
|
|
|
|
+ "快递名称": expressDetailName,
|
|
|
|
|
+ "快递单号": expressId,
|
|
|
"发货时间": expressCreatedAt
|
|
"发货时间": expressCreatedAt
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <List>
|
|
|
|
|
- {
|
|
|
|
|
- Object.keys(all).map((key, index) => (
|
|
|
|
|
- <Item key={index}><span className='item-title'>{key}:</span><span
|
|
|
|
|
- className='item-value'>{all[key]}</span></Item>
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- </List>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- </Query>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-class Shiping extends Component {
|
|
|
|
|
- constructor(props) {
|
|
|
|
|
- super(props)
|
|
|
|
|
- this.state = {}
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- render() {
|
|
|
|
|
- // console.log("Shiping this.props.history",this.props.history)
|
|
|
|
|
- return (
|
|
|
|
|
- <Query query={gql(orderbyprops)} variables={{orderStatus: '1'}}>
|
|
|
|
|
- {
|
|
|
|
|
- ({loading, error, data}) => {
|
|
|
|
|
- if (loading) {
|
|
|
|
|
- return (
|
|
|
|
|
- <div className="loading-center">
|
|
|
|
|
- <ActivityIndicator text="加载中..." size="large"/>
|
|
|
|
|
- </div>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- if (error) {
|
|
|
|
|
- return 'error!'
|
|
|
|
|
- }
|
|
|
|
|
- data = data.orderbyprops
|
|
|
|
|
-
|
|
|
|
|
- return (
|
|
|
|
|
- <div>
|
|
|
|
|
- {
|
|
|
|
|
- data.length === 0 ?
|
|
|
|
|
- <div className='order-tip-wrap'>
|
|
|
|
|
- <div className='order-tip'>还没有这种订单</div>
|
|
|
|
|
- </div>
|
|
|
|
|
- :
|
|
|
|
|
- <DisplayRender
|
|
|
|
|
- data={data}
|
|
|
|
|
- orderStatus='1'
|
|
|
|
|
- button={false}
|
|
|
|
|
- history={this.props.history}
|
|
|
|
|
- />
|
|
|
|
|
- }
|
|
|
|
|
- </div>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- </Query>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-class Unbox extends Component {
|
|
|
|
|
- constructor(props) {
|
|
|
|
|
- super(props)
|
|
|
|
|
- this.state = {}
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- render() {
|
|
|
|
|
- return (
|
|
|
|
|
- <Query query={gql(orderbyprops)} variables={{orderStatus: '2'}}>
|
|
|
|
|
- {
|
|
|
|
|
- ({loading, error, data}) => {
|
|
|
|
|
- if (loading) {
|
|
|
|
|
- return (
|
|
|
|
|
- <div className="loading-center">
|
|
|
|
|
- <ActivityIndicator text="加载中..." size="large"/>
|
|
|
|
|
- </div>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- if (error) {
|
|
|
|
|
- return 'error!'
|
|
|
|
|
- }
|
|
|
|
|
- data = data.orderbyprops
|
|
|
|
|
- // console.log(data)
|
|
|
|
|
- return (
|
|
|
|
|
- <div>
|
|
|
|
|
- {
|
|
|
|
|
- data.length === 0 ?
|
|
|
|
|
- <div className='order-tip-wrap'>
|
|
|
|
|
- <div className='order-tip'>还没有这种订单</div>
|
|
|
|
|
|
|
+ <Modal
|
|
|
|
|
+ popup
|
|
|
|
|
+ visible={orderDetailModal}
|
|
|
|
|
+ onClose={(e)=>this.props.changeModal(false, e)}
|
|
|
|
|
+ animationType="slide-up"
|
|
|
|
|
+ className='modify-goods-modal'
|
|
|
|
|
+ >
|
|
|
|
|
+ <div className='close-item'>
|
|
|
|
|
+ <div className='close-popup' onClick={(e)=>this.props.changeModal(false, e)}>
|
|
|
|
|
+ <Icon type="close" />
|
|
|
</div>
|
|
</div>
|
|
|
- :
|
|
|
|
|
- <DisplayRender
|
|
|
|
|
- data={data}
|
|
|
|
|
- orderStatus='2'
|
|
|
|
|
- button={false}
|
|
|
|
|
- history={this.props.history}
|
|
|
|
|
- />
|
|
|
|
|
- }
|
|
|
|
|
- </div>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- </Query>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-class Completed extends Component {
|
|
|
|
|
- constructor(props) {
|
|
|
|
|
- super(props)
|
|
|
|
|
- this.state = {}
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- render() {
|
|
|
|
|
- return (
|
|
|
|
|
- <Query query={gql(orderbyprops)} variables={{orderStatus: '3'}}>
|
|
|
|
|
- {
|
|
|
|
|
- ({loading, error, data}) => {
|
|
|
|
|
- if (loading) {
|
|
|
|
|
- return (
|
|
|
|
|
- <div className="loading-center">
|
|
|
|
|
- <ActivityIndicator text="加载中..." size="large"/>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <List>
|
|
|
|
|
+ {
|
|
|
|
|
+ Object.keys(all).map((key, index) => (
|
|
|
|
|
+ <Item key={index}><span className='item-title'>{key}:</span><span
|
|
|
|
|
+ className='item-value'>{all[key]}</span></Item>
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ </List>
|
|
|
|
|
+ </Modal>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
- if (error) {
|
|
|
|
|
- return 'error!'
|
|
|
|
|
- }
|
|
|
|
|
- data = data.orderbyprops
|
|
|
|
|
- // console.log(data)
|
|
|
|
|
- return (
|
|
|
|
|
- <div>
|
|
|
|
|
- {
|
|
|
|
|
- data.length === 0 ?
|
|
|
|
|
- <div className='order-tip-wrap'>
|
|
|
|
|
- <div className='order-tip'>还没有这种订单</div>
|
|
|
|
|
- </div>
|
|
|
|
|
- :
|
|
|
|
|
- <DisplayRender
|
|
|
|
|
- data={data}
|
|
|
|
|
- orderStatus='3'
|
|
|
|
|
- button={false}
|
|
|
|
|
- history={this.props.history}
|
|
|
|
|
- />
|
|
|
|
|
- }
|
|
|
|
|
- </div>
|
|
|
|
|
- )
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</Query>
|
|
</Query>
|