indexDtl.jsx 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. import Taro, { Component } from '@tarojs/taro'
  2. import { View } from '@tarojs/components'
  3. import { arrToObj } from '@utils'
  4. import Comment from './components/indexDtl/comment'
  5. import House from './components/indexDtl/house'
  6. import HouseGh from './components/indexDtl/houseGh'
  7. import Range from './components/indexDtl/range'
  8. import './indexDtl.scss'
  9. class Index extends Component {
  10. onShareAppMessage() {
  11. const { curId, curObj } = this.state
  12. return {
  13. title: `来看看${curObj.school_name}周边的房子有哪些?`,
  14. path: `/pagesSchool/indexDtl?id=${curId}`,
  15. }
  16. }
  17. onShareTimeline () {
  18. return {
  19. title: '让买房,更省心!',
  20. }
  21. }
  22. constructor (props) {
  23. super(props)
  24. const {id: curId} = this.$router.params
  25. this.state = {
  26. curId,
  27. curObj: {},
  28. }
  29. }
  30. config = {
  31. navigationBarTitleText: '学校详情',
  32. }
  33. componentWillMount () {
  34. this.getDtl()
  35. }
  36. getDtl = () => {
  37. const { curId } = this.state
  38. Taro.api.house.admschooldetail({id: curId}).then(res => {
  39. this.subComment.getData(res || {})
  40. if (res.estate_list && res.estate_list.duikou && res.estate_list.duikou.length >0 && this.subHouse) this.subHouse.getData(res.estate_list.duikou)
  41. if (res.estate_list && res.estate_list.guihua && res.estate_list.guihua.length >0 && this.subGhHouse) this.subGhHouse.getData(res.estate_list.guihua)
  42. this.subRange.getData(res || {})
  43. this.setState({
  44. curObj: res || {}
  45. })
  46. })
  47. }
  48. componentDidShow () { }
  49. componentDidHide () { }
  50. renderHeader () {
  51. const { curObj } = this.state
  52. const iconHouse = require('@img/images/i_house.png')
  53. const iconPos = require('@img/images/i_pos.png')
  54. const imgUrl = `${curObj.pri_image}_white`
  55. const dictData = Taro.getStorageSync('dictData')
  56. return (
  57. <View className="dtl-header">
  58. <View className="dh-content">
  59. <View className="dh-p1">
  60. <Image className="i" src={iconHouse} />
  61. <View className="t">{curObj.school_name}</View>
  62. </View>
  63. <View className="dh-p2">
  64. <Image className="i" src={iconPos} />
  65. <View className="t">{curObj.address}</View>
  66. </View>
  67. <View className="dh-sign">
  68. <View className="s">{arrToObj(dictData.school_attrib)[curObj.school_attrib]}</View>
  69. <View className="s t4">{arrToObj(dictData.school_type)[curObj.school_type]}</View>
  70. <View className={'st t' + curObj.school_warn}>{arrToObj(dictData.school_warn)[curObj.school_warn]}</View>
  71. </View>
  72. </View>
  73. <Image className="dh-bg" src={imgUrl} mode="aspectFit" />
  74. </View>
  75. )
  76. }
  77. renderRange () {
  78. return (
  79. <View className="dtl-options scoped-school">
  80. <View className="do-title">
  81. <View className="t">学区范围</View>
  82. </View>
  83. <Range onRef={this.refRange} />
  84. </View>
  85. )
  86. }
  87. refRange = (ref) => {
  88. this.subRange = ref
  89. }
  90. renderRemarked () {
  91. const { curObj } = this.state
  92. return (
  93. <View className="dtl-options scoped-school">
  94. <View className="do-title">
  95. <View className="t">学校简评</View>
  96. </View>
  97. <View className="do-content">
  98. <View className="scoped-desc">{curObj.remarked}</View>
  99. </View>
  100. </View>
  101. )
  102. }
  103. renderAchievement () {
  104. const { curObj } = this.state
  105. return (
  106. <View className="dtl-options scoped-school">
  107. <View className="do-title">
  108. <View className="t">历年成绩</View>
  109. </View>
  110. <View className="do-content">
  111. <View className="scoped-desc">{curObj.achievement}</View>
  112. </View>
  113. </View>
  114. )
  115. }
  116. renderOptionsHouse () {
  117. const { curId, curObj } = this.state
  118. const estateList = curObj.estate_list || {}
  119. return (
  120. <View className="dtl-options scoped-school">
  121. <View className="do-title">
  122. <View className="t">对口楼盘</View>
  123. <View className="r2">注:目前该楼盘在此学区中</View>
  124. {
  125. estateList.duikou && estateList.duikou.length > 0
  126. &&
  127. <Navigator url={'/pagesSchool/houseList?id=' + curId + '&name=' + curObj.school_name} className="r">对口所有楼盘{'>'}</Navigator>
  128. }
  129. </View>
  130. <House onRef={this.refHouse} />
  131. </View>
  132. )
  133. }
  134. refHouse = (ref) => {
  135. this.subHouse = ref
  136. }
  137. renderOptionsGhHouse () {
  138. const { curId, curObj } = this.state
  139. const estateList = curObj.estate_list || {}
  140. return (
  141. <View className="dtl-options scoped-school">
  142. <View className="do-title">
  143. <View className="t">可能就读</View>
  144. <View className="r2">注:未来该楼盘有可能划入该学校</View>
  145. {
  146. estateList.guihua && estateList.guihua.length > 0
  147. &&
  148. <Navigator url={'/pagesSchool/houseList?id=' + curId + '&name=' + curObj.school_name} className="r">规划就读所有楼盘{'>'}</Navigator>
  149. }
  150. </View>
  151. <HouseGh onRef={this.refGhHouse} />
  152. </View>
  153. )
  154. }
  155. refGhHouse = (ref) => {
  156. this.subGhHouse = ref
  157. }
  158. renderOptionsInfo () {
  159. const { curObj } = this.state
  160. return (
  161. <View className="dtl-options">
  162. <View className="do-title">
  163. <View className="t">学校信息</View>
  164. </View>
  165. <View className="do-content">
  166. <View className="do-p">
  167. <View className="k">建设时间</View>
  168. <View className="v">2018年</View>
  169. </View>
  170. <View className="do-p">
  171. <View className="k">竣工时间</View>
  172. <View className="v">2021年5月</View>
  173. </View>
  174. <View className="do-p">
  175. <View className="k">占地面积</View>
  176. <View className="v">16800</View>
  177. </View>
  178. <View className="do-p">
  179. <View className="k">建筑面积</View>
  180. <View className="v">68000</View>
  181. </View>
  182. </View>
  183. </View>
  184. )
  185. }
  186. renderGoHome () {
  187. const icon = require('@img/images/icon_go_home.png')
  188. return (
  189. <Image className="g-go-home" src={icon} onClick={this.linkHome.bind(this)}/>
  190. )
  191. }
  192. linkHome () {
  193. Taro.reLaunch({
  194. url: '/pages/index/index'
  195. })
  196. }
  197. renderComment () {
  198. const { curObj } = this.state
  199. return (
  200. <View className="dtl-options">
  201. <View className="do-title">
  202. <View className="t">大家怎么看</View>
  203. <Navigator url={'/pagesMore/comment/list?id=' + curObj.id + '&name=' + curObj.school_name + '&type=school'} className="r">查看更多{' >'}</Navigator>
  204. </View>
  205. <Comment onRef={this.refComment} getDtl={this.getDtl.bind(this)} />
  206. </View>
  207. )
  208. }
  209. refComment = (ref) => {
  210. this.subComment = ref
  211. }
  212. render () {
  213. const { curId, curObj } = this.state
  214. return (
  215. <View className="l-box">
  216. {this.renderHeader()}
  217. {this.renderRange()}
  218. <View className="scoped-bg">
  219. {
  220. curObj.remarked
  221. &&
  222. this.renderRemarked()
  223. }
  224. {
  225. curObj.achievement
  226. &&
  227. this.renderAchievement()
  228. }
  229. {this.renderOptionsHouse()}
  230. {this.renderOptionsGhHouse()}
  231. {this.renderComment()}
  232. </View>
  233. {this.renderGoHome()}
  234. </View>
  235. )
  236. }
  237. }
  238. export default Index