import { ComponentClass } from 'react'
import Taro, { Component } from '@tarojs/taro'
import { View, Label } from '@tarojs/components'
import './index.scss'
import { AtIcon } from 'taro-ui';

type PageOwnProps = {
  className?: string
  money?: any
  type: 'recharge' | 'withdraw'
  result: 'success' | 'faile' | 'waiting'
}

type IProps = PageOwnProps

interface Index {
  props: IProps;
}

class Index extends Component {

  static options = {
    addGlobalClass: true
  }

  render() {
    const { money, result, type, className } = this.props
    let value = 'clock'
    let color = '#10AEFF'
    let message = '审核中'
    switch (result) {
      case 'success':
        value = 'check-circle'
        color = '#09BB07'
        if (type === 'recharge') {
          message = '充值成功'
        } else {
          message = '提现成功'
        }
        break;
      case 'faile':
        value = 'alert-circle'
        color = '#F76260'
        if (type === 'recharge') {
          message = '充值失败'
        } else {
          message = '提现失败'
        }
        break;

      default:
        break;
    }
    return (
      <View className={'sd-account__result ' + (className || '')}>
        {/* 头部 */}
        <View className='sd-account__result-head '>
          <AtIcon value={value} color={color} size={120} />
          <View className='sd-account__result-head-note '> {message}</View>
        </View>
        {/* 金额 */}
        <View className='sd-account__result-desc'>
          <Label >
            {type === 'recharge' ? '充值金额' : '提现金额'}
          </Label>
          <Label className='sd-account__result-money'>{money}</Label>
        </View>
      </View>
    )
  }
}

export default Index as ComponentClass<PageOwnProps>