|
@@ -0,0 +1,264 @@
|
|
|
+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 './estateTrendUpdate.scss'
|
|
|
+
|
|
|
+class Index extends Component {
|
|
|
+
|
|
|
+
|
|
|
+ constructor (props) {
|
|
|
+ super(props)
|
|
|
+ this.state = {
|
|
|
+ feedback_count: '',
|
|
|
+ formObj: {},
|
|
|
+ imgArr: [],
|
|
|
+ }
|
|
|
+ }
|
|
|
+ config = {
|
|
|
+ navigationBarTitleText: '更新房价动态',
|
|
|
+ }
|
|
|
+
|
|
|
+ componentWillMount () {
|
|
|
+ Taro.$AHU(this)
|
|
|
+ const { t, id } = this.$router.params
|
|
|
+ Taro.setNavigationBarTitle({
|
|
|
+ title: t
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ Taro.api.other.apiestatehousedynamicdetail({id}).then(res => {
|
|
|
+ const rObj = res || {}
|
|
|
+ this.setState({
|
|
|
+ formObj: rObj,
|
|
|
+ // imgArr: rObj.dynamic_img ? rObj.dynamic_img.split(',') : [],
|
|
|
+ // feedback_count: rObj.dynamic,
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+
|
|
|
+ textareaChange (feedback_count) {
|
|
|
+ this.setState({
|
|
|
+ feedback_count
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ saveHandle () {
|
|
|
+ const { id } = this.$router.params
|
|
|
+ const { feedback_count, formObj, imgArr } = this.state
|
|
|
+ if (formObj.price_min) {
|
|
|
+ Taro.api.other.apiestatehousedynamicupdate({
|
|
|
+ id,
|
|
|
+ price_min: formObj.price_min,
|
|
|
+ price_max: formObj.price_max,
|
|
|
+ dynamic: feedback_count,
|
|
|
+ dynamic_img: imgArr.join(','),
|
|
|
+ scene_discount: formObj.scene_discount,
|
|
|
+ actual_discount: formObj.actual_discount,
|
|
|
+ on_sale: formObj.on_sale,
|
|
|
+ for_sale: formObj.for_sale,
|
|
|
+ recommend: formObj.recommend,
|
|
|
+ }).then(res => {
|
|
|
+ this.setState({
|
|
|
+ feedback_count: '',
|
|
|
+ formObj: {},
|
|
|
+ imgArr: [],
|
|
|
+ })
|
|
|
+ Taro.$msgConfirm('更新成功', () => {
|
|
|
+ Taro.reLaunch({
|
|
|
+ url: '/pagesRoom/estateTrend'
|
|
|
+ })
|
|
|
+ }, () => {
|
|
|
+ Taro.reLaunch({
|
|
|
+ url: '/pagesRoom/estateTrend'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ Taro.$msg('起价必填')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ baseFormChange (key, val) {
|
|
|
+ let { formObj } = this.state
|
|
|
+ formObj[key] = val
|
|
|
+ this.setState({
|
|
|
+ formObj
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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.price_min}
|
|
|
+ valStr="price_min"
|
|
|
+ keyStr="起价(必填)"
|
|
|
+ keyStr2="请输入起价"
|
|
|
+ typeStr="inputFont"
|
|
|
+ inputFont="元"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.price_max}
|
|
|
+ valStr="price_max"
|
|
|
+ keyStr="封顶价"
|
|
|
+ keyStr2="请输入封顶价"
|
|
|
+ typeStr="inputFont"
|
|
|
+ inputFont="元"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="scoped-box-w">
|
|
|
+ <View className="scoped-box sbw2">
|
|
|
+ <View className="sb-title">最新动态</View>
|
|
|
+ <AtTextarea
|
|
|
+ value={feedback_count}
|
|
|
+ onChange={this.textareaChange.bind(this)}
|
|
|
+ maxLength={300}
|
|
|
+ height={120}
|
|
|
+ placeholder='请输入最新动态'
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="scoped-box sbw1">
|
|
|
+ <View className="sb-title">动态图片
|
|
|
+ {/* <View className="s">(最多1张)</View> */}
|
|
|
+ </View>
|
|
|
+ <View className="scoped-img">
|
|
|
+ {imgItems}
|
|
|
+ {
|
|
|
+ imgArr.length < 1
|
|
|
+ &&
|
|
|
+ <View className="si-op" onClick={this.addImg.bind(this)}>
|
|
|
+ <Image src={addIcon} className="img"/>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.scene_discount}
|
|
|
+ valStr="scene_discount"
|
|
|
+ keyStr="现场折扣"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.actual_discount}
|
|
|
+ valStr="actual_discount"
|
|
|
+ keyStr="实际折扣"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.on_sale}
|
|
|
+ valStr="on_sale"
|
|
|
+ keyStr="在售楼栋"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.for_sale}
|
|
|
+ valStr="for_sale"
|
|
|
+ keyStr="待售楼栋"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.recommend}
|
|
|
+ valStr="recommend"
|
|
|
+ keyStr="推荐房源"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </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
|