import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import { arrToObj } from '@utils'
import Comment from './components/indexDtl/comment'
import House from './components/indexDtl/house'
import HouseGh from './components/indexDtl/houseGh'
import Range from './components/indexDtl/range'
import './indexDtl.scss'
class Index extends Component {
onShareAppMessage() {
const { curId, curObj } = this.state
return {
title: `来看看${curObj.school_name}周边的房子有哪些?`,
path: `/pagesSchool/indexDtl?id=${curId}`,
}
}
onShareTimeline () {
return {
title: '让买房,更省心!',
}
}
constructor (props) {
super(props)
const {id: curId} = this.$router.params
this.state = {
curId,
curObj: {},
}
}
config = {
navigationBarTitleText: '学校详情',
}
componentWillMount () {
this.getDtl()
}
getDtl = () => {
const { curId } = this.state
Taro.api.house.admschooldetail({id: curId}).then(res => {
this.subComment.getData(res || {})
if (res.estate_list && res.estate_list.duikou && res.estate_list.duikou.length >0 && this.subHouse) this.subHouse.getData(res.estate_list.duikou)
if (res.estate_list && res.estate_list.guihua && res.estate_list.guihua.length >0 && this.subGhHouse) this.subGhHouse.getData(res.estate_list.guihua)
this.subRange.getData(res || {})
this.setState({
curObj: res || {}
})
})
}
componentDidShow () { }
componentDidHide () { }
renderHeader () {
const { curObj } = this.state
const iconHouse = require('@img/images/i_house.png')
const iconPos = require('@img/images/i_pos.png')
const imgUrl = `${curObj.pri_image}_white`
const dictData = Taro.getStorageSync('dictData')
return (
{curObj.school_name}
{curObj.address}
{arrToObj(dictData.school_attrib)[curObj.school_attrib]}
{arrToObj(dictData.school_type)[curObj.school_type]}
{arrToObj(dictData.school_warn)[curObj.school_warn]}
)
}
renderRange () {
return (
学区范围
)
}
refRange = (ref) => {
this.subRange = ref
}
renderRemarked () {
const { curObj } = this.state
return (
学校简评
{curObj.remarked}
)
}
renderAchievement () {
const { curObj } = this.state
return (
历年成绩
{curObj.achievement}
)
}
renderOptionsHouse () {
const { curId, curObj } = this.state
const estateList = curObj.estate_list || {}
return (
对口楼盘
注:目前该楼盘在此学区中
{
estateList.duikou && estateList.duikou.length > 0
&&
对口所有楼盘{'>'}
}
)
}
refHouse = (ref) => {
this.subHouse = ref
}
renderOptionsGhHouse () {
const { curId, curObj } = this.state
const estateList = curObj.estate_list || {}
return (
可能就读
注:未来该楼盘有可能划入该学校
{
estateList.guihua && estateList.guihua.length > 0
&&
规划就读所有楼盘{'>'}
}
)
}
refGhHouse = (ref) => {
this.subGhHouse = ref
}
renderOptionsInfo () {
const { curObj } = this.state
return (
学校信息
建设时间
2018年
竣工时间
2021年5月
占地面积
16800
建筑面积
68000
)
}
renderGoHome () {
const icon = require('@img/images/icon_go_home.png')
return (
)
}
linkHome () {
Taro.reLaunch({
url: '/pages/index/index'
})
}
renderComment () {
const { curObj } = this.state
return (
大家怎么看
查看更多{' >'}
)
}
refComment = (ref) => {
this.subComment = ref
}
render () {
const { curId, curObj } = this.state
return (
{this.renderHeader()}
{this.renderRange()}
{
curObj.remarked
&&
this.renderRemarked()
}
{
curObj.achievement
&&
this.renderAchievement()
}
{this.renderOptionsHouse()}
{this.renderOptionsGhHouse()}
{this.renderComment()}
{this.renderGoHome()}
)
}
}
export default Index