/**
 * 倒计时
 */

import Taro, { Component, Config } from '@tarojs/taro';
import { ComponentClass } from 'react';
import { View } from '@tarojs/components';

import Timer from '../../components/timer/timer';
import { IPageState, IProps, IPageOwnProps } from './timer.itf'
import './timer.scss';

interface Index {
  props: IProps;
  // this的属性可以在这里定义
}

class Index extends Component {
  config: Config = {
    navigationBarTitleText: ''
  };

  state: IPageState = {
    startTime: new Date().getTime(),
    endTime: new Date().getTime() + 20000
  };

  componentDidMount() {}

  componentDidShow() {}

  tickHandler(time) {
    console.log(time)
  }

  timeupHandler() {
    console.log('timeup')
  }

  /**
   * handleListItemClick
   */
  handleListItemClick = (componentType) => {
    Taro.navigateTo({
      url: `/pages/demos/${componentType}`
    })
  }

  render() {
    const { startTime, endTime } = this.state
    return (
      <View className='timer-page'>
        <Timer startTime={startTime} endTime={endTime} onTick={this.tickHandler} onTimeup={this.timeupHandler} />
      </View>
    );
  }
}
export default Index as ComponentClass<IPageOwnProps, IPageState>;

