liujq 2 lat temu
rodzic
commit
93fd62771e

+ 3 - 0
src/api/base.js

@@ -57,4 +57,7 @@ export default {
   apimapestate: params => { // 或者某经纬度周边的楼盘
     return request('/api/map/estate', params, 'loading')
   },
+  apiuserhouseadd: params => { // 自助上传房源
+    return request('/api/user/house/add', params, 'loading')
+  },
 }

+ 1 - 0
src/app.jsx

@@ -78,6 +78,7 @@ class App extends Component {
           'center/sxf',
           'center/saleEdit',
           'center/userEdit',
+          'center/uploadRoom',
           'comment/add',
           'comment/list',
           'comment/dtl',

+ 8 - 1
src/pagesMore/center/index.jsx

@@ -205,7 +205,14 @@ class Index extends Component {
               <Image src={iconSign} className="sign"></Image>
             </View>
           </Navigator>
-          : ''
+          : 
+          <Navigator url="/pagesMore/center/uploadRoom" className="entry-op">
+            <Image src={icon4} className="entry-icon"></Image>
+            <View className="entry-text">上传房源</View>
+            <View className="entry-right">
+              <Image src={iconSign} className="sign"></Image>
+            </View>
+          </Navigator>
         }
         {
           userInfo.is_partner && userInfo.is_partner === '1'

+ 233 - 0
src/pagesMore/center/uploadRoom.jsx

@@ -0,0 +1,233 @@
+import Taro, { Component } from '@tarojs/taro'
+import { View } from '@tarojs/components'
+import { AtTextarea }  from 'taro-ui'
+import LFormGroup from '@/c/lform/formGroup'
+const HLKEY = '654mca0l38b489d9'
+const CJ = require('crypto-js')
+import './uploadRoom.scss'
+
+class Index extends Component {
+
+  onShareAppMessage() {
+    return {
+      title: `自助上传房源`,
+    }
+  }
+  onShareTimeline () {
+    return {
+      title: `自助上传房源`,
+    }
+  }
+
+
+  constructor (props) {
+    super(props)
+    this.state = {
+      remark: '',
+      house_cert: '',
+      formObj: {},
+      imgArr: [],
+    }
+  }
+  config = {
+    navigationBarTitleText: '上传房源',
+  }
+
+  componentWillMount () {
+    Taro.$AHU(this)
+  }
+
+  commentChange (remark) {
+    this.setState({
+      remark
+    })
+  }
+
+  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('上传成功~我们审核通过后将展现在洪楼房源系统', () => {
+          Taro.navigateBack({
+            delta: 1
+          })
+        }, () => {
+          Taro.navigateBack({
+            delta: 1
+          })
+        })
+      })
+    } else {
+      Taro.$msg('联系人手机号,价格,和房产证图片必填')
+    }
+  }
+
+  baseFormChange (key, val) {
+    let { formObj } = this.state
+    formObj[key] = val
+    this.setState({
+      formObj
+    })
+  }
+
+  addHouseCertImg () {
+    this.uploadComImg((curImg) => {
+      this.setState({
+        house_cert: curImg,
+      })
+    })
+  }
+
+  addImg () {
+    this.uploadComImg((curImg) => {
+      let { imgArr } = this.state
+      imgArr.push(curImg)
+      this.setState({
+        imgArr
+      })
+    })
+  }
+  uploadComImg (bc) {
+    let token = Taro.getStorageSync('APP_token')
+    const that = this
+    Taro.chooseImage({
+      count: 1, // 默认9
+      sizeType: ['original', 'compressed'],
+      sourceType: ['album', 'camera'],
+      success: function (res) {
+        const tempFilePaths = res.tempFilePaths
+        Taro.uploadFile({
+          url: `https://api.honglouplus.com/api/upload/cloud`,
+          filePath: tempFilePaths[0],
+          name: 'upload',
+          formData: {
+            'token': token
+          },
+          success (res){
+            const msg = res.data || ''
+            const key = CJ.enc.Utf8.parse(HLKEY)
+            const bytes = CJ.AES.decrypt(msg, key, {
+              mode: CJ.mode.ECB,
+              padding: CJ.pad.Pkcs7
+            })
+            const originalText = bytes.toString(CJ.enc.Utf8)
+            const cData = JSON.parse(originalText)
+            const curImg = cData.data.url || ''
+            if (bc) bc(curImg)
+          }
+        })
+      }
+    })
+  }
+  delImg (index) {
+    let { imgArr } = this.state
+    imgArr.splice(index, 1)
+    this.setState({
+      imgArr
+    })
+  }
+  previewImageHandle (current, arr) {
+    const { imgArr } = this.state
+    Taro.previewImage({
+      current,
+      urls: imgArr
+    })
+  }
+
+  render () {
+    const { feedback_count, formObj, imgArr, house_cert } = this.state
+    const dictData = Taro.getStorageSync('dictData')
+    const addIcon = require('@img/icon_upload_img.png')
+    const closeIcon = require('@img/icon_g_close.png')
+    const imgItems = imgArr.map((src, index) => {
+      return (
+        <View className="si-op" key={index}>
+          <Image src={src} className="img" onClick={this.previewImageHandle.bind(this, src)} />
+          <Image src={closeIcon} className="i" onClick={this.delImg.bind(this, index)}/>
+        </View>
+      )
+    })
+    return (
+      <View className="l-box">
+        <View className="l-floor-pos2">
+          <LFormGroup
+            val={formObj.phone}
+            valStr="phone"
+            keyStr="手机号(必填)"
+            keyStr2="请输入联系方式"
+            bc={this.baseFormChange.bind(this)}
+          />
+        </View>
+        <View className="l-floor-pos2">
+          <LFormGroup
+            val={formObj.price}
+            valStr="price"
+            keyStr="价格(必填)"
+            keyStr2="请输入预期价格"
+            bc={this.baseFormChange.bind(this)}
+          />
+        </View>
+        <View className="scoped-box">
+          <View className="sb-title">房产证图片(必填)</View>
+          <View className="scoped-img">
+            {
+              house_cert
+              ?
+              <View className="si-op" onClick={this.addHouseCertImg.bind(this)}>
+                <Image src={house_cert} className="img"/>
+              </View>
+              :
+              <View className="si-op" onClick={this.addHouseCertImg.bind(this)}>
+                <Image src={addIcon} className="img"/>
+              </View>
+            }
+          </View>
+        </View>
+        <View className="scoped-box">
+          <View className="sb-title">房源图片
+            <View className="s">(最多9张)</View>
+          </View>
+          <View className="scoped-img">
+            {imgItems}
+            {
+              imgArr.length < 9
+              &&
+              <View className="si-op" onClick={this.addImg.bind(this)}>
+                <Image src={addIcon} className="img"/>
+              </View>
+            }
+          </View>
+        </View>
+        <View className="scoped-box">
+          <View className="sb-title">房源描述</View>
+          <AtTextarea
+            value={feedback_count}
+            onChange={this.commentChange.bind(this)}
+            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>
+          </View>
+        </View>
+      </View>
+    )
+  }
+}
+
+export default Index

