import { View, Block } from "@tarojs/components";
import './index.scss'

export default function ConsultantItem(props) {

  const { data = {}, style, type, tips } = props
  const handleHomepage = (e) => {
    e.stopPropagation()
    if (props.onHomepage) {
      props.onHomepage()
    }
  }
  return (
    <Block>
      {(!data || !data.id) && tips == 'show' && (<View style="margin-top: 20px; text-align: center">暂无数据</View>)}
      {
        (data && (data.id || data.consultantPersonId)) &&
        (
          <View className="card-item" style={style} onClick={() => props.onClick && props.onClick(data)}>

            <View className="flex-info" >
              <Image src={data.photo || data.avatar} className='avatar' ></Image>
              <View>
                {
                  (data.name || data.userName) &&
                  <View className="name">
                    {data.name || data.userName}
                    <Image src={require('@/assets/person/card.png')} className='card' ></Image>
                    {type == 'raiseProfile' && <View className="tip">您的专属置业顾问</View>}
                  </View>
                }
                <View className="phone">{data.phone}</View>
              </View>
            </View>

            {!type && <View className="home" onClick={handleHomepage}>主页</View>}
            {type == 'raiseProfile' && <View className="contact" onClick={props.contactClick}>联系我<Text className="right-icon"></Text></View>}
          </View >
        )
      }
    </Block>
  )
}
