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

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

zhanghaozhe committed
10 11 12
  return() {
    window.location.href = "/"
  }
xuzhenghua committed
13

zhanghaozhe committed
14 15 16 17 18
  goShop = () => {
    const { isLogin = false } = this.props
    let url = isLogin ? "/shopcart" : "/passport"
    window.location.replace(url)
  }
xuzhenghua committed
19

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

zhanghaozhe committed
52
export default HeaderBar