+ 48 - 0
src/pagesMore/center/uploadRoom.scss

@@ -0,0 +1,48 @@
+@import '@css/mixin.scss';
+.scoped-box {
+  padding: 20px 20px 0;
+  .sb-title {
+    font-size: 30px;
+    color: #333;
+    padding-bottom: 20px;
+    font-weight: bold;
+    padding-left: 10px;
+    .s {
+      display: inline-block;
+      font-size: 24px;
+      color: #999;
+      font-weight: normal;
+    }
+  }
+}
+.at-textarea {
+  border: 1PX solid #f2f2f2;
+}
+.at-textarea__textarea {
+  font-size: 28px;
+  color: #333;
+}
+
+.scoped-img {
+  .si-op {
+    display: inline-block;
+    vertical-align: middle;
+    width: 200px;
+    height: 200px;
+    margin-right: 30px;
+    margin-bottom: 30px;
+    position: relative;
+    border: 1PX solid #f2f2f2;
+    .img {
+      width: 200px;
+      height: 200px;
+    }
+    .i {
+      position: absolute;
+      top: -20px;
+      right: -20px;
+      width: 40px;
+      height: 40px;
+    }
+  }
+}

+ 1 - 3
src/pagesOther/map/vr.jsx

@@ -91,7 +91,6 @@ class Index extends Component {
       if (markerId > 19999 && markerId < 30000) { // 楼盘
         const { allDataArr } = this.state
         const curItem = allDataArr[markerId - 20000]
-        console.log(curItem)
         this.setState({
           curObj: curItem
         }, () => {
@@ -168,7 +167,6 @@ class Index extends Component {
   }
   linkVr () {
     const { curObj } = this.state
-    console.log(curObj)
     Taro.navigateTo({url: `/pagesHouse/vr?id=${curObj.vr_key}&estateName=${curObj.estate_name}`})
   }
 
@@ -185,7 +183,7 @@ class Index extends Component {
           longitude='115.851699'
           latitude='28.644161' 
           enable-poi={false}
-          scale='12'
+          scale='14'
           markers={estateList}
           min-scale="11"
           max-scale="20"