price.jsx 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. import Taro, { Component } from '@tarojs/taro'
  2. import { View, Image, ScrollView } from '@tarojs/components'
  3. import { AtNoticebar } from 'taro-ui'
  4. import ListMore from '@/c/pageDataList/listMore'
  5. import EchartLine from './components/price/EchartLine'
  6. import Chat from '@/c/chat/com'
  7. import LoginJudge from '@/c/login/Judge'
  8. import './price.scss'
  9. class Index extends Component {
  10. onShareAppMessage() {
  11. const {id, name} = this.$router.params
  12. return {
  13. title: `${name}的历史成交价`,
  14. path: `/pagesHouse/price?id=${id}&name=${name}`,
  15. }
  16. }
  17. onShareTimeline () {
  18. const {id, name} = this.$router.params
  19. return {
  20. title: `${name}的历史成交价`,
  21. path: `/pagesHouse/price?id=${id}&name=${name}`,
  22. }
  23. }
  24. constructor (props) {
  25. super(props)
  26. this.state = {
  27. page_size: 20,
  28. page: 1,
  29. isListEnd: false,
  30. isListLoading: false,
  31. isListEmpty: false,
  32. dataList: [],
  33. isLock: true,
  34. }
  35. }
  36. config = {
  37. navigationBarTitleText: '楼盘成交价',
  38. }
  39. componentWillMount () {
  40. Taro.$AHU(this)
  41. const {id, name } = this.$router.params
  42. Taro.setNavigationBarTitle({
  43. title: `${name}的历史成交价`
  44. })
  45. }
  46. refChat = (ref) => {
  47. this.subChat = ref
  48. }
  49. componentDidShow () {
  50. let isLock = true
  51. const edClick = Taro.getStorageSync('APP_edChat')
  52. const currentTime = Date.now()
  53. const sixHoursAgo = currentTime - (6 * 60 * 1000)
  54. if (edClick) {
  55. if (edClick <= sixHoursAgo) { // 超过时间,锁定
  56. isLock = true
  57. Taro.removeStorageSync('APP_edClick')
  58. } else {
  59. isLock = false
  60. }
  61. } else { // 锁定
  62. isLock = true
  63. }
  64. this.setState({
  65. isLock,
  66. }, () => {
  67. const {id, name } = this.$router.params
  68. this.getDataList(() => {
  69. if (this.subChat) this.subChat.getData({name, id}, 'pt')
  70. })
  71. })
  72. }
  73. componentDidHide () { }
  74. getDataList (bc) {
  75. const {id: estate_id} = this.$router.params
  76. let { page_size, page, dataList, isListEmpty, isLock } = this.state
  77. Taro.api.house.apiestatepricelist({
  78. page,
  79. page_size,
  80. estate_id
  81. }).then(res => {
  82. let lineData = []
  83. const curData = res.list || []
  84. let isListEnd = false
  85. if (curData.length > 0) {
  86. if (page === 1) {
  87. // dataList = curData
  88. dataList = isLock ? curData.splice(3) : curData
  89. lineData = JSON.parse(JSON.stringify(curData))
  90. } else {
  91. dataList = dataList.concat(curData)
  92. }
  93. if (curData.length === page_size && res.total !== curData.length) {
  94. isListEnd = false
  95. } else {
  96. isListEnd = true
  97. }
  98. }
  99. if (curData.length === 0 && page === 1) {
  100. isListEmpty = true
  101. dataList = []
  102. } else {
  103. isListEmpty = false
  104. }
  105. this.setState({
  106. dataList,
  107. isListEnd,
  108. isListEmpty,
  109. isListLoading: false
  110. })
  111. if (lineData.length > 0) {
  112. if (this.subLine) this.subLine.getData(lineData.reverse() || [])
  113. }
  114. if (bc) bc()
  115. })
  116. }
  117. onScrollToLower (e) {
  118. let { isListEnd, isListLoading, page } = this.state
  119. if (!isListEnd && !isListLoading) {
  120. page++
  121. this.setState({
  122. page,
  123. isListLoading: true
  124. }, () => {
  125. this.getDataList()
  126. })
  127. }
  128. }
  129. renderList () {
  130. const iconLock = require('@img/icon_g_lock.png')
  131. const { dataList, isListEnd, isListLoading, isListEmpty, isLock } = this.state
  132. const {id, name} = this.$router.params
  133. const itemsList = dataList.map((item, index) => {
  134. const FH = Number(item.cur_layer) || 1
  135. const H = Number(item.layer) || 1
  136. let FHstr = FH
  137. if (item.company === '贝壳') {
  138. if (FH > H * 0.6666) {
  139. FHstr = '中高层'
  140. } else if (FH > H * 0.33333) {
  141. FHstr = '中楼层'
  142. } else {
  143. FHstr = '中低层'
  144. }
  145. if (FH === 1) FHstr = '低层'
  146. if (FH === H) FHstr = '高层'
  147. }
  148. return (
  149. <View className="sl-item" key={index}>
  150. {
  151. item.cur_layer > 0 && item.layer > 0
  152. ?
  153. <View className="sl-p1">{FHstr}/{H}层<View className="s">{item.estate_name}</View></View>
  154. :
  155. <View className="sl-p1"><View className="s">{item.estate_name}</View></View>
  156. }
  157. <View className="sl-p2">
  158. <View className="op">
  159. <View className="k">总面积</View>
  160. <View className="v">{item.area}㎡</View>
  161. </View>
  162. <View className="op t2">
  163. <View className="k">单价</View>
  164. <View className="v">{item.unit_price}元/㎡</View>
  165. </View>
  166. </View>
  167. <View className="sl-p3">签约中介:{item.company}</View>
  168. <View className="sl-p3">签约日期:{item.sign_at}</View>
  169. <View className="sl-r1"><View className="n">{item.price}</View>万</View>
  170. </View>
  171. )
  172. })
  173. return (
  174. <ScrollView
  175. className='l-scroll-view'
  176. scrollY
  177. scrollWithAnimation
  178. scrollTop="0"
  179. lowerThreshold="30"
  180. onScrollToLower={this.onScrollToLower.bind(this)}
  181. >
  182. <View className="scoped-list">
  183. <Navigator url={`/pagesHouse/priceChart?id=${id}&name=${name}`} className="sl-top-tips">查看图表分析{'>>'}</Navigator>
  184. <AtNoticebar icon='volume-plus'>查询结果仅供参考</AtNoticebar>
  185. {
  186. isLock
  187. ?
  188. <View className="sl-item dis">
  189. <View className="slid-tips" onClick={this.unlockHandle.bind(this)}>
  190. <Image className="icon" src={iconLock}></Image>
  191. <View className="t">最新成交价,点击咨询解锁</View>
  192. </View>
  193. <View className="slid-main">
  194. <View className="sl-p1">**/**层<View className="s">******</View></View>
  195. <View className="sl-p2">
  196. <View className="op">
  197. <View className="k">总面积</View>
  198. <View className="v">*****㎡</View>
  199. </View>
  200. <View className="op t2">
  201. <View className="k">单价</View>
  202. <View className="v">******元/㎡</View>
  203. </View>
  204. </View>
  205. <View className="sl-p3">签约中介:**********</View>
  206. <View className="sl-p3">签约日期:**********</View>
  207. <View className="sl-r1"><View className="n">***</View>万</View>
  208. </View>
  209. </View>
  210. : ''
  211. }
  212. {itemsList}
  213. </View>
  214. <ListMore isListEnd={isListEnd} isListLoading={isListLoading} isListEmpty={isListEmpty} />
  215. {/* {this.renderLine()} */}
  216. </ScrollView>
  217. )
  218. }
  219. unlockHandle () {
  220. const currentTime = Date.now()
  221. Taro.setStorageSync('APP_edChat', currentTime)
  222. this.subChat.countHandle('chat')
  223. }
  224. renderTop () {
  225. const { name } = this.$router.params
  226. const bg = require('./img/bg_house.jpg')
  227. return (
  228. <View className="scoped-bg-top">
  229. <View className="sbt-wrap" onClick={this.urlDtlLink.bind(this)}>
  230. <View className="t">{name}</View>
  231. <Image src={bg} className="bg"></Image>
  232. </View>
  233. </View>
  234. )
  235. }
  236. urlDtlLink () {
  237. const { id } = this.$router.params
  238. Taro.navigateTo({url: '/pagesHouse/indexDtl?id=' + id})
  239. }
  240. renderLine () {
  241. const { dataList } = this.state
  242. const {id, name} = this.$router.params
  243. return (
  244. <Navigator url={`/pagesHouse/priceChart?id=${id}&name=${name}`} className="l-area-box">
  245. <View className="lab-title">近20次成交单价
  246. <View className="lab-title-right t2">更多图表分析{'>'}</View>
  247. </View>
  248. <View className="lab-chart">
  249. <EchartLine curData={dataList} onRef={this.refLine} />
  250. </View>
  251. </Navigator>
  252. )
  253. }
  254. refLine = (ref) => {
  255. this.subLine = ref
  256. }
  257. renderFooter () {
  258. const bg = require('./img/price/bg_more.png')
  259. return (
  260. <Navigator url="/pagesHouse/list?type=成交价&name=选择楼盘查成交价" className="scoped-footer">
  261. <Image src={bg} className='bg' />
  262. </Navigator>
  263. )
  264. }
  265. render () {
  266. return (
  267. <View className="l-box">
  268. <LoginJudge />
  269. {this.renderTop()}
  270. {this.renderList()}
  271. <Chat onRef={this.refChat} />
  272. {/* {this.renderFooter()} */}
  273. </View>
  274. )
  275. }
  276. }
  277. export default Index