|
@@ -0,0 +1,367 @@
|
|
|
+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 './uploadRoom2.scss'
|
|
|
+
|
|
|
+class Index extends Component {
|
|
|
+
|
|
|
+ onShareAppMessage() {
|
|
|
+ return {
|
|
|
+ title: `自助上传房源`,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ onShareTimeline () {
|
|
|
+ return {
|
|
|
+ title: `自助上传房源`,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ constructor (props) {
|
|
|
+ super(props)
|
|
|
+ this.state = {
|
|
|
+ addr1: '',
|
|
|
+ addr2: '',
|
|
|
+ addr3: '',
|
|
|
+ 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
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ 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" />
|
|
|
+ <View className='t'>栋座</View>
|
|
|
+ <Input type="number" value={addr2} onInput={this.changeAddrInput.bind(this, 'addr2')} className="i" />
|
|
|
+ <View className='t'>单元</View>
|
|
|
+ <Input type="number" value={addr3} onInput={this.changeAddrInput.bind(this, 'addr3')} className="i" />
|
|
|
+ <View className='t'>室号</View>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ changeAddrInput (str, e) {
|
|
|
+ this.setState({
|
|
|
+ [str]: e.detail.value
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ render () {
|
|
|
+ const { remark, formObj, imgArr, house_cert } = 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 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>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ const moreEstateOptions = {
|
|
|
+ api: 'house.admestatelist',
|
|
|
+ opKey: 'estate_name',
|
|
|
+ opVal: 'id',
|
|
|
+ skey: 'estate_name',
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ <View className="l-box">
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.estate_id}
|
|
|
+ valStr="estate_id"
|
|
|
+ keyStr="关联楼盘(必填)"
|
|
|
+ keyStr2="请选择"
|
|
|
+ typeStr="radio"
|
|
|
+ moreOptions={moreEstateOptions}
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ {this.renderAddr()}
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.xxxxxxxxxx}
|
|
|
+ valStr="xxxxxxxxxx"
|
|
|
+ keyStr="楼层层高"
|
|
|
+ keyStr2="请输入"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.house_type}
|
|
|
+ valStr="house_type"
|
|
|
+ keyStr="户型"
|
|
|
+ keyStr2="请输入"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.area}
|
|
|
+ valStr="area"
|
|
|
+ keyStr="建筑面积(必填)"
|
|
|
+ keyStr2="请输入"
|
|
|
+ typeStr="inputFont"
|
|
|
+ inputFont="㎡"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.price}
|
|
|
+ valStr="price"
|
|
|
+ keyStr="总价(必填)"
|
|
|
+ keyStr2="请输入"
|
|
|
+ typeStr="inputFont"
|
|
|
+ inputFont="万"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.owner}
|
|
|
+ valStr="owner"
|
|
|
+ keyStr="业主姓名"
|
|
|
+ keyStr2="请输入"
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <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.is_dec}
|
|
|
+ valStr="is_dec"
|
|
|
+ keyStr="装修情况"
|
|
|
+ keyStr2="请选择"
|
|
|
+ typeStr="select"
|
|
|
+ moreOptions={roomDecMoreOptions}
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.how_many_year}
|
|
|
+ valStr="how_many_year"
|
|
|
+ keyStr="满几年"
|
|
|
+ keyStr2="请选择"
|
|
|
+ typeStr="select"
|
|
|
+ moreOptions={houseRoomYearMoreOptions}
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.xxxxxxxxxxxxxxxx}
|
|
|
+ valStr="xxxxxxxxxxxxxxxx"
|
|
|
+ keyStr="有电梯"
|
|
|
+ keyStr2="请选择"
|
|
|
+ typeStr="select"
|
|
|
+ moreOptions={yesnoMoreOptions}
|
|
|
+ bc={this.baseFormChange.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="l-floor-pos2">
|
|
|
+ <LFormGroup
|
|
|
+ val={formObj.xxxxxxxxxxxxxxxxx}
|
|
|
+ valStr="xxxxxxxxxxxxxxxxx"
|
|
|
+ keyStr="交房时间"
|
|
|
+ keyStr2="请选择"
|
|
|
+ dateFields="month"
|
|
|
+ typeStr="date"
|
|
|
+ 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={remark}
|
|
|
+ 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
|