index.js 1.53 KB
Newer Older
wangshuo committed
1 2
import React, {Component} from 'react'
import './index.scss';
xuzhenghua committed
3

wangshuo committed
4 5 6 7
class HeaderBar extends Component {
    constructor(props) {
        super(props);
    }
xuzhenghua committed
8

wangshuo committed
9 10 11
    goBack = () => {
        window.history.go(-1);
    }
FE committed
12

13 14 15 16
    toLink = () => {
        const { toHref } = this.props;
        console.log(toHref);
        location.replace(toHref)
FE committed
17 18
    }

wangshuo committed
19 20 21
    goShop = () => {
        location.replace('/shopcart');
    }
xuzhenghua committed
22

wangshuo committed
23
    render() {
24
        const { toHref } = this.props
wangshuo committed
25 26
        return (
            <div className="detail-header" style={{...this.props.style}}>
xuzhenghua committed
27
                {
28
                    !toHref && this.props.arrow &&
xuzhenghua committed
29 30
                    <i className='iconfont iconiconfront-68' onClick={this.goBack}></i>
                }
FE committed
31
                {
32 33 34 35 36 37
                    toHref && typeof toHref === 'function' &&
                    <i className='iconfont iconiconfront-68' onClick={toHref}>1</i>
                }
                {
                    toHref && typeof toHref === 'string' &&
                    <i className='iconfont iconiconfront-68' onClick={this.toLink}></i>
FE committed
38
                }
wangshuo committed
39
                <span className='herder'>{this.props.title}</span>
xuzhenghua committed
40 41 42 43 44 45 46 47
                {
                    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>
                }
wangshuo committed
48 49 50
            </div>
        );
    }
xuzhenghua committed
51 52 53
};

export default HeaderBar;