import React, { Component } from 'react';
import './index.less';
import Icon from '../Icon';
export default class Input extends Component {
render() {
const { className = '', onChange, placeholder, error, left, right } = this.props;
return (
{left &&
{left}
}
onChange && onChange(data)} />
{right &&
{right}
}
{error}
);
}
}
export class SelectInput extends Component {
render() {
const { className = '', onChange, placeholder, value, selectValue, onSelect } = this.props;
return (
onSelect && onSelect()}>
{selectValue}
}
value={value}
placeholder={placeholder}
onChange={data => onChange && onChange(data)}
/>
);
}
}
export class VerificationInput extends Component {
constructor(props) {
super(props);
this.timeKey = null;
this.state = { loading: 0 };
}
componentWillUnmount() {
if (this.timeKey) clearTimeout(this.timeKey);
}
onSend() {
const { onSend, time = 60 } = this.props;
if (onSend) {
onSend();
}
this.setTime(time);
}
setTime(time) {
this.setState({ loading: time });
this.timeKey = setTimeout(() => {
this.setTime(time - 1);
}, 1000);
}
render() {
const { loading } = this.state;
const { className = '', onChange, placeholder, value } = this.props;
return (
this.onSend()}>
获取验证码
) : (
等待{loading}秒
)
}
value={value}
placeholder={placeholder}
onChange={data => onChange && onChange(data)}
/>
);
}
}