import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
import ListMore from '@/c/pageDataList/listMore'
import { arrToObj } from '@utils'
import './index.scss'
export default class Comment extends Component {
  constructor (props) {
    super(props)
    this.state = {
      curObj: {},
    }
  }


  componentWillMount () {
    this.props.onRef(this)
  }

  getData = (curObj) => {
    this.setState({
      curObj
    })
  }


  previewImageHandle (cur, arr) {
    const current = `${cur}_plus`
    const urls = arr.map(item => {
      return `${item}_plus`
    })
    Taro.previewImage({
      current,
      urls
    })
  }


  render () {
    const { curObj } = this.state
    return (
      <View className="scoped-box">
        {
          curObj.district_img
          &&
          <View className="img-box" onClick={this.previewImageHandle.bind(this, curObj.district_img, [curObj.district_img])}>
            <Image src={curObj.district_img + '_white'} className="img"/>
            <View className="i-t">
              <View className="bg"></View>
              <View className="t">点击查看全图</View>
            </View>
          </View>
        }
        {
          curObj.school_type === '2'
          ?
          <View className="p">私立不划学区</View>
          :
          <View className="p">{curObj.district || '未知'}</View>
        }
      </View>
    )
  }
}