estateTrendRecord.jsx 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. import Taro, { Component } from '@tarojs/taro'
  2. import { View, Image, Text, Navigator } from '@tarojs/components'
  3. import { AtSearchBar } from 'taro-ui'
  4. import ListMore from '@/c/pageDataList/listMore'
  5. import './estateTrendRecord.scss'
  6. import { arrToObj } from '@utils'
  7. class Index extends Component {
  8. constructor (props) {
  9. super(props)
  10. this.state = {
  11. searchKey: '',
  12. page_size: 10,
  13. page: 1,
  14. isListEnd: false,
  15. isListLoading: false,
  16. isListEmpty: false,
  17. dataList: [],
  18. curNav: 1,
  19. isDShow: false,
  20. curObj: {},
  21. }
  22. }
  23. config = {
  24. navigationBarTitleText: '动态趋势记录',
  25. }
  26. componentWillMount () {
  27. Taro.$AHU(this)
  28. const { t } = this.$router.params
  29. Taro.setNavigationBarTitle({
  30. title: t
  31. })
  32. this.getDataList()
  33. }
  34. componentDidShow () { }
  35. componentDidHide () { }
  36. renderSearch () {
  37. const { searchKey } = this.state
  38. let placeholderText = '模糊搜索楼盘名称'
  39. return (
  40. <View>
  41. <AtSearchBar
  42. fixed={true}
  43. value={searchKey}
  44. placeholder={placeholderText}
  45. onChange={this.onSeachChange.bind(this)}
  46. onClear={this.onClearHandle.bind(this)}
  47. onActionClick={this.onSelectActionClick.bind(this)}
  48. />
  49. </View>
  50. )
  51. }
  52. onSeachChange (value) {
  53. this.setState({
  54. searchKey: value
  55. })
  56. }
  57. onClearHandle () {
  58. this.setState({
  59. searchKey: '',
  60. page: 1
  61. }, () => {
  62. this.getDataList()
  63. })
  64. }
  65. onSelectActionClick () {
  66. this.setState({
  67. page: 1,
  68. }, () => {
  69. this.getDataList()
  70. })
  71. }
  72. getDataList () {
  73. const { id } = this.$router.params
  74. let { page_size, page, dataList, isListEmpty, searchKey } = this.state
  75. Taro.api.other.apiestatehousedynamiclog({
  76. id,
  77. page,
  78. page_size,
  79. }).then(res => {
  80. const curData = res.list || []
  81. let isListEnd = false
  82. if (curData.length > 0) {
  83. if (page === 1) {
  84. dataList = curData
  85. } else {
  86. dataList = dataList.concat(curData)
  87. }
  88. if (curData.length === page_size && res.total !== curData.length) {
  89. isListEnd = false
  90. } else {
  91. isListEnd = true
  92. }
  93. }
  94. if (curData.length === 0 && page === 1) {
  95. isListEmpty = true
  96. dataList = []
  97. } else {
  98. isListEmpty = false
  99. }
  100. this.setState({
  101. dataList,
  102. isListEnd,
  103. isListEmpty,
  104. isListLoading: false
  105. })
  106. })
  107. }
  108. onScrollToLower (e) {
  109. let { isListEnd, isListLoading, page } = this.state
  110. if (!isListEnd && !isListLoading) {
  111. page++
  112. this.setState({
  113. page,
  114. isListLoading: true
  115. }, () => {
  116. this.getDataList()
  117. })
  118. }
  119. }
  120. renderList () {
  121. const dictData = Taro.getStorageSync('dictData')
  122. const ptObj = arrToObj(dictData.product_type)
  123. const { dataList, isListEnd, isListLoading, isListEmpty } = this.state
  124. const itemsList = dataList.map((item, index) => {
  125. return (
  126. <View className="sl-item" key={index}>
  127. <View>
  128. <View className="p1">[{item.create_by}]{item.create_at}</View>
  129. <View className="p-one">
  130. <View className="po-l">价格区间:</View>
  131. <View className="po-r t1">{item.price_min}元-{item.price_max}元</View>
  132. </View>
  133. <View className="p-one">
  134. <View className="po-l">最新动态:</View>
  135. <View className="po-r">
  136. {
  137. item.dynamic_img
  138. ? <Image src={item.dynamic_img} onClick={this.previewImageHandle.bind(this, item.dynamic_img)} className="img"/>
  139. : ''
  140. }
  141. {item.dynamic || '未知'}
  142. {
  143. item.isMoreShow
  144. ? <View className="por-btn" onClick={this.moreShowHideHandle.bind(this, index)}>收起</View>
  145. : <View className="por-btn" onClick={this.moreShowHideHandle.bind(this, index)}>展开</View>
  146. }
  147. </View>
  148. </View>
  149. {
  150. item.isMoreShow
  151. ?
  152. <View className="more">
  153. <View className="p-one">
  154. <View className="po-l">现场折扣:</View>
  155. <View className="po-r">{item.scene_discount || '未知'}</View>
  156. </View>
  157. <View className="p-one">
  158. <View className="po-l">实际折扣:</View>
  159. <View className="po-r">{item.actual_discount || '未知'}</View>
  160. </View>
  161. <View className="p-one">
  162. <View className="po-l">在售楼栋:</View>
  163. <View className="po-r">{item.on_sale || '未知'}</View>
  164. </View>
  165. <View className="p-one">
  166. <View className="po-l">待售楼栋:</View>
  167. <View className="po-r">{item.for_sale || '未知'}</View>
  168. </View>
  169. <View className="p-one">
  170. <View className="po-l">推荐房源:</View>
  171. <View className="po-r">{item.recommend || '未知'}</View>
  172. </View>
  173. </View>
  174. : ''
  175. }
  176. </View>
  177. </View>
  178. )
  179. })
  180. return (
  181. <ScrollView
  182. className='l-scroll-view'
  183. scrollY
  184. scrollWithAnimation
  185. scrollTop="0"
  186. lowerThreshold="30"
  187. onScrollToLower={this.onScrollToLower.bind(this)}
  188. >
  189. <View className="scoped-list">
  190. {itemsList}
  191. </View>
  192. <ListMore isListEnd={isListEnd} isListLoading={isListLoading} isListEmpty={isListEmpty} />
  193. </ScrollView>
  194. )
  195. }
  196. linkUpdate (item) {
  197. const dictData = Taro.getStorageSync('dictData')
  198. const ptObj = arrToObj(dictData.product_type)
  199. Taro.navigateTo({
  200. url: `/pagesRoom/estateTrendUpdate?id=${item.id}&t=${item.house_square}㎡-${item.estate_name}[${ptObj[item.product_type]}]`
  201. })
  202. }
  203. moreShowHideHandle (index) {
  204. let { dataList } = this.state
  205. dataList[index].isMoreShow = !dataList[index].isMoreShow
  206. this.setState({
  207. dataList
  208. })
  209. }
  210. previewImageHandle (url) {
  211. const imgUrl = url
  212. Taro.previewImage({
  213. current: imgUrl,
  214. urls: [imgUrl]
  215. })
  216. }
  217. callHandle (phoneNumber) {
  218. Taro.makePhoneCall({
  219. phoneNumber
  220. })
  221. }
  222. render () {
  223. return (
  224. <View className="l-box">
  225. {this.renderList()}
  226. </View>
  227. )
  228. }
  229. }
  230. export default Index