Browse Source

添加上传房源1.0

liujq temp20230202 2 years ago
parent
commit
38ab7134b4

+ 15 - 0
src/api/room.js

@@ -60,4 +60,19 @@ export default {
   apirecept2salelist: params => { // 门店排班轮值 排班人员列表
     return request('/api/recept2/sale/list', params, 'loading')
   },
+  apieshouselist: params => { // 二手房 房源列表
+    return request('/api/eshouse/list', params, 'loading')
+  },
+  apieshousedetail: params => { // 二手房 房源详情
+    return request('/api/eshouse/detail', params, 'loading')
+  },
+  apieshouseadd: params => { // 二手房 房源添加
+    return request('/api/eshouse/add', params, 'loading')
+  },
+  apieshousepricechange: params => { // 二手房 房源改价
+    return request('/api/eshouse/price/change', params, 'loading')
+  },
+  apieshouseedit: params => { // 二手房 房源编辑
+    return request('/api/eshouse/edit', params, 'loading')
+  },
 }

+ 1 - 0
src/assets/css/mixin.scss

@@ -157,6 +157,7 @@ $greyColor: #9b9b9b;
 }
 .l-floor-pos2 {
   padding: 0 20px;
+  position: relative;
 }
 
 .l-base-wrap {

+ 1 - 1
src/components/lform/RadioSelect.jsx

@@ -71,7 +71,7 @@ export default class RadioSelect extends Component {
       ...params,
     }).then(res => {
       const arr = res.list || res || []
-      const remoteOptions = []
+      let remoteOptions = []
       arr.forEach(item => {
         const curItem = { label: item[moreOptions.opKey], value: item[moreOptions.opVal], desc: item[moreOptions.opDesc || 'desc'] }
         remoteOptions.push({ ...item, ...curItem })

+ 6 - 2
src/components/lform/formGroup.jsx

@@ -206,12 +206,12 @@ export default class FormGroup extends Component {
       curRadioObj,
       curImgUrl,
       isCShow,
-      cantonNameObj
+      cantonNameObj,
+      inputDiyType,
     } = this.state
     const { 
       keyStr, 
       keyStr2, 
-      inputType = 'text', 
       moreOptions, 
       labelWidth, 
       labelAlign = 'left', 
@@ -251,6 +251,10 @@ export default class FormGroup extends Component {
         boxClassName += ' ' + defineBoxClassName
       }
     }
+
+    let { inputType = 'text' } = this.state 
+    if (inputDiyType) inputType = inputDiyType
+    
     const bg = require('@img/icon_upload_img.png')
     const signRight = require('@img/icon_sign_right.png')
     const imageSrc = curImgUrl || bg

+ 191 - 54
src/pagesMore/center/uploadRoom2.jsx

@@ -26,10 +26,12 @@ class Index extends Component {
       addr1: '',
       addr2: '',
       addr3: '',
-      remark: '',
-      house_cert: '',
-      formObj: {},
-      imgArr: [],
+      pri_image: '',
+      formObj: {
+        house_type: '1室1厅1卫',
+        hide_status: '1',
+      },
+      imgArr: []
     }
   }
   config = {
@@ -40,29 +42,102 @@ class Index extends Component {
     Taro.$AHU(this)
   }
 
-  commentChange (remark) {
-    this.setState({
-      remark
-    })
+  componentDidMount() {
+    const {id} = this.$router.params
+    if (id) {
+      Taro.api.room.apieshousedetail({id}).then(res => {
+        let cObj = res || {}
+        // console.log(cObj)
+        const addr = cObj.house_no.split('-')
+        Taro.setNavigationBarTitle({
+          title: cObj.sale_user.sale_name + '-编辑房源'
+        })
+        this.setState({
+          formObj: {
+            id: cObj.id,
+            house_type: cObj.house_type || '1室1厅1卫',
+            hide_status: cObj.hide_status || '1',
+            estate_id: cObj.estate_id || '',
+            estate_name: cObj.estate_name || '',
+            title: cObj.title || '',
+            house_no: cObj.house_no || '',
+            delivery_at: cObj.delivery_at || '',
+            price: cObj.price || '',
+            area: cObj.area || '',
+            full_year: cObj.full_year || '',
+            floor: cObj.floor || '',
+            storeys: cObj.storeys || '',
+            is_dec: cObj.is_dec || '',
+            is_elevator: cObj.is_elevator || '',
+            owner: cObj.owner || '',
+            owner_phone: cObj.owner_phone || '',
+            introduce: cObj.introduce || '',
+            remarked: cObj.remarked || '',
+          },
+          pri_image: cObj.pri_image || '',
+          imgArr: (cObj.images && cObj.images.length > 0) ? cObj.images.split(',') : [],
+          addr1: addr[0],
+          addr2: addr[1],
+          addr3: addr[2],
+        })
+      })
+    }
   }
 
+
+
   saveHandle () {
-    const { remark, formObj, imgArr, house_cert } = this.state
-    if (formObj.price && formObj.phone && house_cert) {
-      Taro.api.base.apiuserhouseadd({
-        phone: formObj.phone,
-        price: formObj.price,
-        house_cert: house_cert,
-        remark: remark,
-        images: imgArr.join(','),
-      }).then(res => {
-        this.setState({
-          remark: '',
-          house_cert: '',
-          formObj: {},
-          imgArr: [],
-        })
-        Taro.$msgConfirm('上传成功~我们审核通过后将展现在洪楼房源系统', () => {
+    const { formObj, imgArr, pri_image, addr1, addr2, addr3 } = this.state
+    let house_no = ''
+    if (addr1 && addr2 && addr3) {
+      house_no = `${addr1}-${addr2}-${addr3}`
+    } else {
+      Taro.$msg('请输入楼栋单号房间号')
+      return
+    }
+    // console.log(formObj.estate_id, formObj.title, pri_image)
+    let apiStr = 'apieshouseadd'
+    let params = {
+      estate_id: formObj.estate_id,
+      title: formObj.title,
+      house_no,
+      delivery_at: formObj.delivery_at,
+      house_type: formObj.house_type,
+      price: formObj.price,
+      area: formObj.area,
+      full_year: formObj.full_year,
+      floor: formObj.floor,
+      storeys: formObj.storeys,
+      is_dec: formObj.is_dec,
+      is_elevator: formObj.is_elevator,
+      owner: formObj.owner,
+      owner_phone: formObj.owner_phone,
+      introduce: formObj.introduce,
+      remarked: formObj.remarked,
+      hide_status: formObj.hide_status,
+      pri_image: pri_image,
+      images: imgArr.join(','),
+    }
+    if (formObj.id) {
+      apiStr = 'apieshouseedit'
+      params.id = formObj.id
+    }
+    if (formObj.estate_id && formObj.title && pri_image) {
+      Taro.api.room[apiStr](params).then(res => {
+        if (!formObj.id) {
+          this.setState({
+            pri_image: '',
+            formObj: {
+              house_type: '1室1厅1卫',
+              hide_status: '1',
+            },
+            imgArr: [],
+            addr1: '',
+            addr2: '',
+            addr3: '',
+          })
+        }
+        Taro.$msgConfirm('操作成功', () => {
           Taro.navigateBack({
             delta: 1
           })
@@ -73,7 +148,7 @@ class Index extends Component {
         })
       })
     } else {
-      Taro.$msg('联系人手机号,价格,和房产证图片必填')
+      Taro.$msg('楼盘、标题、封面图必填')
     }
   }
 
@@ -88,7 +163,7 @@ class Index extends Component {
   addHouseCertImg () {
     this.uploadComImg((curImg) => {
       this.setState({
-        house_cert: curImg,
+        pri_image: curImg,
       })
     })
   }
@@ -107,7 +182,7 @@ class Index extends Component {
     const that = this
     Taro.chooseImage({
       count: 1, // 默认9
-      sizeType: ['original', 'compressed'],
+      sizeType: ['compressed'],  // original
       sourceType: ['album', 'camera'],
       success: function (res) {
         const tempFilePaths = res.tempFilePaths
@@ -149,15 +224,18 @@ class Index extends Component {
     })
   }
 
+
+
+
   renderAddr () {
     const { addr1, addr2, addr3 } = this.state
     return (
       <View className="scoped-addr-box">
-        <Input type="number" value={addr1} onInput={this.changeAddrInput.bind(this, 'addr1')}  className="i" />
+        <Input type="number" value={addr1} onInput={this.changeAddrInput.bind(this, 'addr1')}  className="i" placeholder="__" />
         <View className='t'>栋座</View>
-        <Input type="number" value={addr2} onInput={this.changeAddrInput.bind(this, 'addr2')}  className="i" />
+        <Input type="number" value={addr2} onInput={this.changeAddrInput.bind(this, 'addr2')}  className="i" placeholder="__" />
         <View className='t'>单元</View>
-        <Input type="number" value={addr3} onInput={this.changeAddrInput.bind(this, 'addr3')}  className="i" />
+        <Input type="number" value={addr3} onInput={this.changeAddrInput.bind(this, 'addr3')}  className="i" placeholder="__" />
         <View className='t'>室号</View>
       </View>
     )
@@ -168,15 +246,35 @@ class Index extends Component {
     })
   }
 
+  renderFloorHeight () {
+    const { formObj } = this.state
+    return (
+      <View className='scoped-floor-height-box'>
+        <Input type="number" value={formObj.floor} onInput={this.changeFormObjInput.bind(this, 'floor')}  className="i" placeholder="所在楼层" />
+        <View className='t'>/</View>
+        <Input type="number" value={formObj.storeys} onInput={this.changeFormObjInput.bind(this, 'storeys')}  className="i" placeholder="总楼层" />
+        <View className='t'>层</View>
+      </View>
+    )
+  }
+  changeFormObjInput (str, e) {
+    let { formObj } = this.state
+    formObj[str] = e.detail.value
+    this.setState({
+      formObj
+    })
+  }
+
 
 
 
   render () {
-    const { remark, formObj, imgArr, house_cert } = this.state
+    const { formObj, imgArr, pri_image } = this.state
     const dictData = Taro.getStorageSync('dictData')
     const roomDecMoreOptions = {arr: dictData.room_dec}
     const houseRoomYearMoreOptions = {arr: dictData.house_room_year}
     const yesnoMoreOptions = {arr: [...dictData.sys_yesno]}
+    const hideStatusoMoreOptions = {arr: [...dictData.hide_status]}
     const addIcon = require('@img/icon_upload_img.png')
     const closeIcon = require('@img/icon_g_close.png')
     const imgItems = imgArr.map((src, index) => {
@@ -187,7 +285,7 @@ class Index extends Component {
         </View>
       )
     })
-    const moreEstateOptions = {
+    let moreEstateOptions = {
       api: 'house.admestatelist',
       opKey: 'estate_name',
       opVal: 'id',
@@ -196,10 +294,16 @@ class Index extends Component {
     return (
       <View className="l-box">
         <View className="l-floor-pos2">
+          {
+            formObj.estate_name
+            ?
+            <View className='scoped-estate-name'>{formObj.estate_name}[只读]</View>
+            : ''
+          }
           <LFormGroup
             val={formObj.estate_id}
             valStr="estate_id"
-            keyStr="关联楼盘(必填)"
+            keyStr="楼盘(必填)"
             keyStr2="请选择"
             typeStr="radio"
             moreOptions={moreEstateOptions}
@@ -207,16 +311,29 @@ class Index extends Component {
           />
         </View>
         <View className="l-floor-pos2">
+          <LFormGroup
+            val={formObj.title}
+            valStr="title"
+            keyStr="标题(必填)"
+            keyStr2="请总结概括该房源特色"
+            bc={this.baseFormChange.bind(this)}
+          />
+        </View>
+        <View className="l-floor-pos2">
+          <LFormGroup
+            val={formObj.house_no}
+            valStr="house_no"
+            keyStr="地址"
+          />
           {this.renderAddr()}
         </View>
         <View className="l-floor-pos2">
           <LFormGroup
-            val={formObj.xxxxxxxxxx}
-            valStr="xxxxxxxxxx"
-            keyStr="楼层层高"
-            keyStr2="请输入"
-            bc={this.baseFormChange.bind(this)}
+            val={formObj.floor}
+            valStr="floor"
+            keyStr="楼层"
           />
+          {this.renderFloorHeight()}
         </View>
         <View className="l-floor-pos2">
           <LFormGroup
@@ -231,7 +348,7 @@ class Index extends Component {
           <LFormGroup
             val={formObj.area}
             valStr="area"
-            keyStr="建筑面积(必填)"
+            keyStr="建筑面积"
             keyStr2="请输入"
             typeStr="inputFont"
             inputFont="㎡"
@@ -242,7 +359,7 @@ class Index extends Component {
           <LFormGroup
             val={formObj.price}
             valStr="price"
-            keyStr="总价(必填)"
+            keyStr="房屋总价"
             keyStr2="请输入"
             typeStr="inputFont"
             inputFont="万"
@@ -260,8 +377,8 @@ class Index extends Component {
         </View>
         <View className="l-floor-pos2">
           <LFormGroup
-            val={formObj.phone}
-            valStr="phone"
+            val={formObj.owner_phone}
+            valStr="owner_phone"
             keyStr="业主电话"
             keyStr2="请输入"
             bc={this.baseFormChange.bind(this)}
@@ -280,8 +397,8 @@ class Index extends Component {
         </View>
         <View className="l-floor-pos2">
           <LFormGroup
-            val={formObj.how_many_year}
-            valStr="how_many_year"
+            val={formObj.full_year}
+            valStr="full_year"
             keyStr="满几年"
             keyStr2="请选择"
             typeStr="select"
@@ -291,8 +408,8 @@ class Index extends Component {
         </View>
         <View className="l-floor-pos2">
           <LFormGroup
-            val={formObj.xxxxxxxxxxxxxxxx}
-            valStr="xxxxxxxxxxxxxxxx"
+            val={formObj.is_elevator}
+            valStr="is_elevator"
             keyStr="有电梯"
             keyStr2="请选择"
             typeStr="select"
@@ -302,8 +419,8 @@ class Index extends Component {
         </View>
         <View className="l-floor-pos2">
           <LFormGroup
-            val={formObj.xxxxxxxxxxxxxxxxx}
-            valStr="xxxxxxxxxxxxxxxxx"
+            val={formObj.delivery_at}
+            valStr="delivery_at"
             keyStr="交房时间"
             keyStr2="请选择"
             dateFields="month"
@@ -311,16 +428,26 @@ class Index extends Component {
             bc={this.baseFormChange.bind(this)}
           />
         </View>
-
+        <View className="l-floor-pos2">
+          <LFormGroup
+            val={formObj.hide_status}
+            valStr="hide_status"
+            keyStr="显示隐藏"
+            keyStr2="请选择"
+            typeStr="select"
+            moreOptions={hideStatusoMoreOptions}
+            bc={this.baseFormChange.bind(this)}
+          />
+        </View>
 
         <View className="scoped-box">
-          <View className="sb-title">房产证图片(必填)</View>
+          <View className="sb-title">封面主图片(必填)</View>
           <View className="scoped-img">
             {
-              house_cert
+              pri_image
               ?
               <View className="si-op" onClick={this.addHouseCertImg.bind(this)}>
-                <Image src={house_cert} className="img"/>
+                <Image src={pri_image} className="img"/>
               </View>
               :
               <View className="si-op" onClick={this.addHouseCertImg.bind(this)}>
@@ -347,13 +474,23 @@ class Index extends Component {
         <View className="scoped-box">
           <View className="sb-title">更多对外描述</View>
           <AtTextarea
-            value={remark}
-            onChange={this.commentChange.bind(this)}
+            value={formObj.introduce}
+            onChange={this.baseFormChange.bind(this, 'introduce')}
             maxLength={300}
             height={200}
             placeholder='更多需要补充的描述,对外公开(300字以内)'
           />
         </View>
+        <View className="scoped-box">
+          <View className="sb-title">内部备注</View>
+          <AtTextarea
+            value={formObj.remarked}
+            onChange={this.baseFormChange.bind(this, 'remarked')}
+            maxLength={300}
+            height={200}
+            placeholder='仅编辑查看,房源内部备注信息(300字以内)'
+          />
+        </View>
         <View className="l-floor-footer t2">
           <View className="lff-flex">
             <View className="lff-btn full" onClick={this.saveHandle.bind(this)}>提交</View>

+ 52 - 7
src/pagesMore/center/uploadRoom2.scss

@@ -54,21 +54,66 @@
 
 
 .scoped-addr-box {
+  position: absolute;
+  right: 20px;
+  top: 0;
+  width: 70%;
+  z-index: 2;
+  background: #fff;
   display: flex;
-  height: 60px;
-  padding: 20px;
-  border-bottom: 1PX solid #f2f2f2;
+  height: 90px;
+  // border-bottom: 1PX solid #f2f2f2;
   .i {
     flex: 3;
-    font-size: 30px;
-    line-height: 60px;
+    font-size: 28px;
+    line-height: 90px;
     text-align: right;
+    height: 90px;
     padding-right: 10px;
   }
   .t {
     flex: 2;
-    font-size: 30px;
+    font-size: 28px;
     color: #999;
-    line-height: 60px;
+    height: 90px;
+    line-height: 90px;
   }
+}
+
+.scoped-floor-height-box {
+  position: absolute;
+  right: 20px;
+  top: 0;
+  width: 50%;
+  background: #fff;
+  display: flex;
+  height: 90px;
+  z-index: 2;
+  .i {
+    flex: 2;
+    font-size: 28px;
+    line-height: 90px;
+    height: 90px;
+    text-align: center;
+  }
+  .t {
+    flex: 1;
+    font-size: 28px;
+    color: #999;
+    line-height: 90px;
+    height: 90px;
+    text-align: center;
+  }
+}
+
+.scoped-estate-name {
+  position: absolute;
+  right: 20px;
+  top: 0;
+  width: 70%;
+  background: #fff;
+  height: 90px;
+  line-height: 90px;
+  text-align: right;
+  z-index: 9;
 }

+ 18 - 8
src/pagesRoom/dtl.jsx

@@ -44,7 +44,7 @@ class Index extends Component {
   
   getDtl = () => {
     const { curId } = this.state
-    Taro.api.room.apioldhousedetail({id: curId}).then(res => {
+    Taro.api.room.apieshousedetail({id: curId}).then(res => {
       Taro.setNavigationBarTitle({
         title: res.title || '房源详情'
       })
@@ -125,6 +125,16 @@ class Index extends Component {
     })
   }
 
+
+  editHandle () {
+    const { curId } = this.state
+    const appUserInfo = Taro.getStorageSync('APP_userInfo')
+    if (appUserInfo.is_sale == 1) {
+      Taro.navigateTo({
+        url: `/pagesMore/center/uploadRoom2?id=${curId}`
+      })
+    }
+  }
   
   renderMain () {
     const dictData = Taro.getStorageSync('dictData')
@@ -136,8 +146,8 @@ class Index extends Component {
     const { curObj } = this.state
     const tagArr = curObj.custom_tag ? curObj.custom_tag.split(',') : []
     const moreImg = require('./img/dtl/bg_estate.png')
-    const FH = Number(curObj.floor_height) || 1
-    const H = Number(curObj.height) || 1
+    const FH = Number(curObj.floor) || 1
+    const H = Number(curObj.storeys) || 1
     let FHstr = '未知'
     if (FH > H * 0.6666) {
       FHstr = '中高层'
@@ -160,7 +170,7 @@ class Index extends Component {
             })
           }
         </View>
-        <View className="sm-title">{curObj.title}</View>
+        <View className="sm-title" onClick={this.editHandle.bind(this)}>{curObj.title}</View>
         <View className="sm-focus">
           <View className="op">
             <View className="v">{curObj.price}万</View>
@@ -188,16 +198,16 @@ class Index extends Component {
           </View>
           <View className="op">
             <View className="k">楼层:</View>
-            <View className="v">{FHstr}/{curObj.height}层</View>
+            <View className="v">{FHstr}/{curObj.storeys}层</View>
           </View>
           <View className="op">
             <View className="k">满几年:</View>
-            <View className="v">{hryObj[curObj.how_many_year]}</View>
+            <View className="v">{hryObj[curObj.full_year]}</View>
           </View>
-          <View className="op">
+          {/* <View className="op">
             <View className="k">房源类型:</View>
             <View className="v">{ptObj[curObj.product_type]}</View>
-          </View>
+          </View> */}
           <View className="op">
             <View className="k">装修状态:</View>
             <View className="v">{roomDecObj[curObj.is_dec]}</View>

+ 14 - 4
src/pagesRoom/list.jsx

@@ -496,7 +496,7 @@ class Index extends Component {
       productTypeCur,
       estateIdCur,
     } = this.state
-    let apiStr = 'apioldhouselist'
+    let apiStr = 'apieshouselist'
     let params = {
       page,
       page_size,
@@ -553,9 +553,9 @@ class Index extends Component {
     const { dataList, isListEnd, isListLoading, isListEmpty } = this.state
     const itemsList = dataList.map((item, index) => {
       let FHstr = '未知楼层'
-      if (item.floor_height) {
-        const FH = Number(item.floor_height) || 1
-        const H = Number(item.height) || 1
+      if (item.floor) {
+        const FH = Number(item.floor) || 1
+        const H = Number(item.storeys) || 1
         if (FH > H * 0.6666) {
           FHstr = '中高层'
         } else if (FH > H * 0.33333) {
@@ -612,6 +612,16 @@ class Index extends Component {
     Taro.navigateTo({
       url: `/pagesRoom/dtl?id=${item.id}`
     })
+    // const appUserInfo = Taro.getStorageSync('APP_userInfo')
+    // if (appUserInfo.is_sale == 1) {
+    //   Taro.navigateTo({
+    //     url: `/pagesMore/center/uploadRoom2?id=${item.id}`
+    //   })
+    // } else {
+    //   Taro.navigateTo({
+    //     url: `/pagesRoom/dtl?id=${item.id}`
+    //   })
+    // }
   }
 
   render () {