cartList.js 1.58 KB
Newer Older
xuzhenghua committed
1 2
import React, {Component} from 'react'
import {Link} from 'react-router-dom'
zhanghaozhe committed
3
import CartItem from './cartItem'
4

xuzhenghua committed
5
class cartList extends Component {
.  
baiguangyao committed
6 7 8 9 10 11
    render() {
        return (
            <div className="cart-main">
                {/* 遍历购物车商品列表 */}
                <div className="cart-c-body">
                    {
xuzhenghua committed
12
                        this.props.data.length > 0 ?
xuzhenghua committed
13
                            this.props.data.map((item, index) => {
.  
baiguangyao committed
14
                                return (
zhanghaozhe committed
15
                                    <CartItem
xuzhenghua committed
16
                                        index={index}
.  
baiguangyao committed
17 18
                                        changeStock={(id, val) => {
                                            this.props.changeStock(id, val)
zhanghaozhe committed
19
                                        }}
.  
baiguangyao committed
20 21
                                        checkChange={(id, val) => {
                                            this.props.checkChange(id, val)
zhanghaozhe committed
22
                                        }}
23 24 25 26
                                        key={index} 
                                        item={item}
                                        toDetail={this.props.toDetail}
                                    />
.  
baiguangyao committed
27 28
                                )
                            })
xuzhenghua committed
29 30
                            : <div className="cart-tip">
                                <p className='cart-mess'>这里是空的,快去逛逛吧~</p>
xuzhenghua committed
31
                                <Link to='/classify'>去逛逛</Link>
xuzhenghua committed
32
                            </div>
.  
baiguangyao committed
33 34 35 36 37 38 39
                    }
                </div>
            </div>
        )
    }
}

xuzhenghua committed
40
export default cartList;