roomPriceXk.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. import Taro, { Component } from '@tarojs/taro'
  2. import { View } from '@tarojs/components'
  3. import LoginJudge from '@/c/login/Judge'
  4. import { arrToObj } from '@utils'
  5. import { AtTabs } from 'taro-ui'
  6. import Chat from '@/c/chat/com'
  7. import './roomPriceXk.scss'
  8. class Index extends Component {
  9. onShareAppMessage() {
  10. const {eId, id, name} = this.$router.params
  11. return {
  12. title: `来看看${name}的一房一价表`,
  13. path: `/pagesRoom/roomPrice?eId=${eId}&id=${id}&name=${name}`,
  14. }
  15. }
  16. onShareTimeline () {
  17. const {eId, id, name} = this.$router.params
  18. return {
  19. title: `来看看${name}的一房一价表`,
  20. path: `/pagesRoom/roomPrice?eId=${eId}&id=${id}&name=${name}`,
  21. }
  22. }
  23. constructor (props) {
  24. super(props)
  25. const {eId: curId} = this.$router.params
  26. this.state = {
  27. curId,
  28. curObj: {},
  29. curNav: 0,
  30. roomArr: [],
  31. curRoomObj: {},
  32. houseSaleStateArr: ['未售', '小定', '已定', '已售'],
  33. isDtlShow: false,
  34. buildingNumList: [],
  35. }
  36. }
  37. config = {
  38. navigationBarTitleText: '一房一价表',
  39. navigationBarBackgroundColor: '#369af7',
  40. navigationBarTextStyle: 'white'
  41. }
  42. componentWillMount () {
  43. Taro.$AHU(this)
  44. // const { name } = this.$router.params
  45. // Taro.setNavigationBarTitle({
  46. // title: name + '-一房一价表' || '一房一价表'
  47. // })
  48. const {eId, id} = this.$router.params
  49. Taro.api.house.apiestatelottery2batchinfo({
  50. lottery_id: id,
  51. estate_id: eId,
  52. }).then(res => {
  53. let ll = res.lottery_list || []
  54. let buildingNumList = []
  55. ll.forEach(item => {
  56. const arr = item.building_num.split(',')
  57. arr.forEach(sub => {
  58. buildingNumList.push({
  59. id: item.id,
  60. title: sub,
  61. lottery_time: item.lottery_time
  62. })
  63. })
  64. })
  65. this.setState({
  66. buildingNumList,
  67. curObj: res || {}
  68. }, () => {
  69. this.getDtl()
  70. })
  71. })
  72. }
  73. getDtl = () => {
  74. const { curNav, buildingNumList } = this.state
  75. const {eId, name, id} = this.$router.params
  76. Taro.api.house.apiestatelotterypricelist({
  77. estate_id: eId,
  78. lottery_id: buildingNumList[curNav].id,
  79. building_num: buildingNumList[curNav].title,
  80. }).then(res => {
  81. this.setState({
  82. roomArr: res || []
  83. })
  84. if (this.subChat) {
  85. this.subChat.getData({name, id: eId}, 'pt')
  86. }
  87. })
  88. }
  89. onceGetInfo () {
  90. const {eId} = this.$router.params
  91. const { curObj, curNav, buildingNumList } = this.state
  92. if (curObj.id === buildingNumList[curNav].id) {
  93. return
  94. }
  95. Taro.api.house.apiestatelottery2batchinfo({
  96. lottery_id: buildingNumList[curNav].id,
  97. estate_id: eId,
  98. }).then(res => {
  99. this.setState({
  100. curObj: res || {}
  101. })
  102. })
  103. }
  104. refChat = (ref) => {
  105. this.subChat = ref
  106. }
  107. componentDidShow () { }
  108. componentDidHide () { }
  109. renderTop () {
  110. const {eId, id, name} = this.$router.params
  111. const curParams = `eId=${eId}&id=${id}&name=${name}`
  112. const { curObj, curNav, buildingNumList } = this.state
  113. const nameIcon = require('./img/yfyj/yfyj04.png')
  114. const i1 = require('./img/yfyj/yfyj05.png')
  115. const i2 = require('./img/yfyj/yfyj06.png')
  116. const op1 = require('./img/yfyj/yfyj_icon1.png')
  117. const op2 = require('./img/yfyj/yfyj_icon2.png')
  118. const op3 = require('./img/yfyj/yfyj_icon3.png')
  119. const op4 = require('./img/yfyj/yfyj_icon4.png')
  120. const bg = require('./img/yfyj/bg.jpg')
  121. return (
  122. <View className="scoped-header">
  123. <View className="scoped-top">
  124. <Image src={bg} className="bg"></Image>
  125. <View className="st-wrap">
  126. <View className="st-header">
  127. <View className="text">
  128. <Image src={nameIcon} className="i"></Image>
  129. <View className="t">{name}</View>
  130. </View>
  131. <View className="r" onClick={this.urlDtlLink.bind(this)}>返回楼盘详情</View>
  132. </View>
  133. <View className="st-p1">
  134. <Image className="i" src={i1}></Image>
  135. <View className="t">{curObj.under_way}</View>
  136. </View>
  137. <View className="st-p1">
  138. <Image className="i" src={i2}></Image>
  139. <View className="t2">{curObj.lottery_time}</View>
  140. </View>
  141. <View className="st-p2">
  142. <Image src={op1} className="op1" onClick={this.urlLink.bind(this, '/pagesRoom/roomPriceList', curParams)}></Image>
  143. <Image src={op2} className="op2" onClick={this.urlLink.bind(this, '/pagesRoom/roomPriceImg', curParams)}></Image>
  144. <Image src={op3} className="op3" onClick={this.previewImageHandle.bind(this, curObj.project_img, [curObj.project_img])}></Image>
  145. <Image src={op4} className="op4" onClick={this.previewQrcodeImageHandle.bind(this, 'http://icon.honglounews.com/ncfxw2.jpg', ['http://icon.honglounews.com/ncfxw2.jpg'])}></Image>
  146. </View>
  147. {this.renderQrcode()}
  148. </View>
  149. </View>
  150. <View className="sh-nav">
  151. <AtTabs
  152. current={curNav}
  153. scroll
  154. tabList={buildingNumList}
  155. onClick={this.navClick.bind(this)}>
  156. </AtTabs>
  157. </View>
  158. </View>
  159. )
  160. }
  161. urlLink (u, params) {
  162. if (u === 'dev') {
  163. Taro.$msg('开发中~敬请期待')
  164. } else {
  165. let url = u
  166. if (params) url += `?${params}`
  167. Taro.navigateTo({
  168. url
  169. })
  170. }
  171. }
  172. navClick (value) {
  173. this.setState({
  174. curNav: value
  175. }, () => {
  176. this.getDtl()
  177. this.onceGetInfo()
  178. })
  179. }
  180. renderQrcode () {
  181. const qrcodeImg = 'http://icon.honglounews.com/miniqrcode.jpg'
  182. return (
  183. <Image src={qrcodeImg} className="scoped-qrcode" onClick={this.previewQrcodeImageHandle.bind(this, qrcodeImg, [qrcodeImg])} />
  184. )
  185. }
  186. previewQrcodeImageHandle (current, urls) {
  187. Taro.previewImage({
  188. current,
  189. urls
  190. })
  191. }
  192. //
  193. urlDtlLink () {
  194. const { eId } = this.$router.params
  195. Taro.navigateTo({url: '/pagesHouse/indexDtl?id=' + eId + '&YH=zzyh'})
  196. }
  197. renderInfo () {
  198. const { roomArr } = this.state
  199. let cArr = roomArr || []
  200. const htArr = cArr[0] ? cArr[0].data : []
  201. const htArrIndex = htArr.length
  202. const htitems = htArr.map((item, index) => {
  203. let boxClassStr = `'srp-col num'${htArrIndex}`
  204. return (
  205. <View className={boxClassStr} key={index}>
  206. <View className="srp-ht">
  207. <View className="srp-img">
  208. <Image src={item.house_img + '_xs'} className="img" onClick={this.previewImageHandle.bind(this, item.house_img, [item.house_img])}/>
  209. <View className="tips">
  210. <View className="bg"></View>
  211. <View className="t">查看大图</View>
  212. </View>
  213. </View>
  214. <View className="p1">{item.house_type}</View>
  215. <View className="p2">{item.built}㎡</View>
  216. {
  217. item.house_rate === '100%'
  218. ? ''
  219. :
  220. <View className="p2">得房率:{item.house_rate}</View>
  221. }
  222. </View>
  223. </View>
  224. )
  225. })
  226. return (
  227. <View className="scoped-room-price">
  228. <View className="srp-row">
  229. <View className="srp-col">户型图</View>
  230. {htitems}
  231. </View>
  232. {
  233. cArr.map((one, oIndex) => {
  234. return (
  235. <View className="srp-row" key={oIndex}>
  236. <View className="srp-col">{one.storey}层</View>
  237. {
  238. one.data.map((two, tIndex) => {
  239. const oneDataLength = one.data.length
  240. let boxClassStr2 = `'srp-col num'${oneDataLength}`
  241. if (two.house_sale_state === '小定') boxClassStr2 = `'srp-col t2 num'${oneDataLength}`
  242. if (two.house_sale_state === '已定') boxClassStr2 = `'srp-col t3 num'${oneDataLength}`
  243. if (two.house_sale_state === '已售') boxClassStr2 = `'srp-col t4 num'${oneDataLength}`
  244. return (
  245. <View className={boxClassStr2} key={tIndex} onClick={this.openDtlPopup.bind(this, two)}>
  246. {
  247. two.house_sale_state === '小定' || two.house_sale_state === '已定' || two.house_sale_state === '已售'
  248. ?
  249. <View className="srp-tag">{two.house_sale_state}</View>
  250. : ''
  251. }
  252. <View className="srp-room">
  253. <View className="srpr-p1">{two.room}
  254. <View className="s">{'>>'}</View>
  255. </View>
  256. <View className="srpr-p2">{two.built}㎡</View>
  257. <View className="srpr-p2">¥{parseInt(two.sale)}/㎡</View>
  258. <View className="srpr-p2">总价:{(Number(two.price) / 10000).toFixed(1)}万</View>
  259. </View>
  260. </View>
  261. )
  262. })
  263. }
  264. </View>
  265. )
  266. })
  267. }
  268. </View>
  269. )
  270. }
  271. previewImageHandle (cur, arr) {
  272. const current = `${cur}_plus`
  273. const urls = arr.map(item => {
  274. return `${item}_plus`
  275. })
  276. Taro.previewImage({
  277. current,
  278. urls
  279. })
  280. }
  281. renderDtl () {
  282. const { isDtlShow, curRoomObj, houseSaleStateArr } = this.state
  283. let boxClassStr = 'p2 t1'
  284. if (curRoomObj.house_sale_state === '小定') boxClassStr = `'p2 t2`
  285. if (curRoomObj.house_sale_state === '已定') boxClassStr = `'p2 t3`
  286. if (curRoomObj.house_sale_state === '已售') boxClassStr = `'p2 t4`
  287. let newTotalPrice = curRoomObj.price
  288. if (curRoomObj.house_discount) {
  289. const hdArr = curRoomObj.house_discount.split(',')
  290. hdArr.forEach(dis1 => {
  291. const oneStr = dis1.substr(0,1)
  292. const otherStr = dis1.substr(1,dis1.length)
  293. if (oneStr === '*'){
  294. newTotalPrice = (Number(newTotalPrice * otherStr).toFixed(2))
  295. }
  296. if (oneStr === '-'){
  297. newTotalPrice = (Number(newTotalPrice - otherStr).toFixed(2))
  298. }
  299. if (oneStr === '+'){
  300. newTotalPrice = (Number(newTotalPrice + otherStr).toFixed(2))
  301. }
  302. })
  303. }
  304. let newOnePrice = Number(newTotalPrice / curRoomObj.built).toFixed(2)
  305. return (
  306. <View className={isDtlShow ? 'l-modal-box' : 'l-modal-box hide'}>
  307. <View className='lmb-bg'></View>
  308. <View className='lmb-body'>
  309. <View className="scoped-dtl">
  310. <View className="sd-img">
  311. <Image src={curRoomObj.house_img + '_xs'} className="img" onClick={this.previewImageHandle.bind(this, curRoomObj.house_img, [curRoomObj.house_img])}/>
  312. <View className="tips">
  313. <View className="bg"></View>
  314. <View className="t">查看大图</View>
  315. </View>
  316. </View>
  317. <View className="sd-p">
  318. <View className="p2">{curRoomObj.house_type}</View>
  319. <View className="p2">{curRoomObj.building_num}</View>
  320. <View className="p2">房号:{curRoomObj.room}</View>
  321. <View className="p2">层高:{curRoomObj.floor_height}</View>
  322. <View className="p2">建筑面积:{curRoomObj.built}㎡</View>
  323. <View className="p2">套内面积:{curRoomObj.built === curRoomObj.space ? '未知' : curRoomObj.space}㎡</View>
  324. <View className="p2">公摊面积:{curRoomObj.built === curRoomObj.space ? '未知' : curRoomObj.sharing}㎡</View>
  325. <View className="p2">得房率:{curRoomObj.built === curRoomObj.space ? '未知' : curRoomObj.house_rate}</View>
  326. <View className="p2">毛坯:{curRoomObj.blank}元/㎡</View>
  327. <View className="p2">装修:{curRoomObj.decoration}元/㎡</View>
  328. <View className="p2">单价:{curRoomObj.sale}元/㎡</View>
  329. <View className="p2">总价:{curRoomObj.price}元</View>
  330. </View>
  331. <View className="sd-label">销控数据
  332. </View>
  333. <View className="sd-p">
  334. <View className={boxClassStr}>
  335. <Picker mode='selector' range={houseSaleStateArr} onChange={this.onSaleStateChange}>
  336. {curRoomObj.house_sale_state}<View className="s">{'修改>>'}</View>
  337. </Picker>
  338. </View>
  339. <View className="p2">折扣:
  340. <Input type='text' placeholder='请输入' value={curRoomObj.house_discount} onInput={this.inputCHnage.bind(this, 'house_discount')} />
  341. </View>
  342. <View className="p2">备注:
  343. <Textarea placeholder='请输入' style='background:#fff;width:100%;min-height:50px;padding:0 30rpx;box-sizing: border-box;text-align: left;color: #666;' value={curRoomObj.house_sale_remark} autoHeight/>
  344. </View>
  345. <View className="p2">
  346. <View className="s">折后总价:{newTotalPrice || '暂无'}元</View>
  347. <View className="s">折后单价:{newOnePrice || '暂无'}元/㎡</View>
  348. </View>
  349. </View>
  350. <View className="l-floor-footer t2">
  351. <View className="lff-flex">
  352. <View className="lff-btn t3" onClick={this.closeRulePopup.bind(this)}>关闭</View>
  353. <View className="lff-btn t2" onClick={this.closeRulePopup.bind(this, 'edit')}>保存</View>
  354. </View>
  355. </View>
  356. </View>
  357. </View>
  358. </View>
  359. )
  360. }
  361. inputCHnage (str, e) {
  362. let { curRoomObj } = this.state
  363. curRoomObj[str] = e.target.value
  364. this.setState({
  365. curRoomObj
  366. })
  367. }
  368. // const { valStr, bc } = this.props
  369. // bc(valStr, strTrim())
  370. onSaleStateChange = e => {
  371. let { curRoomObj, houseSaleStateArr } = this.state
  372. curRoomObj.house_sale_state = houseSaleStateArr[e.detail.value]
  373. this.setState({
  374. curRoomObj
  375. })
  376. }
  377. openDtlPopup (item) {
  378. this.setState({
  379. curRoomObj: item,
  380. isDtlShow: true
  381. })
  382. }
  383. closeRulePopup (str) {
  384. this.setState({
  385. curRoomObj: {},
  386. isDtlShow: false
  387. })
  388. if (str === 'edit') {
  389. let { curRoomObj } = this.state
  390. let house_discount = curRoomObj.house_discount.replace(/,|、|\/|\\/g, ',')
  391. Taro.api.house.apiestatelotterypriceedit({
  392. id: curRoomObj.id,
  393. house_sale_state: curRoomObj.house_sale_state,
  394. house_sale_remark: curRoomObj.house_sale_remark || '',
  395. house_discount,
  396. }).then(res => {
  397. this.getDtl()
  398. })
  399. }
  400. }
  401. renderShare () {
  402. const iconShare = require('@img/images/icon_g_share6.png')
  403. return (
  404. <Button className="g-icon-share btn-to-div" openType="share">
  405. <Image className="img" src={iconShare} />
  406. </Button>
  407. )
  408. }
  409. render () {
  410. return (
  411. <View className="l-box">
  412. <LoginJudge />
  413. {this.renderTop()}
  414. {this.renderInfo()}
  415. {this.renderDtl()}
  416. {this.renderShare()}
  417. <Chat onRef={this.refChat} />
  418. </View>
  419. )
  420. }
  421. }
  422. export default Index