pkDtl.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. import Taro, { Component } from '@tarojs/taro'
  2. import { View, Map } from '@tarojs/components'
  3. import { arrToObj } from '@utils'
  4. import './pkDtl.scss'
  5. class Index extends Component {
  6. onShareAppMessage() {
  7. const { pkArr } = this.state
  8. let idArr = []
  9. const nameArr = pkArr.map(item => {
  10. idArr.push(item.id)
  11. return item.estate_name
  12. })
  13. return {
  14. title: `${nameArr.join('vs')}-楼盘对比`,
  15. path: `/pagesHouse/pkDtl?id=${idArr.join(',')}`,
  16. }
  17. }
  18. onShareTimeline () {
  19. return {
  20. title: '让买房,更省心!',
  21. }
  22. }
  23. constructor (props) {
  24. super(props)
  25. this.state = {
  26. pkArr: [],
  27. }
  28. }
  29. config = {
  30. navigationBarTitleText: '楼盘PK',
  31. }
  32. componentWillMount () {
  33. const {id} = this.$router.params
  34. if (id) {
  35. const idArr = id.split(',') || []
  36. let tempArr = []
  37. idArr.forEach(cId => {
  38. tempArr.push(
  39. new Promise((resolve, reject) => {
  40. Taro.api.house.admestatesimple({id: cId}).then(res => {
  41. return resolve(res)
  42. }).catch(err => {
  43. return reject(err)
  44. })
  45. })
  46. )
  47. })
  48. Promise.all(tempArr).then(res => {
  49. if (res && res.length > 0 && !Taro.getStorageSync('APP_pkList')) Taro.setStorageSync('APP_pkList', res)
  50. this.setState({
  51. pkArr: res || []
  52. })
  53. })
  54. } else {
  55. this.getDtl()
  56. }
  57. }
  58. renderTop () {
  59. const bg = require('./img/pk/bg.jpg')
  60. const { pkArr } = this.state
  61. return (
  62. <View className="pk-header">
  63. <View className="scoped-bg" onClick={this.previewQrcodeImageHandle.bind(this)}>
  64. <Image src={bg} className="bg" />
  65. </View>
  66. <View className="ph-main">
  67. {
  68. pkArr.map((item, index) => {
  69. return (
  70. <View className="ph-item" key={index}>
  71. <View className="ph-name">
  72. <View className="t">{item.estate_name}</View>
  73. </View>
  74. <View className="ph-content">
  75. <Image src={item.pri_image} className="ph-img" />
  76. </View>
  77. </View>
  78. )
  79. })
  80. }
  81. </View>
  82. </View>
  83. )
  84. }
  85. getDtl = (data) => {
  86. const { i } = this.$router.params
  87. const iArr = i.split(',')
  88. const pkList = data || Taro.getStorageSync('APP_pkList') || []
  89. let pkArr = iArr.map(i => {
  90. return pkList[i]
  91. })
  92. this.setState({
  93. pkArr
  94. })
  95. }
  96. componentDidShow () { }
  97. componentDidHide () { }
  98. previewImageHandle (cur, arr) {
  99. const current = `${cur}_plus`
  100. const urls = arr.map(item => {
  101. return `${item.img_url}_plus`
  102. })
  103. Taro.previewImage({
  104. current,
  105. urls
  106. })
  107. }
  108. previewQrcodeImageHandle (current, urls) {
  109. Taro.previewImage({
  110. current: 'http://icon.honglounews.com/miniqrcode.jpg',
  111. urls: ['http://icon.honglounews.com/miniqrcode.jpg']
  112. })
  113. }
  114. linkHome () {
  115. Taro.reLaunch({
  116. url: '/pages/index/index'
  117. })
  118. }
  119. renderGoHome () {
  120. const icon = require('@img/images/icon_go_home.png')
  121. return (
  122. <Image className="g-go-home" src={icon} onClick={this.linkHome.bind(this)}/>
  123. )
  124. }
  125. render () {
  126. const dictData = Taro.getStorageSync('dictData')
  127. const saObj = arrToObj(dictData.school_attrib)
  128. const mlObj = arrToObj(dictData.metro_line)
  129. const mtObj = arrToObj(dictData.metro_type)
  130. const { pkArr } = this.state
  131. const pk0Obj = pkArr[0] || {}
  132. const pk1Obj = pkArr[1] || {}
  133. let metroLineStr0 = ''
  134. if (pk0Obj.metro_line) {
  135. const ml0Arr = pk0Obj.metro_line.split(',')
  136. const ml0Str = ml0Arr.map(v => {
  137. return mlObj[v]
  138. })
  139. metroLineStr0 = ml0Str.join(',')
  140. }
  141. let metroLineStr1 = ''
  142. if (pk1Obj.metro_line) {
  143. const ml1Arr = pk1Obj.metro_line.split(',')
  144. const ml1Str = ml1Arr.map(v => {
  145. return mlObj[v]
  146. })
  147. metroLineStr1 = ml1Str.join(',')
  148. }
  149. let metroTypeStr0 = ''
  150. if (pk0Obj.metro_type) {
  151. const mt0Arr = pk0Obj.metro_type.split(',')
  152. const mt0Str = mt0Arr.map(v => {
  153. return mtObj[v]
  154. })
  155. metroTypeStr0 = mt0Str.join(',')
  156. }
  157. let metroTypeStr1 = ''
  158. if (pk1Obj.metro_type) {
  159. const mt1Arr = pk1Obj.metro_type.split(',')
  160. const mt1Str = mt1Arr.map(v => {
  161. return mtObj[v]
  162. })
  163. metroTypeStr1 = mt1Str.join(',')
  164. }
  165. let pk0SchoolStr = ''
  166. const school0list = pk0Obj.school_list || {duikou: [], guihua: []}
  167. const sl0Arr = [...school0list.duikou, ...school0list.guihua]
  168. if (sl0Arr && sl0Arr.length > 0) {
  169. const schoolStr0 = sl0Arr.map(item => {
  170. return `(${saObj[item.school_attrib]})${item.school_name}`
  171. })
  172. pk0SchoolStr = schoolStr0.join(';')
  173. }
  174. let pk1SchoolStr = ''
  175. const school1list = pk1Obj.school_list || {duikou: [], guihua: []}
  176. const slArr = [...school1list.duikou, ...school1list.guihua]
  177. if (slArr && slArr.length > 0) {
  178. const schoolStr1 = slArr.map(item => {
  179. return `(${saObj[item.school_attrib]})${item.school_name}`
  180. })
  181. pk1SchoolStr = schoolStr1.join(';')
  182. }
  183. const product_type0 = pk0Obj.product_type || ''
  184. const productTypeArr0 = product_type0.split(',').map(v => {
  185. return arrToObj(dictData.product_type)[v]
  186. })
  187. const product_type1 = pk1Obj.product_type || ''
  188. const productTypeArr1 = product_type1.split(',').map(v => {
  189. return arrToObj(dictData.product_type)[v]
  190. })
  191. const iconShare = require('./img/pk/i2.png')
  192. return (
  193. <View className="l-box">
  194. {this.renderTop()}
  195. <View className="pk-ops">
  196. <View className="po-item">
  197. <View className="po-p1">基本信息</View>
  198. </View>
  199. <View className="po-item">
  200. <View className="po-v tar">{arrToObj(dictData.estate_tag)[pk0Obj.estate_tag]}</View>
  201. <View className="po-label">楼盘状态</View>
  202. <View className="po-v">{arrToObj(dictData.estate_tag)[pk1Obj.estate_tag]}</View>
  203. </View>
  204. <View className="po-item">
  205. <View className="po-v tar">{pk0Obj.price_range}/㎡</View>
  206. <View className="po-label">参考价格</View>
  207. <View className="po-v">{pk1Obj.price_range}/㎡</View>
  208. </View>
  209. <View className="po-item">
  210. <View className="po-v tar">{arrToObj(dictData.area_type)[pk0Obj.area_type]}</View>
  211. <View className="po-label">所属区域</View>
  212. <View className="po-v">{arrToObj(dictData.area_type)[pk1Obj.area_type]}</View>
  213. </View>
  214. <View className="po-item">
  215. <View className="po-v tar">{productTypeArr0.length > 0 ? `${productTypeArr0.join('/')}` : ''}</View>
  216. <View className="po-label">产品类型</View>
  217. <View className="po-v">{productTypeArr1.length > 0 ? `${productTypeArr1.join('/')}` : ''}</View>
  218. </View>
  219. <View className="po-item">
  220. <View className="po-v tar">{pk0Obj.built_area}㎡</View>
  221. <View className="po-label">面积户型</View>
  222. <View className="po-v">{pk1Obj.built_area}㎡</View>
  223. </View>
  224. {/* <View className="po-item">
  225. <View className="po-v tar">{pk0Obj.stairs_rate}</View>
  226. <View className="po-label">梯户比</View>
  227. <View className="po-v">{pk1Obj.stairs_rate}</View>
  228. </View> */}
  229. <View className="po-item">
  230. <View className="po-v tar">{pk0Obj.household}</View>
  231. <View className="po-label">总户数</View>
  232. <View className="po-v">{pk1Obj.household}</View>
  233. </View>
  234. <View className="po-item">
  235. <View className="po-v tar">{pk0Obj.parking}</View>
  236. <View className="po-label">车位数</View>
  237. <View className="po-v">{pk1Obj.parking}</View>
  238. </View>
  239. <View className="po-item">
  240. <View className="po-v tar">{pk0Obj.green_rate}%</View>
  241. <View className="po-label">绿化率</View>
  242. <View className="po-v">{pk1Obj.green_rate}%</View>
  243. </View>
  244. <View className="po-item">
  245. <View className="po-v tar">{pk0Obj.plot_ratio}</View>
  246. <View className="po-label">容积率</View>
  247. <View className="po-v">{pk1Obj.plot_ratio}</View>
  248. </View>
  249. <View className="po-item">
  250. <View className="po-v tar">{pk0Obj.deliver_time}</View>
  251. <View className="po-label">初次交付</View>
  252. <View className="po-v">{pk1Obj.deliver_time}</View>
  253. </View>
  254. </View>
  255. <View className="pk-ops t2">
  256. <View className="po-item">
  257. <View className="po-p1">物业配套</View>
  258. </View>
  259. <View className="po-item">
  260. <View className="po-v tar">{pk0Obj.property_fee || '0'}元</View>
  261. <View className="po-label">物业费</View>
  262. <View className="po-v">{pk1Obj.property_fee || '0'}元</View>
  263. </View>
  264. <View className="po-item">
  265. <View className="po-v tar">{pk0Obj.property_type}</View>
  266. <View className="po-label">物业公司</View>
  267. <View className="po-v">{pk1Obj.property_type}</View>
  268. </View>
  269. <View className="po-item">
  270. <View className="po-v tar">{pk0SchoolStr}</View>
  271. <View className="po-label">对口学校</View>
  272. <View className="po-v">{pk1SchoolStr}</View>
  273. </View>
  274. <View className="po-item">
  275. <View className="po-v tar">{metroLineStr0}</View>
  276. <View className="po-label">地铁线</View>
  277. <View className="po-v">{metroLineStr1}</View>
  278. </View>
  279. <View className="po-item">
  280. <View className="po-v tar">{metroTypeStr0}</View>
  281. <View className="po-label">地铁站</View>
  282. <View className="po-v">{metroTypeStr1}</View>
  283. </View>
  284. <View className="po-item">
  285. <Navigator url={'/pagesHouse/indexDtl?id=' + pk0Obj.id} className="po-v tar link">
  286. <View className="b">查看更多</View>
  287. </Navigator>
  288. <View className="po-label">更多</View>
  289. <Navigator url={'/pagesHouse/indexDtl?id=' + pk1Obj.id} className="po-v link">
  290. <View className="b">查看更多</View>
  291. </Navigator>
  292. </View>
  293. </View>
  294. <Button className="pk-share btn-to-div" openType="share">
  295. <Image src={iconShare} className="img" />
  296. </Button>
  297. {this.renderGoHome()}
  298. </View>
  299. )
  300. }
  301. }
  302. export default Index