area.jsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import Taro, { Component } from '@tarojs/taro'
  2. import { View } from '@tarojs/components'
  3. import Footer from '@/c/footer'
  4. import hlSign from '@/c/hlSign'
  5. import './area.scss'
  6. import { arrToObj } from '@utils'
  7. class Index extends Component {
  8. onShareAppMessage() {
  9. return {
  10. title: `来看看南昌各个区域有哪些学校`,
  11. }
  12. }
  13. onShareTimeline () {
  14. return {
  15. title: `来看看南昌各个区域有哪些学校,洪楼告诉你哪些楼盘可以读`,
  16. }
  17. }
  18. constructor (props) {
  19. super(props)
  20. const {id: curId} = this.$router.params
  21. this.state = {
  22. curId,
  23. curObj: {},
  24. cateArr: []
  25. }
  26. }
  27. config = {
  28. navigationBarTitleText: '选择区域',
  29. }
  30. componentWillMount () {
  31. Taro.$AHU(this)
  32. Taro.api.house.schoolareacount().then(res => {
  33. this.setState({
  34. cateArr: res || []
  35. })
  36. })
  37. }
  38. renderOp () {
  39. const bg1 = require('./img/area/xq01.png')
  40. const bg2 = require('./img/area/xq02.png')
  41. const bg3 = require('./img/area/xq03.png')
  42. const bg4 = require('./img/area/xq04.png')
  43. const bg5 = require('./img/area/xq05.png')
  44. const bg6 = require('./img/area/xq06.png')
  45. const { cateArr } = this.state
  46. const dictData = Taro.getStorageSync('dictData')
  47. const atObj = arrToObj(dictData.area_type)
  48. let total = 0
  49. const cArr = cateArr.map((item, i) => {
  50. total += item.total
  51. let bg = bg1
  52. if (i % 6 === 0) bg = bg2
  53. if (i % 6 === 1) bg = bg3
  54. if (i % 6 === 2) bg = bg4
  55. if (i % 6 === 3) bg = bg5
  56. if (i % 6 === 4) bg = bg6
  57. if (i % 6 === 5) bg = bg1
  58. return {
  59. bg,
  60. ...item,
  61. key: atObj[item.area_type]
  62. }
  63. })
  64. const curItems = cArr.map((item, index) => {
  65. return (
  66. <View className="sb-item" key={index} onClick={this.listLink.bind(this, item)}>
  67. <View className="t">{item.key}({item.total || 0})</View>
  68. <Image src={item.bg} className="bg"/>
  69. </View>
  70. )
  71. })
  72. return (
  73. <View className="scoped-box">
  74. <View className="sb-item" key={index} onClick={this.listLink.bind(this, 'all')}>
  75. <View className="t">全部区域({total || 0})</View>
  76. <Image src={bg1} className="bg"/>
  77. </View>
  78. {curItems}
  79. </View>
  80. )
  81. }
  82. listLink (item) {
  83. if (item === 'all') {
  84. Taro.navigateTo({
  85. url: `/pagesSchool/index`
  86. })
  87. } else {
  88. Taro.navigateTo({
  89. url: `/pagesSchool/index?areaType=${item.area_type}&areaName=${item.key}`
  90. })
  91. }
  92. }
  93. componentDidShow () { }
  94. componentDidHide () { }
  95. renderShare () {
  96. const iconShare = require('@img/images/icon_g_share6.png')
  97. return (
  98. <Button className="g-icon-share btn-to-div" openType="share">
  99. <Image className="img" src={iconShare} />
  100. </Button>
  101. )
  102. }
  103. render () {
  104. const xqbanner = require('./img/xqbanner2.jpg')
  105. return (
  106. <View className="l-box has-footer">
  107. <Navigator url={'/pagesOther/map/dtl'} className="scoped-top">
  108. <Image src={xqbanner} className="bg" />
  109. </Navigator>
  110. <hlSign />
  111. {this.renderOp()}
  112. {this.renderShare()}
  113. <Footer current={1} />
  114. </View>
  115. )
  116. }
  117. }
  118. export default Index