230320a303 4 months ago
parent
commit
078fe26c4a

+ 1 - 1
.vscode/settings.json

@@ -1,3 +1,3 @@
 {
-    "stockCode": "sz159819,sh560980,sz159967"
+    "stockCode": "sz300346,sz300919"
 }

+ 3 - 0
src/api/house.js

@@ -63,6 +63,9 @@ export default {
   apiestatenewslist: params => { // 楼盘动态列表接口
     return request('/api/estate/news/list', params)
   },
+  apiestatenewsadd: params => { // 楼盘动态添加
+    return request('/api/estate/news/add', params)
+  },
   apiestatefollow: params => { // 关注楼盘
     return request('/api/estate/follow', params, 'loading')
   },

+ 1 - 0
src/app.jsx

@@ -51,6 +51,7 @@ class App extends Component {
           'photo',
           'photoin',
           'news',
+          'newsEdit',
           'follow',
           'history',
           'search',

+ 27 - 2
src/pagesHouse/news.jsx

@@ -29,6 +29,7 @@ class Index extends Component {
       isListLoading: false,
       isListEmpty: false,
       dataList: [],
+      uoObj: null,
     }
   }
 
@@ -38,10 +39,18 @@ class Index extends Component {
 
   componentWillMount () {
     Taro.$AHU(this)
-    this.getDataList()
+    
+    const uoObj = Taro.getStorageSync('APP_userInfo')
+    if (uoObj) {
+      this.setState({
+        uoObj
+      })
+    }
   }
 
-  componentDidShow () { }
+  componentDidShow () { 
+    this.getDataList()
+  }
 
   componentDidHide () { }
 
@@ -197,11 +206,27 @@ class Index extends Component {
     })
   }
 
+  linkEdit () {
+    const {id, name} = this.$router.params
+    Taro.navigateTo({url: `/pagesHouse/newsEdit?id=${id}&name=${name}`})
+  }
+
   render () {
+    const { uoObj } = this.state
     return (
       <View className="l-box">
         {this.renderTop()}
         {this.renderList()}
+        {
+          uoObj && uoObj.is_sale == 1
+          ?
+          <View className="l-floor-footer">
+            <View className="lff-flex">
+              <View className="lff-btn full" onClick={this.linkEdit.bind(this)}>更新动态</View>
+            </View>
+          </View>
+          : ''
+        }
       </View>
     )
   }

+ 3 - 2
src/pagesHouse/news.scss

