index.jsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import Taro, { Component } from '@tarojs/taro'
  2. import { View, Image } from '@tarojs/components'
  3. import { arrToObj } from '@utils'
  4. import './index.scss'
  5. export default class List extends Component {
  6. constructor (props) {
  7. super(props)
  8. this.state = {
  9. newsList: [],
  10. }
  11. }
  12. componentWillMount () {
  13. this.props.onRef(this)
  14. }
  15. getData = (newsList) => {
  16. this.setState({
  17. newsList
  18. })
  19. }
  20. render () {
  21. const dictData = Taro.getStorageSync('dictData')
  22. const { newsList } = this.state
  23. const curItems = newsList.map((item, index) => {
  24. const product_type = item.product_type || ''
  25. const productTypeArr = product_type.split(',').map(v => {
  26. return arrToObj(dictData.product_type)[v]
  27. })
  28. const cTagStr = item.custom_tag || ''
  29. const tagViews = cTagStr.split(',').map((tag, tagIndex) => {
  30. return (
  31. <View className="s" key={tagIndex}>{tag}</View>
  32. )
  33. })
  34. return (
  35. <Navigator url={'/pagesHouse/indexDtl?id=' + item.estate_id} className="lhl-item col-1" key={index}>
  36. <View className="lhl-img">
  37. <Image src={item.pri_image + '_xs'} className="img" />
  38. </View>
  39. <View className="lhl-info">
  40. <View className="lhl-p1">{item.estate_name}</View>
  41. <View className="lhl-p2">{item.price_range || "未知"}/㎡</View>
  42. <View className="lhl-p3">{arrToObj(dictData.area_type)[item.area_type]} {productTypeArr.length > 0 ? `-${productTypeArr.join('/')}` : ''}</View>
  43. <View className="lhl-sign">
  44. {
  45. item.estate_tag === '售罄' || item.estate_tag === '二手'
  46. ? <View className="s t4">{item.estate_tag}</View>
  47. : item.estate_tag === '待售'
  48. ? <View className="s t3">{item.estate_tag}</View>
  49. : <View className="s t2">{item.estate_tag}</View>
  50. }
  51. {tagViews}
  52. </View>
  53. </View>
  54. </Navigator>
  55. )
  56. })
  57. return (
  58. <View className="l-house-list">
  59. {curItems}
  60. </View>
  61. )
  62. }
  63. }