| | |
| | | state = { |
| | | running: false, |
| | | line: 1, |
| | | gap: 2000, |
| | | init: true |
| | | } |
| | | |
| | | timer = null |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { autoMatic } = this.props |
| | | |
| | | if (autoMatic.gap && autoMatic.gap >= 1) { |
| | | this.setState({gap: autoMatic.gap * 1000}) |
| | | } |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('modifyTabs', this.breakOff) |
| | |
| | | |
| | | autoExecOver = (btnId, type) => { |
| | | const { autoMatic, config } = this.props |
| | | const { gap } = this.state |
| | | |
| | | if (!this.state.running || btnId !== autoMatic.action) return |
| | | |
| | |
| | | this.setState({line: this.state.line + 1}, () => { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 2000) |
| | | }, gap) |
| | | }) |
| | | } else if (autoMatic.onFail === 'stay') { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 2000) |
| | | }, gap) |
| | | } else { |
| | | this.setState({running: false}) |
| | | } |
| | |
| | | this.setState({line: this.state.line + 1}, () => { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 2000) |
| | | }, gap) |
| | | }) |
| | | } else if (autoMatic.onSuccess === 'stay') { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 2000) |
| | | }, gap) |
| | | } else { |
| | | this.setState({running: false}) |
| | | } |