import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
import './roomPriceList.scss'

class Index extends Component {
  onShareAppMessage() {
    const {eId, name} = this.$router.params
    return {
      title: `来看看${name}的往期摇号`,
      path: `/pagesHouse/roomPriceList?eId=${eId}&name=${name}`,
    }
  }
  onShareTimeline () {
    const {eId, name} = this.$router.params
    return {
      title: `来看看${name}的往期摇号`,
      path: `/pagesHouse/roomPriceList?eId=${eId}&name=${name}`,
    }
  }
  
  constructor (props) {
    super(props)
    this.state = {
      dataList: [],
    }
  }

  config = {
    navigationBarTitleText: '往期摇号',
  }

  componentDidMount () {
    const { eId } = this.$router.params
    Taro.api.house.apiestatelottery2batchlist({
      estate_id: eId,
    }).then(res => {
      this.setState({
        dataList: res.list || []
      })
    })
  }

  renderList () {
    const { eId, id, name } = this.$router.params
    const { dataList } = this.state
    const curItems = dataList.map((item, index) => {
      return (
        <Navigator url={`/pagesHouse/roomPrice?eId=${eId}&id=${id}&name=${name}`} className="sl-item" key={index}>
          <View className="p1">{item.under_way}</View>
          <View className="p2">摇号时间：{item.lottery_time}</View>
          <View className="p3">查看明细{'>>'}</View>
        </Navigator>
      )
    })
    return (
      <View className="scoped-list">
        {curItems}
      </View>
    )
  }


  render () {
    return (
      <View className="l-box">
        {this.renderList()}
      </View>
    )
  }
}

export default Index
