roomPriceXk.jsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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. if (two.house_sale_state === '洪楼售') boxClassStr2 = `'srp-col t5 num'${oneDataLength}`
  245. return (
  246. <View className={boxClassStr2} key={tIndex} onClick={this.openDtlPopup.bind(this, two)}>
  247. {
  248. two.house_sale_state === '小定' || two.house_sale_state === '已定' || two.house_sale_state === '已售' || two.house_sale_state === '洪楼售'
  249. ?
  250. <View className="srp-tag">{two.house_sale_state}</View>
  251. : ''
  252. }
  253. {
  254. two.toward
  255. ?
  256. <View className="srp-tag2">{two.toward}</View>
  257. : ''
  258. }
  259. <View className="srp-room">
  260. <View className="srpr-p1">{two.room}
  261. <View className="s">{'>>'}</View>
  262. </View>
  263. <View className="srpr-p2">{two.built}㎡</View>
  264. <View className="srpr-p2">¥{parseInt(two.sale)}/㎡</View>
  265. <View className="srpr-p2">总价:{(Number(two.price) / 10000).toFixed(1)}万</View>
  266. </View>
  267. </View>
  268. )
  269. })
  270. }
  271. </View>
  272. )
  273. })
  274. }
  275. </View>
  276. )
  277. }
  278. previewImageHandle (cur, arr) {
  279. const current = `${cur}_plus`
  280. const urls = arr.map(item => {
  281. return `${item}_plus`
  282. })
  283. Taro.previewImage({
  284. current,
  285. urls
  286. })
  287. }
  288. renderDtl () {
  289. const { isDtlShow, curRoomObj, houseSaleStateArr } = this.state
  290. let boxClassStr = 'p2 t1'
  291. if (curRoomObj.house_sale_state === '小定') boxClassStr = `'p2 t2`
  292. if (curRoomObj.house_sale_state === '已定') boxClassStr = `'p2 t3`
  293. if (curRoomObj.house_sale_state === '已售') boxClassStr = `'p2 t4`
  294. if (curRoomObj.house_sale_state === '洪楼售') boxClassStr = `'p2 t5`
  295. let newTotalPrice = curRoomObj.price
  296. if (curRoomObj.house_discount) {
  297. const hdArr = curRoomObj.house_discount.split(',')
  298. hdArr.forEach(dis1 => {
  299. const oneStr = dis1.substr(0,1)
  300. const otherStr = dis1.substr(1,dis1.length)
  301. if (oneStr === '*'){
  302. newTotalPrice = (Number(newTotalPrice * otherStr).toFixed(2))
  303. }
  304. if (oneStr === '-'){
  305. newTotalPrice = (Number(newTotalPrice - otherStr).toFixed(2))
  306. }
  307. if (oneStr === '+'){
  308. newTotalPrice = (Number(newTotalPrice + otherStr).toFixed(2))
  309. }
  310. })
  311. }
  312. let newOnePrice = Number(newTotalPrice / curRoomObj.built).toFixed(2)
  313. return (
  314. <View className={isDtlShow ? 'l-modal-box' : 'l-modal-box hide'}>
  315. <View className='lmb-bg'></View>
  316. <View className='lmb-body'>
  317. <View className="scoped-dtl">
  318. {/* <View className="sd-img">
  319. <Image src={curRoomObj.house_img + '_xs'} className="img" onClick={this.previewImageHandle.bind(this, curRoomObj.house_img, [curRoomObj.house_img])}/>
  320. <View className="tips">
  321. <View className="bg"></View>
  322. <View className="t">查看大图</View>
  323. </View>
  324. </View> */}
  325. <View className="sd-p" onClick={this.previewImageHandle.bind(this, curRoomObj.house_img, [curRoomObj.house_img])}>
  326. <View className="p2">{curRoomObj.house_type}</View>
  327. <View className="p2">{curRoomObj.building_num}</View>
  328. <View className="p2">房号:{curRoomObj.room}</View>
  329. <View className="p2">层高:{curRoomObj.floor_height}</View>
  330. <View className="p2">建筑面积:{curRoomObj.built}㎡</View>
  331. <View className="p2">套内面积:{curRoomObj.built === curRoomObj.space ? '未知' : curRoomObj.space}㎡</View>
  332. <View className="p2">公摊面积:{curRoomObj.built === curRoomObj.space ? '未知' : curRoomObj.sharing}㎡</View>
  333. <View className="p2">得房率:{curRoomObj.built === curRoomObj.space ? '未知' : curRoomObj.house_rate}</View>
  334. <View className="p2">毛坯:{curRoomObj.blank}元/㎡</View>
  335. <View className="p2">装修:{curRoomObj.decoration}元/㎡</View>
  336. <View className="p2">单价:{curRoomObj.sale}元/㎡</View>
  337. <View className="p2">总价:{curRoomObj.price}元</View>
  338. </View>
  339. <View className="sd-label">销控数据
  340. </View>
  341. <View className="sd-p">
  342. <View className={boxClassStr}>
  343. <Picker mode='selector' range={houseSaleStateArr} onChange={this.onSaleStateChange}>
  344. {curRoomObj.house_sale_state}<View className="s">{'修改>>'}</View>
  345. </Picker>
  346. </View>
  347. <View className="p2">折扣:
  348. <Input type='text' placeholder='请输入' value={curRoomObj.house_discount} onInput={this.inputCHnage.bind(this, 'house_discount')} />
  349. </View>
  350. <View className="p2">朝向:
  351. <Input type='text' placeholder='请输入' value={curRoomObj.toward} onInput={this.inputCHnage.bind(this, 'toward')} />
  352. </View>
  353. <View className="p2">
  354. <View className="s">折后总价:{newTotalPrice || '暂无'}元</View>
  355. <View className="s">折后单价:{newOnePrice || '暂无'}元/㎡</View>
  356. </View>
  357. <View className="p">备注:
  358. <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/>
  359. </View>
  360. <View className="p3">
  361. <View className="t">输入验证码{curRoomObj.id},将本单元全部改为已售</View>
  362. <Input type='text' className="i" placeholder='请输入' value={curRoomObj.inputId} onInput={this.inputCHnage.bind(this, 'inputId')} />
  363. <View className="b" onClick={this.tagHandle.bind(this)}>本单元全部已售</View>
  364. </View>
  365. </View>
  366. <View className="l-floor-footer t2">
  367. <View className="lff-flex">
  368. <View className="lff-btn t3" onClick={this.closeRulePopup.bind(this)}>关闭</View>
  369. <View className="lff-btn t2" onClick={this.closeRulePopup.bind(this, 'edit')}>保存</View>
  370. </View>
  371. </View>
  372. </View>
  373. </View>
  374. </View>
  375. )
  376. }
  377. // const { curNav, buildingNumList } = this.state
  378. // const {eId, name, id} = this.$router.params
  379. // Taro.api.house.apiestatelotterypricelist({
  380. // estate_id: eId,
  381. // lottery_id: buildingNumList[curNav].id,
  382. // building_num: buildingNumList[curNav].title,
  383. inputCHnage (str, e) {
  384. let { curRoomObj } = this.state
  385. curRoomObj[str] = e.target.value
  386. this.setState({
  387. curRoomObj
  388. })
  389. }
  390. tagHandle () {
  391. const { curNav, buildingNumList } = this.state
  392. const {eId} = this.$router.params
  393. let { curRoomObj } = this.state
  394. if (curRoomObj.id == curRoomObj.inputId) {
  395. Taro.$msgConfirm(`确定该单元全部改为已售?`, () => {
  396. Taro.api.house.apiestatelotterypricebatch({
  397. estate_id: eId,
  398. house_sale_state: '已售',
  399. building_num: buildingNumList[curNav].title
  400. }).then(res => {
  401. this.getDtl()
  402. this.closeRulePopup()
  403. Taro.$msg(`更新成功~`)
  404. })
  405. }, () => {})
  406. } else {
  407. Taro.$msg(`请输入正确的验证码`)
  408. }
  409. }
  410. // const { valStr, bc } = this.props
  411. // bc(valStr, strTrim())
  412. onSaleStateChange = e => {
  413. let { curRoomObj, houseSaleStateArr } = this.state
  414. curRoomObj.house_sale_state = houseSaleStateArr[e.detail.value]
  415. this.setState({
  416. curRoomObj
  417. })
  418. }
  419. openDtlPopup (item) {
  420. this.setState({
  421. curRoomObj: item,
  422. isDtlShow: true
  423. })
  424. }
  425. closeRulePopup (str) {
  426. this.setState({
  427. curRoomObj: {},
  428. isDtlShow: false
  429. })
  430. if (str === 'edit') {
  431. let { curRoomObj } = this.state
  432. let house_discount = curRoomObj.house_discount ? curRoomObj.house_discount.replace(/,|、|\/|\\/g, ',') : ''
  433. Taro.api.house.apiestatelotterypriceedit({
  434. id: curRoomObj.id,
  435. house_sale_state: curRoomObj.house_sale_state,
  436. house_sale_remark: curRoomObj.house_sale_remark || '',
  437. toward: curRoomObj.toward || '',
  438. house_discount,
  439. }).then(res => {
  440. this.getDtl()
  441. })
  442. }
  443. }
  444. renderShare () {
  445. const iconShare = require('@img/images/icon_g_share6.png')
  446. return (
  447. <Button className="g-icon-share btn-to-div" openType="share">
  448. <Image className="img" src={iconShare} />
  449. </Button>
  450. )
  451. }
  452. render () {
  453. return (
  454. <View className="l-box">
  455. <LoginJudge />
  456. {this.renderTop()}
  457. {this.renderInfo()}
  458. {this.renderDtl()}
  459. {this.renderShare()}
  460. <Chat onRef={this.refChat} />
  461. </View>
  462. )
  463. }
  464. }
  465. export default Index