Commit a8aeb17c by xuzhenghua

detail

parent 454affe1
...@@ -4,6 +4,8 @@ import {connect} from "react-redux" ...@@ -4,6 +4,8 @@ import {connect} from "react-redux"
import {Toast} from 'antd-mobile' import {Toast} from 'antd-mobile'
import {api, http} from "@/utils" import {api, http} from "@/utils"
import {HeaderBar} from "@/common" import {HeaderBar} from "@/common"
// import {logout} from '@/store/userAction'
class MyEdut extends PureComponent { class MyEdut extends PureComponent {
...@@ -37,7 +39,7 @@ class MyEdut extends PureComponent { ...@@ -37,7 +39,7 @@ class MyEdut extends PureComponent {
} }
// 退出登录 // 退出登录
outLogin = () => { outLogin = () => {
// this.props.logout()
} }
// 确定修改 // 确定修改
...@@ -106,5 +108,5 @@ class MyEdut extends PureComponent { ...@@ -106,5 +108,5 @@ class MyEdut extends PureComponent {
export default connect( export default connect(
state => ({user: state.user}), state => ({user: state.user}),
null // {logout}
)(MyEdut) )(MyEdut)
...@@ -18,7 +18,6 @@ class Cart extends Component { ...@@ -18,7 +18,6 @@ class Cart extends Component {
super(props) super(props)
this.state = { this.state = {
data: [], data: [],
deleteAll: false,
checkedNum: 0, checkedNum: 0,
allPrice: 0, allPrice: 0,
cartNmu: 0, cartNmu: 0,
...@@ -111,11 +110,12 @@ class Cart extends Component { ...@@ -111,11 +110,12 @@ class Cart extends Component {
let allPrice = 0; let allPrice = 0;
let checkedNum = 0; let checkedNum = 0;
let cartNmu = 0; let cartNmu = 0;
let arr = []
newData.forEach((item, i) => { newData.forEach((item, i) => {
if (item.check) { if (item.check) {
i++; arr.push(item)
cartNmu += 1; cartNmu += 1;
checkedNum = i; checkedNum = arr.length;
allPrice += parseFloat(item.price1); allPrice += parseFloat(item.price1);
} }
}) })
...@@ -126,6 +126,19 @@ class Cart extends Component { ...@@ -126,6 +126,19 @@ class Cart extends Component {
}) })
} }
// 去结算
tobuy = () => {
http.get(`${api['pay-api']}/m/cart/addtopreorder/[${this.state.courseIdarr}]`).then((res) => {
if (res.data.errno == 0) {
this.props.history.push('/order')
} else {
Toast.info(res.data.msg, 2);
}
})
}
// 删除 // 删除
todelete = () => { todelete = () => {
if (this.state.courseIdarr.length > 0) { if (this.state.courseIdarr.length > 0) {
...@@ -161,28 +174,6 @@ class Cart extends Component { ...@@ -161,28 +174,6 @@ class Cart extends Component {
<div className="cart-body"> <div className="cart-body">
<ShopCart checkChange={this.checkChange.bind(this)} data={this.state.data}/> <ShopCart checkChange={this.checkChange.bind(this)} data={this.state.data}/>
{
this.state.deleteAll ?
<div className="cart-footer">
<div>
<Checkbox onChange={(e) => {
this.allChange(e)
}}/>
<div>全选</div>
</div>
<div></div>
<div className={classnames({
'active': this.state.cartNmu > 0
})}
onClick={() => {
if (this.state.cartNmu > 0) {
this.delete()
}
}}>
删除<span>({this.state.cartNmu})</span>
</div>
</div>
:
<div className="cart-footer"> <div className="cart-footer">
<div className="cart-label"> <div className="cart-label">
<Checkbox onChange={(e) => { <Checkbox onChange={(e) => {
...@@ -200,13 +191,13 @@ class Cart extends Component { ...@@ -200,13 +191,13 @@ class Cart extends Component {
'active': this.state.checkedNum > 0 'active': this.state.checkedNum > 0
})} onClick={() => { })} onClick={() => {
if (this.state.checkedNum > 0) { if (this.state.checkedNum > 0) {
this.buy() this.tobuy()
} }
}}> }}>
结算<span> ( {this.state.checkedNum} ) </span> 结算<span> ( {this.state.checkedNum} ) </span>
</div> </div>
</div> </div>
}
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment