index.js 1.59 KB
Newer Older
xuzhenghua committed
1 2 3 4 5 6
import React, {Component} from 'react'
import {SearchBar} from 'antd-mobile'
import './index.scss'

class HeaderBar extends Component {
    toSearch() {
7
        window.location.href = '/search';
xuzhenghua committed
8
    }
xuzhenghua committed
9

xuzhenghua committed
10
    return() {
11
        window.location.href = '/';
xuzhenghua committed
12 13 14
    }

    goShop = () => {
15 16 17
        const { isLogin = false } = this.props;
        let url = isLogin? '/shopcart' : '/passport';
        window.location.replace(url);
xuzhenghua committed
18 19 20 21 22 23
    }

    render() {
        return (
            <div className='preferential'>
                <div className="search-nav">
xuzhenghua committed
24 25
                    {
                        !this.props.toHref &&
26 27 28 29
                        <i 
                            className={'iconfont iconiconfront-68 return'} 
                            onClick={this.return.bind(this)}
                        />
xuzhenghua committed
30 31 32
                    }
                    {
                        this.props.toHref &&
33 34 35 36
                        <i 
                            className={'iconfont iconiconfront-68 return'} 
                            onClick={this.props.toHref}
                        />
xuzhenghua committed
37
                    }
xuzhenghua committed
38 39 40 41 42 43
                    <SearchBar
                        placeholder="搜索课程"
                        cancelText={" "}
                        onFocus={this.toSearch.bind(this)}
                        showCancelButton={false}
                    />
44 45 46 47
                    <i 
                        className={'iconfont icongouwuche-xianxing shopping-cart'} 
                        onClick={this.goShop}
                    />
xuzhenghua committed
48 49 50 51 52 53 54
                </div>
            </div>
        )
    }

}

55
export default HeaderBar;