cartItem.js 1.88 KB
Newer Older
.  
baiguangyao committed
1 2 3
import React, { Component } from 'react';
import { Checkbox } from 'antd-mobile';
import OrderList from '@/common/OrderList';
xuzhenghua committed
4
import {Link} from "react-router-dom";
.  
baiguangyao committed
5 6


zhanghaozhe committed
7
class CartItem extends Component {
.  
baiguangyao committed
8 9 10 11 12 13 14 15 16
    // 构造函数
    constructor(props) {
        super(props)
        this.state = {
            val: props.item.value
        }
    }
    // 改变选择
    onChange(e, id) {
xuzhenghua committed
17
        let checked = e.target.checked
.  
baiguangyao committed
18 19 20 21 22 23 24
        this.props.checkChange(id, checked)
    }

    render() {
        let item = this.props.item
        const Info = (
            <div className="order-info">
25 26 27 28
                <p className='order-title text-overflow-one' onClick={()=>this.props.toDetail(item.course_id)}>
                    {/* <Link to={`/detail?id=${item.course_id}`}> */}
                    {item.course_title}
                    {/* </Link> */}
xuzhenghua committed
29
                </p>
xuzhenghua committed
30
                <p className='order-content text-overflow-2'>{item.simpledescription}</p>
.  
baiguangyao committed
31
                <p className='order-des'>
xuzhenghua committed
32 33
                    <span className='order-newprice'>¥{item.price1}</span>
                    <span className='order-price'>¥{item.price0}</span>
.  
baiguangyao committed
34 35 36 37 38 39 40 41
                </p>
            </div>
        )

        return (
                <div className="cart-c-item" >
                    <div className="cart-c-check">
                        <Checkbox checked={item.check} onChange={(e) => {
xuzhenghua committed
42
                            this.onChange(e, item.course_id)
.  
baiguangyao committed
43 44 45
                        }} />
                    </div>

xuzhenghua committed
46
                    <div className="card-wrap">
47 48 49 50 51 52
                        <OrderList 
                            info={Info} 
                            src={item.image_name} 
                            id={item.course_id}
                            toDetail={this.props.toDetail}
                        ></OrderList>
xuzhenghua committed
53
                    </div>
.  
baiguangyao committed
54 55 56 57 58
                </div>

        )
    }
}
zhanghaozhe committed
59
export default CartItem;