|
@@ -0,0 +1,500 @@
|
|
|
+import Taro, { Component } from '@tarojs/taro'
|
|
|
+import { View } from '@tarojs/components'
|
|
|
+import LoginJudge from '@/c/login/Judge'
|
|
|
+import WaterMark from '@/c/waterMark'
|
|
|
+import { arrToObj } from '@utils'
|
|
|
+import { AtTabs } from 'taro-ui'
|
|
|
+
|
|
|
+import Chat from '@/c/chat/com'
|
|
|
+import './roomPrice2.scss'
|
|
|
+import room from '../api/room'
|
|
|
+
|
|
|
+class Index extends Component {
|
|
|
+
|
|
|
+ constructor (props) {
|
|
|
+ super(props)
|
|
|
+ const {eId: curId} = this.$router.params
|
|
|
+ this.state = {
|
|
|
+ curId,
|
|
|
+ curObj: {},
|
|
|
+ curNav: 0,
|
|
|
+ buildingNumList: [],
|
|
|
+ roomArr: [],
|
|
|
+ curRoomObj: {},
|
|
|
+ houseSaleStateArr: ['未售', '小定', '已定', '已售', '洪楼售'],
|
|
|
+ isDtlShow: false,
|
|
|
+ allData: {},
|
|
|
+ isEdit: false,
|
|
|
+ isNavPopupShow: false,
|
|
|
+ navObj: {},
|
|
|
+ edRoomList: [],
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ config = {
|
|
|
+ navigationBarTitleText: '二手房房源表',
|
|
|
+ }
|
|
|
+
|
|
|
+ componentWillMount () {
|
|
|
+ Taro.$AHU(this)
|
|
|
+ this.getNavInfo()
|
|
|
+ }
|
|
|
+
|
|
|
+ getNavInfo = () => {
|
|
|
+ const { eId } = this.$router.params
|
|
|
+ const { curNav } = this.state
|
|
|
+ Taro.api.room.apibuildingunitlist({
|
|
|
+ page_size: 1000,
|
|
|
+ estate_id: eId,
|
|
|
+ }).then(res => {
|
|
|
+ const buildingNumList = res.list || []
|
|
|
+ this.setState({
|
|
|
+ buildingNumList,
|
|
|
+ curObj: buildingNumList[curNav]
|
|
|
+ }, () => {
|
|
|
+ this.getRoomList()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ refChat = (ref) => {
|
|
|
+ this.subChat = ref
|
|
|
+ }
|
|
|
+
|
|
|
+ componentDidShow () { }
|
|
|
+
|
|
|
+ componentDidHide () { }
|
|
|
+
|
|
|
+ renderTop () {
|
|
|
+ const {eId, id, name} = this.$router.params
|
|
|
+ const { curNav, buildingNumList, isEdit } = this.state
|
|
|
+ const newTabList = buildingNumList.map(item => {
|
|
|
+ return {
|
|
|
+ title: `${item.building}栋${item.unit}单元`,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const nameIcon = require('./img/yfyj/yfyj04.png')
|
|
|
+ return (
|
|
|
+ <View className="scoped-header">
|
|
|
+ <View className="scoped-top">
|
|
|
+ <View className="st-wrap">
|
|
|
+ <View className="st-header">
|
|
|
+ <View className="text">
|
|
|
+ <Image src={nameIcon} className="i"></Image>
|
|
|
+ <View className="t">{name}</View>
|
|
|
+ </View>
|
|
|
+ <View className="r" onClick={this.openNavPopup.bind(this)}>添加楼栋</View>
|
|
|
+ {
|
|
|
+ isEdit ? (
|
|
|
+ <View className="r2 t2" onClick={this.changeNavTab.bind(this)}>展示</View>
|
|
|
+ ) : (
|
|
|
+ <View className="r2" onClick={this.changeNavTab.bind(this)}>编辑</View>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ <View className="sh-nav">
|
|
|
+ <AtTabs
|
|
|
+ current={curNav}
|
|
|
+ scroll
|
|
|
+ tabList={newTabList}
|
|
|
+ onClick={this.navClick.bind(this)}>
|
|
|
+ </AtTabs>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ openNavPopup (str) {
|
|
|
+ this.setState({
|
|
|
+ isNavPopupShow: true
|
|
|
+ })
|
|
|
+ if (str === 'edit') {
|
|
|
+ const { buildingNumList, curNav } = this.state
|
|
|
+ this.setState({
|
|
|
+ navObj: buildingNumList[curNav]
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setState({
|
|
|
+ navObj: {}
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ closeNavPopup (str) {
|
|
|
+ this.setState({
|
|
|
+ isNavPopupShow: false
|
|
|
+ })
|
|
|
+ if (str === 'edit') {
|
|
|
+ const { eId } = this.$router.params
|
|
|
+ let { navObj, isEdit } = this.state
|
|
|
+ let apiStr = 'apibuildingunitadd'
|
|
|
+ let params = {
|
|
|
+ estate_id: eId,
|
|
|
+ building: navObj.building || '',
|
|
|
+ unit: navObj.unit || '',
|
|
|
+ total_floor: navObj.total_floor || '',
|
|
|
+ room_num: navObj.room_num || '',
|
|
|
+ remark: navObj.remark || '',
|
|
|
+ }
|
|
|
+ if (isEdit) {
|
|
|
+ apiStr = 'apibuildingunitedit'
|
|
|
+ params.id = navObj.id
|
|
|
+ }
|
|
|
+ Taro.api.room[apiStr](params).then(res => {
|
|
|
+ this.getNavInfo()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ changeNavTab () {
|
|
|
+ const { isEdit } = this.state
|
|
|
+ this.setState({
|
|
|
+ isEdit: !isEdit
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ urlLink (u, params) {
|
|
|
+ if (u === 'dev') {
|
|
|
+ Taro.$msg('开发中~敬请期待')
|
|
|
+ } else {
|
|
|
+ let url = u
|
|
|
+ if (params) url += `?${params}`
|
|
|
+ Taro.navigateTo({
|
|
|
+ url
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ navClick (value) {
|
|
|
+ const { isEdit } = this.state
|
|
|
+ this.setState({
|
|
|
+ curNav: value
|
|
|
+ }, () => {
|
|
|
+ if (isEdit) {
|
|
|
+ this.openNavPopup('edit')
|
|
|
+ } else {
|
|
|
+ this.getNavInfo()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ renderQrcode () {
|
|
|
+ const qrcodeImg = 'http://icon.honglounews.com/miniqrcode.jpg'
|
|
|
+ return (
|
|
|
+ <Image src={qrcodeImg} className="scoped-qrcode" onClick={this.previewQrcodeImageHandle.bind(this, qrcodeImg, [qrcodeImg])} />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ previewQrcodeImageHandle (current, urls) {
|
|
|
+ Taro.previewImage({
|
|
|
+ current,
|
|
|
+ urls
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //
|
|
|
+ urlDtlLink () {
|
|
|
+ const { eId } = this.$router.params
|
|
|
+ Taro.navigateTo({url: '/pagesHouse/indexDtl?id=' + eId + '&YH=zzyh'})
|
|
|
+ }
|
|
|
+
|
|
|
+ create2DArray(x, y) {
|
|
|
+ let array = new Array(x).fill({data: new Array(y).fill({house_sale_state: ''})})
|
|
|
+ return array
|
|
|
+ }
|
|
|
+
|
|
|
+ renderInfo () {
|
|
|
+ const { curObj, edRoomList } = this.state
|
|
|
+ let cArr = this.create2DArray(curObj.total_floor, curObj.room_num) || []
|
|
|
+ return (
|
|
|
+ <View className="scoped-room-price">
|
|
|
+ {
|
|
|
+ cArr.map((one, oIndex) => {
|
|
|
+ return (
|
|
|
+ <View className="srp-row" key={oIndex}>
|
|
|
+ <View className="srp-col">{cArr.length - oIndex}层</View>
|
|
|
+ {
|
|
|
+ one.data
|
|
|
+ ?
|
|
|
+ one.data.map((two, tIndex) => {
|
|
|
+ const oneDataLength = one.data.length
|
|
|
+ let boxClassStr2 = `'srp-col num'${oneDataLength}`
|
|
|
+ const room = `${cArr.length - oIndex}0${tIndex+1}`
|
|
|
+ let curTwo = {...two}
|
|
|
+ edRoomList.forEach(r => {
|
|
|
+ if (r.room === room) {
|
|
|
+ curTwo = {...r}
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (curTwo.final_price) boxClassStr2 = `'srp-col t4 num'${oneDataLength}`
|
|
|
+ return (
|
|
|
+ <View className={boxClassStr2} key={tIndex} onClick={this.openDtlPopup.bind(this, curTwo, cArr, oIndex, tIndex)}>
|
|
|
+ {
|
|
|
+ curTwo.final_price
|
|
|
+ ?
|
|
|
+ <View className="srp-tag">已售</View>
|
|
|
+ : ''
|
|
|
+ }
|
|
|
+ {
|
|
|
+ two.toward
|
|
|
+ ?
|
|
|
+ <View className="srp-tag2">{curTwo.toward}</View>
|
|
|
+ : ''
|
|
|
+ }
|
|
|
+ <View className="srp-room">
|
|
|
+ <View className="srpr-p1">{`${cArr.length - oIndex}0${tIndex+1}`}</View>
|
|
|
+ {
|
|
|
+ curTwo.id
|
|
|
+ ?
|
|
|
+ <View>
|
|
|
+ <View className="srpr-p2">面积:{curTwo.built}㎡</View>
|
|
|
+ {
|
|
|
+ curTwo.final_price
|
|
|
+ ? <View className="srpr-p2">成交:{curTwo.final_price}万<View>¥{(curTwo.final_price * 10000 / curTwo.built).toFixed(2) }/㎡</View></View>
|
|
|
+ : <View className="srpr-p2">挂牌:{curTwo.listing_price}万<View>¥{(curTwo.listing_price * 10000 / curTwo.built).toFixed(2) }/㎡</View></View>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ :
|
|
|
+ <View>
|
|
|
+ <View className="srpr-p3">暂无数据</View>
|
|
|
+ <View className="srpr-p3">点击新增</View>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ : ''
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ previewImageHandle (cur, arr) {
|
|
|
+ const current = `${cur}_plus`
|
|
|
+ const urls = arr.map(item => {
|
|
|
+ return `${item}_plus`
|
|
|
+ })
|
|
|
+ Taro.previewImage({
|
|
|
+ current,
|
|
|
+ urls
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ renderEditTips () {
|
|
|
+ return (
|
|
|
+ <View className="edit-tips">
|
|
|
+ <View className="et-t">点击上方标签,修改编辑楼栋单元</View>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ renderNavPopup () {
|
|
|
+ const { isNavPopupShow, navObj } = this.state
|
|
|
+ return (
|
|
|
+ <View className={isNavPopupShow ? 'l-modal-box' : 'l-modal-box hide'}>
|
|
|
+ <View className='lmb-bg'></View>
|
|
|
+ <View className='lmb-body'>
|
|
|
+ <View className="scoped-form">
|
|
|
+ <View className="sf-item t2">
|
|
|
+ <Input className="i2" type='text' placeholder='' value={navObj.building} onInput={this.inputCHnage.bind(this, 'building')} />
|
|
|
+ <View className="k2">栋的</View>
|
|
|
+ <Input className="i2" type='text' placeholder='' value={navObj.unit} onInput={this.inputCHnage.bind(this, 'unit')} />
|
|
|
+ <View className="k2">单元</View>
|
|
|
+ </View>
|
|
|
+ <View className="sf-item t2">
|
|
|
+ <View className="k2">总共</View>
|
|
|
+ <Input className="i2" type='number' placeholder='' value={navObj.total_floor} onInput={this.inputCHnage.bind(this, 'total_floor')} />
|
|
|
+ <View className="k2">层,每层</View>
|
|
|
+ <Input className="i2" type='number' placeholder='' value={navObj.room_num} onInput={this.inputCHnage.bind(this, 'room_num')} />
|
|
|
+ <View className="k2">户</View>
|
|
|
+ </View>
|
|
|
+ <View className="sf-item">
|
|
|
+ <View className="k">备注:</View>
|
|
|
+ <Input className="i" type='number' placeholder='请输入' value={navObj.remark} onInput={this.inputCHnage.bind(this, 'remark')} />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-footer t2">
|
|
|
+ <View className="lff-flex">
|
|
|
+ <View className="lff-btn t3" onClick={this.closeNavPopup.bind(this)}>关闭</View>
|
|
|
+ <View className="lff-btn t2s" onClick={this.closeNavPopup.bind(this, 'edit')}>保存</View>
|
|
|
+ {
|
|
|
+ navObj.id
|
|
|
+ ?
|
|
|
+ <View className="lff-btn t4" onClick={this.delNav.bind(this)}>删除</View>
|
|
|
+ : ''
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ inputCHnage (str, e) {
|
|
|
+ let { navObj } = this.state
|
|
|
+ navObj[str] = e.target.value
|
|
|
+ this.setState({
|
|
|
+ navObj
|
|
|
+ })
|
|
|
+ }
|
|
|
+ delNav () {
|
|
|
+ let { navObj } = this.state
|
|
|
+ Taro.$msgConfirm(`确定删除${navObj.building}栋${navObj.unit}单元吗?`, () => {
|
|
|
+ Taro.api.room.apibuildingunitdel({id: navObj.id}).then(res => {
|
|
|
+ Taro.$msg('删除成功!')
|
|
|
+ this.getNavInfo()
|
|
|
+ this.closeNavPopup()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ renderDtl () {
|
|
|
+ const { isDtlShow, curRoomObj, curObj } = this.state
|
|
|
+ return (
|
|
|
+ <View className={isDtlShow ? 'l-modal-box' : 'l-modal-box hide'}>
|
|
|
+ <View className='lmb-bg'></View>
|
|
|
+ <View className='lmb-body'>
|
|
|
+ <View className="scoped-form">
|
|
|
+ <View className="sf-item t2">
|
|
|
+ <View className="k2">{`${curObj.building}栋${curObj.unit}单元`} {curRoomObj.storey}层{curRoomObj.room}</View>
|
|
|
+ </View>
|
|
|
+ <View className="sf-item t2">
|
|
|
+ <View className="k2">房屋面积</View>
|
|
|
+ <Input className="i2" type='number' placeholder='' value={curRoomObj.built} onInput={this.roomChange.bind(this, 'built')} />
|
|
|
+ <View className="k2">㎡</View>
|
|
|
+ </View>
|
|
|
+ <View className="sf-item t2">
|
|
|
+ <View className="k2">最新挂总价</View>
|
|
|
+ <Input className="i2" type='number' placeholder='' value={curRoomObj.listing_price} onInput={this.roomChange.bind(this, 'listing_price')} />
|
|
|
+ <View className="k2">万元</View>
|
|
|
+ </View>
|
|
|
+ <View className="sf-item t2">
|
|
|
+ <View className="k2">成交价[选填]</View>
|
|
|
+ <Input className="i2" type='number' placeholder='' value={curRoomObj.final_price} onInput={this.roomChange.bind(this, 'final_price')} />
|
|
|
+ <View className="k2">万元</View>
|
|
|
+ </View>
|
|
|
+ <View className="sf-item">
|
|
|
+ <View className="k">备注:</View>
|
|
|
+ <Input className="i" type='number' placeholder='请输入' value={curRoomObj.remark} onInput={this.roomChange.bind(this, 'remark')} />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-footer t2">
|
|
|
+ <View className="lff-flex">
|
|
|
+ <View className="lff-btn t3" onClick={this.closeRulePopup.bind(this)}>关闭</View>
|
|
|
+ <View className="lff-btn t2s" onClick={this.closeRulePopup.bind(this, 'edit')}>保存</View>
|
|
|
+ {
|
|
|
+ curRoomObj.id
|
|
|
+ ?
|
|
|
+ <View className="lff-btn t4" onClick={this.delRoom.bind(this)}>删除</View>
|
|
|
+ : ''
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ roomChange (str, e) {
|
|
|
+ let { curRoomObj } = this.state
|
|
|
+ curRoomObj[str] = e.target.value
|
|
|
+ this.setState({
|
|
|
+ curRoomObj
|
|
|
+ })
|
|
|
+ }
|
|
|
+ delRoom () {
|
|
|
+ let { curObj,curRoomObj } = this.state
|
|
|
+ Taro.$msgConfirm(`确定删除${curObj.building}栋${curObj.unit}单元的${curRoomObj.storey}层${curRoomObj.room}吗?`, () => {
|
|
|
+ Taro.api.room.apieshousepricedel({id: curRoomObj.id}).then(res => {
|
|
|
+ Taro.$msg('删除成功!')
|
|
|
+ this.closeRulePopup()
|
|
|
+ this.getRoomList()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ openDtlPopup (two, cArr, oIndex, tIndex) {
|
|
|
+ let curRoomObj = {...two}
|
|
|
+ if (!curRoomObj.room) curRoomObj.room = `${cArr.length - oIndex}0${tIndex+1}`
|
|
|
+ if (!curRoomObj.storey) curRoomObj.storey = `${cArr.length - oIndex}`
|
|
|
+ this.setState({
|
|
|
+ curRoomObj,
|
|
|
+ isDtlShow: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ closeRulePopup (str) {
|
|
|
+ const {eId} = this.$router.params
|
|
|
+ if (str === 'edit') {
|
|
|
+ let { curRoomObj, curObj } = this.state
|
|
|
+ let params = {
|
|
|
+ estate_id: eId,
|
|
|
+ building_id: curObj.id,
|
|
|
+ storey: curRoomObj.storey || '',
|
|
|
+ room: curRoomObj.room || '',
|
|
|
+ built: curRoomObj.built || '',
|
|
|
+ listing_price: curRoomObj.listing_price || '',
|
|
|
+ final_price: curRoomObj.final_price || '',
|
|
|
+ remark: curRoomObj.remark || '',
|
|
|
+ }
|
|
|
+ if (!params.built) {
|
|
|
+ Taro.$msg('请输入房屋面积!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!params.listing_price && !params.final_price) {
|
|
|
+ Taro.$msg('请输入成交价或最新挂总价!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.setState({
|
|
|
+ curRoomObj: {},
|
|
|
+ isDtlShow: false
|
|
|
+ })
|
|
|
+ let apiStr = 'apieshousepriceadd'
|
|
|
+ if (curRoomObj.id) {
|
|
|
+ params.id = curRoomObj.id
|
|
|
+ apiStr = 'apieshousepriceedit'
|
|
|
+ }
|
|
|
+ Taro.api.room[apiStr](params).then(res => {
|
|
|
+ Taro.$msg('操作成功!')
|
|
|
+ this.getRoomList()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setState({
|
|
|
+ curRoomObj: {},
|
|
|
+ isDtlShow: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ getRoomList () {
|
|
|
+ const {eId} = this.$router.params
|
|
|
+ let { curObj } = this.state
|
|
|
+ Taro.api.room.apieshousepricelist({
|
|
|
+ estate_id: eId,
|
|
|
+ building_id: curObj.id,
|
|
|
+ }).then(res => {
|
|
|
+ this.setState({
|
|
|
+ edRoomList: res || []
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ render () {
|
|
|
+ const { isEdit} = this.state
|
|
|
+ return (
|
|
|
+ <View className="l-box">
|
|
|
+ {/* <WaterMark /> */}
|
|
|
+ <LoginJudge />
|
|
|
+ {this.renderTop()}
|
|
|
+ {isEdit ? this.renderEditTips() : this.renderInfo()}
|
|
|
+ {this.renderNavPopup()}
|
|
|
+ {this.renderDtl()}
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export default Index
|