import React, {Component} from 'react'
import './index.scss';

class HeaderBar extends Component {
    constructor(props) {
        super(props);
    }

    goBack = () => {
        window.history.go(-1);
    }

    toHref = () => {
        const { href } = this.props;
        location.replace(href)
    }

    goShop = () => {
        location.replace('/shopcart');
    }

    render() {
        return (
            <div className="detail-header" style={{...this.props.style}}>
                {
                    !this.props.href && this.props.arrow &&
                    <i className='iconfont iconiconfront-68' onClick={this.goBack}></i>
                }
                {
                    this.props.href &&
                    <i className='iconfont iconiconfront-68' onClick={this.toHref}></i>
                }
                <span className='herder'>{this.props.title}</span>
                {
                    this.props.cart &&
                    <i className='iconfont icongouwuche-xianxing' onClick={this.goShop}></i>
                }
                {
                    this.props.delete &&
                    <i className='iconfont iconiconfront-56' onClick={this.props.toDelete}></i>
                }
            </div>
        );
    }
};

export default HeaderBar;