@@ -1,10 +1,11 @@
 @import '@css/mixin.scss';
 @import '@css/house-entry.scss';
 .l-box {
-  padding-top: 156px;
+  padding-top: calc(156px);
+  padding-bottom: 110px;
 }
 .l-scroll-view {
-  height: calc(100vh);
+  height: calc(100vh - 156px - 110px);
   box-sizing: border-box;
 }
 .scoped-list {

+ 226 - 0
src/pagesHouse/newsEdit.jsx

@@ -0,0 +1,226 @@
+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 './newsEdit.scss'
+
+class Index extends Component {
+  constructor (props) {
+    super(props)
+    this.state = {
+      trends_cont: '',
+      formObj: {},
+      imgArr: [],
+    }
+  }
+  config = {
+    navigationBarTitleText: '动态更新',
+  }
+
+  componentDidMount () {
+    const { name } = this.$router.params
+    Taro.setNavigationBarTitle({
+      title: name + '-动态更新' || '动态更新'
+    })
+    // Taro.api.base.apisaleuserdetail().then(res => {
+    //   this.setState({
+    //     formObj: {
+    //       title: res.title,
+    //       sale_phone: res.sale_phone,
+    //       custom_tag: res.custom_tag,
+    //     },
+    //     trends_cont: res.trends_cont,
+    //     imgArr: res.sale_avatar ? [res.sale_avatar] : []
+    //   })
+    // })
+    Taro.$AHU(this)
+  }
+
+  commentChange (trends_cont) {
+    this.setState({
+      trends_cont
+    })
+  }
+
+  saveHandle () {
+    const { formObj, imgArr, trends_cont } = this.state
+    const {id: estate_id} = this.$router.params
+    if (formObj.title) {
+      Taro.api.house.apiestatenewsadd({
+        estate_id,
+        title: formObj.title,
+        trends_cont: trends_cont,
+        // trends_cont: 'app',
+        images: imgArr.join(','),
+      }).then(res => {
+        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
+    })
+  }
+
+
+
+
+
+  addImg () {
+    this.uploadComImg((arr) => {
+      let { imgArr } = this.state
+      imgArr = imgArr.length > 0 ? [...imgArr, ...arr] : [...arr]
+      console.log(imgArr)
+      this.setState({
+        imgArr
+      })
+    }, 9)
+  }
+  uploadComImg (bc, count, moreStr) {
+    const that = this
+    Taro.chooseMedia({
+      count: count ? count : 1, // 默认9
+      mediaType: ['image'],
+      sizeType: ['compressed'],  // original
+      sourceType: ['album', 'camera'],
+      success: function (res) {
+        const tempFiles = res.tempFiles
+        if (tempFiles.length > 0) {
+          let imgBcArr = []
+          tempFiles.forEach((p, i) => {
+            that.diyUploadFile(p.tempFilePath, moreStr).then(url => {
+              imgBcArr.push(url)
+              if (bc && imgBcArr.length === tempFiles.length) {
+                bc(imgBcArr)
+              }
+            })
+          })
+        }
+      }
+    })
+  }
+  diyUploadFile (filePath, moreStr) {
+    return new Promise((resolve, reject) => {
+      let token = Taro.getStorageSync('APP_token')
+      let url = `https://api.honglouplus.com/api/upload/cloudpir`
+      if (moreStr === 'noSign') url = `https://api.honglouplus.com/api/upload/cloud`
+      Taro.uploadFile({
+        url,
+        filePath,
+        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 || ''
+          resolve(curImg)
+        }
+      })
+    })
+  }
+  delImg (index) {
+    let { imgArr } = this.state
+    imgArr.splice(index, 1)
+    this.setState({
+      imgArr
+    })
+  }
+  previewImageHandle (current, arr) {
+    const { imgArr } = this.state
+    let nArr = imgArr.map(item => {
+      return item + '_plus'
+    })
+    Taro.previewImage({
+      current,
+      urls: nArr
+    })
+  }
+
+
+
+
+
+  
+  render () {
+    let { formObj, trends_cont  } = 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 + '_plus'} 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.title}
+            valStr="title"
+            keyStr="标题"
+            bc={this.baseFormChange.bind(this)}
+          />
+        </View>
+        <View className="scoped-box">
+          <View className="sb-title">动态内容</View>
+          <AtTextarea
+            value={trends_cont}
+            onChange={this.commentChange.bind(this)}
+            maxLength={300}
+            height={140}
+            placeholder='请输入动态内容(300字以内)'
+          />
+        </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="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/pagesHouse/newsEdit.scss

@@ -0,0 +1,48 @@
+@import '@css/mixin.scss';
+.scoped-box {
+  padding: 20px;
+  .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 - 1
src/pagesMore/center/saleEdit.jsx

@@ -28,7 +28,7 @@ class Index extends Component {
           custom_tag: res.custom_tag,
         },
         auto_reply: res.auto_reply,
-        imgArr: [res.sale_avatar]
+        imgArr: res.sale_avatar ? [res.sale_avatar] : []
       })
     })
     Taro.$AHU(this)

+ 1 - 1
src/pagesMore/center/uploadRoom2.jsx

@@ -440,7 +440,7 @@ class Index extends Component {
   addImg () {
     this.uploadComImg((arr) => {
       let { imgArr } = this.state
-      imgArr = [...imgArr, ...arr]
+      imgArr = imgArr.length > 0 ? [...imgArr, ...arr] : [...arr]
       this.setState({
         imgArr
       })

+ 1 - 1
src/pagesMore/center/uploadRoomHl.jsx

@@ -198,7 +198,7 @@ class Index extends Component {
   addImg () {
     this.uploadComImg((arr) => {
       let { imgArr } = this.state
-      imgArr = [...imgArr, ...arr]
+      imgArr = imgArr.length > 0 ? [...imgArr, ...arr] : [...arr]
       this.setState({
         imgArr
       })

+ 1 - 1
src/pagesRoom/follow/roomAdd.jsx

@@ -282,7 +282,7 @@ class Index extends Component {
   addImg () {
     this.uploadComImg((arr) => {
       let { imgArr } = this.state
-      imgArr = [...imgArr, ...arr]
+      imgArr = imgArr.length > 0 ? [...imgArr, ...arr] : [...arr]
       this.setState({
         imgArr
       })

+ 1 - 1
src/pagesRoom/rentUpload.jsx

@@ -190,7 +190,7 @@ class Index extends Component {
   addImg () {
     this.uploadComImg((arr) => {
       let { imgArr } = this.state
-      imgArr = [...imgArr, ...arr]
+      imgArr = imgArr.length > 0 ? [...imgArr, ...arr] : [...arr]
       this.setState({
         imgArr
       })