import React from 'react'
import Button from '../../CommonComponent/ButtonComponent/ButtonComponent'
require('./index.css')
class BreakageCode extends React.Component{
    constructor(props){
         super(props)
         this.state={
             barcode:'',
             barcodeWord:false
         }
    }

    render(){
        let { barcode , barcodeWord } = this.state;
       return (
           <div className={'breakageContent'} style={{width:'100%',height:'100%',background:'rgba(0,0,0,1)'}}>
                <div className={"breakageCodeHeader font32  colfff "}>
                    <i className={"iconfont middle icon font50 icon-circle-left circleIcon fl"} style={{flexBasis:'100px'}}/>
                    <span className={"font40"}>请输入遗留商品的条形码</span>
                    <span className={'font30'}>条形码残缺?</span>
                </div>
               <div className={'breakageCodeContent'}>
                   {
                       barcodeWord?<p className={'font30'} style={{color:'#d0021b',textAlign:'center',marginTop:'20px'}}>条形码输入错误，请重新输入</p>:null
                   }
                   <input type="text" className={'font30'} vlaue={barcode} onChange={(ev)=>{this.setState({barcode:ev.target.value})}}/>
                   <p className={'barcodeScan font30 colfff'}>or<span className={'colff7860'}>条形码扫描</span></p>
               </div>
               <Button text={'确定'} option={this.getCodeProduct.bind(this)} btnContainer={'font30 backff775c colfff'} style={{border:'0',margin:'0 auto',marginTop:'120px'}} />
           </div>
       )
    }
    getCodeProduct(){
        let {barcode}=this.state;
        //验证输入的条形码是否为空
        if(barcode){
           this.props.getBarCodeProductInfo(barcode);
           this.props.changePage(2)
           this.setState({barcodeWord:false})
        }else{
            this.setState({barcodeWord:true})
        }
    }
}
export default BreakageCode;