|
@@ -1,7 +1,7 @@
|
|
|
import React, { Component } from 'react';
|
|
import React, { Component } from 'react';
|
|
|
import ShopCarCard from './ShopCarCard'
|
|
import ShopCarCard from './ShopCarCard'
|
|
|
import {PageContext} from '../../context/context'
|
|
import {PageContext} from '../../context/context'
|
|
|
-
|
|
|
|
|
|
|
+import {ActivityIndicator} from 'antd-mobile';
|
|
|
import './ShopCarPage.css'
|
|
import './ShopCarPage.css'
|
|
|
import {graphqls} from '../../api/graphql_request'
|
|
import {graphqls} from '../../api/graphql_request'
|
|
|
import {getShopCarByProps,deleteCarByProps,} from '../../api/graphql/shopCar'
|
|
import {getShopCarByProps,deleteCarByProps,} from '../../api/graphql/shopCar'
|
|
@@ -12,7 +12,8 @@ class ShopCarPage extends Component{
|
|
|
this.state={
|
|
this.state={
|
|
|
shopCarList:[],
|
|
shopCarList:[],
|
|
|
sumPrice:0,
|
|
sumPrice:0,
|
|
|
- shopCarCount:0
|
|
|
|
|
|
|
+ shopCarCount:0,
|
|
|
|
|
+ loading:true
|
|
|
}
|
|
}
|
|
|
this.renderShopCarList=this.renderShopCarList.bind(this)
|
|
this.renderShopCarList=this.renderShopCarList.bind(this)
|
|
|
this.deleteCarById=this.deleteCarById.bind(this)
|
|
this.deleteCarById=this.deleteCarById.bind(this)
|
|
@@ -39,8 +40,11 @@ class ShopCarPage extends Component{
|
|
|
this.setState({
|
|
this.setState({
|
|
|
shopCarList:response.userCartbyprops,
|
|
shopCarList:response.userCartbyprops,
|
|
|
sumPrice,
|
|
sumPrice,
|
|
|
- shopCarCount
|
|
|
|
|
|
|
+ shopCarCount,
|
|
|
|
|
+ loading:false
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -54,9 +58,8 @@ class ShopCarPage extends Component{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
renderShopCarList(){
|
|
renderShopCarList(){
|
|
|
- return this.state.shopCarList.map((item,index)=>{
|
|
|
|
|
|
|
+ return this.state.shopCarList||[].map((item,index)=>{
|
|
|
return <ShopCarCard car={item} key={index} deleteCarById={this.deleteCarById}/>
|
|
return <ShopCarCard car={item} key={index} deleteCarById={this.deleteCarById}/>
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -64,6 +67,7 @@ class ShopCarPage extends Component{
|
|
|
render(){
|
|
render(){
|
|
|
return(
|
|
return(
|
|
|
<div className="shopCarPage">
|
|
<div className="shopCarPage">
|
|
|
|
|
+ <ActivityIndicator toast text="loading" animating={this.state.loading}/>
|
|
|
<div className="ShopCarList">
|
|
<div className="ShopCarList">
|
|
|
{this.renderShopCarList()}
|
|
{this.renderShopCarList()}
|
|
|
</div>
|
|
</div>
|
|
@@ -72,9 +76,11 @@ class ShopCarPage extends Component{
|
|
|
<button
|
|
<button
|
|
|
className="toPay"
|
|
className="toPay"
|
|
|
onClick={()=>{
|
|
onClick={()=>{
|
|
|
- this.props.changePage('order')
|
|
|
|
|
- this.props.setFromShopCar(true)
|
|
|
|
|
- //this.deleteAllShopCar()
|
|
|
|
|
|
|
+ if(this.state.shopCarList.length>0){
|
|
|
|
|
+ this.props.changePage('order')
|
|
|
|
|
+ this.props.setFromShopCar(true)
|
|
|
|
|
+ //this.deleteAllShopCar()
|
|
|
|
|
+ }
|
|
|
}}
|
|
}}
|
|
|
>去支付</button>
|
|
>去支付</button>
|
|
|
</div>
|
|
</div>
|