import { ComponentClass } from 'react'
import Taro, { Component } from '@tarojs/taro'
import { View, Image, Text, Label } from '@tarojs/components'
import './index.scss'
import SdFormid from '../sdFormid';
interface DataInterface {
  headimgurl: string
  nickName: string
}
type PageOwnProps = {
  className?: string
  data: DataInterface
  hasRedpacket?: boolean
  money?: any
  number?: any
  onImageClick?: any
  onRedpacketUsersClick?: any
}


type IProps = PageOwnProps

interface Index {
  props: IProps;
}

class Index extends Component {
  static options = {
    addGlobalClass: true
  }
  handleClick = () => {
    this.props.onRedpacketUsersClick()
  }
  render() {
    const ownerInfo = this.props.data || {}
    const { hasRedpacket, money, number } = this.props
    return (
      <View className={'sd-owner-info ' + (this.props.className || '') + (hasRedpacket ? ' sd-owner-info-got-money' : '')}>
        <View className='sd-owner-info-body'>
          <Image className='sd-owner-info-avatar' src={ownerInfo.headimgurl}></Image>
          <View className='sd-owner-info-name'>{ownerInfo.nickName} </View>
          <View className='sd-owner-info-zhenshi'>
            <Image className='sd-owner-info-zhenshi-icon' src='http://ft-image.oss-cn-beijing.aliyuncs.com/059.png'></Image>
            <Text>真实屋主</Text>
          </View>
        </View>
        {
          hasRedpacket &&
          <SdFormid onClick={this.handleClick}>
            <View className='sd-owner-info-footer'>
              已有 <Label className='sd-owner-info-red'>{number}人</Label> 领取 <Label className='sd-owner-info-red'>{money}</Label>  元现金红包
          </View>
          </SdFormid>
        }
      </View>
    )
  }
}

export default Index as ComponentClass<PageOwnProps>