import Taro, { Component } from '@tarojs/taro'
import './SelectSearch.scss'
import LFormGroup from '@/c/lform/formGroup'
export default class SelectSearch extends Component {
  constructor (props) {
    super(props)
    this.state = {
      formObj: {}
    }
  }
  
  componentDidUpdate (prevProps, prevState) {}

  dealPopup (str) {
    const { bc } = this.props
    const { formObj } = this.state
    if (bc) {
      if (str === 'confirm') {
        bc('confirm', formObj)
      } else {
        bc()
      }
    }
  }
  closePopup () {
    const { close } = this.props
    if (close) {
      close()
    }
  }

  baseFormChange (key, val) {
    let { formObj } = this.state
    formObj[key] = val
    this.setState({
      formObj
    })
  }

  render () {
    const { show } = this.props
    const { formObj } = this.state
    return (
      <View className={show ? 'l-modal-box' : 'l-modal-box hide'}>
        <View className='lmb-bg'></View>
        <View className='lmb-body'>
          <View className="lmb-main">
            <View className='l-floor-pos'>
              <LFormGroup
                val={formObj.keyWord}
                defineContentClassName="input-center"
                labelShow="no"
                pbShow="no"
                valStr="keyWord"
                keyStr="请输入关键词"
                bc={this.baseFormChange.bind(this)}
              />
            </View>
            <View className="l-floor-footer t2">
              <View className="lff-flex">
                <View className="lff-btn t3" onClick={this.closePopup.bind(this)}>关闭</View>
                <View className="lff-btn" onClick={this.dealPopup.bind(this, 'confirm')}>搜索</View>
              </View>
            </View>
          </View>
        </View>
      </View>
    )
  }
}