import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import LoginJudge from '@/c/login/Judge'
import { arrToObj } from '@utils'
import { AtTabs } from 'taro-ui'
import Chat from '@/c/chat/com'
import './roomPriceXk.scss'
class Index extends Component {
onShareAppMessage() {
const {eId, id, name} = this.$router.params
return {
title: `来看看${name}的一房一价表`,
path: `/pagesRoom/roomPrice?eId=${eId}&id=${id}&name=${name}`,
}
}
onShareTimeline () {
const {eId, id, name} = this.$router.params
return {
title: `来看看${name}的一房一价表`,
path: `/pagesRoom/roomPrice?eId=${eId}&id=${id}&name=${name}`,
}
}
constructor (props) {
super(props)
const {eId: curId} = this.$router.params
this.state = {
curId,
curObj: {},
curNav: 0,
roomArr: [],
curRoomObj: {},
houseSaleStateArr: ['未售', '小定', '已定', '已售'],
isDtlShow: false,
buildingNumList: [],
}
}
config = {
navigationBarTitleText: '一房一价表',
navigationBarBackgroundColor: '#369af7',
navigationBarTextStyle: 'white'
}
componentWillMount () {
Taro.$AHU(this)
// const { name } = this.$router.params
// Taro.setNavigationBarTitle({
// title: name + '-一房一价表' || '一房一价表'
// })
const {eId, id} = this.$router.params
Taro.api.house.apiestatelottery2batchinfo({
lottery_id: id,
estate_id: eId,
}).then(res => {
let ll = res.lottery_list || []
let buildingNumList = []
ll.forEach(item => {
const arr = item.building_num.split(',')
arr.forEach(sub => {
buildingNumList.push({
id: item.id,
title: sub,
lottery_time: item.lottery_time
})
})
})
this.setState({
buildingNumList,
curObj: res || {}
}, () => {
this.getDtl()
})
})
}
getDtl = () => {
const { curNav, buildingNumList } = this.state
const {eId, name, id} = this.$router.params
Taro.api.house.apiestatelotterypricelist({
estate_id: eId,
lottery_id: buildingNumList[curNav].id,
building_num: buildingNumList[curNav].title,
}).then(res => {
this.setState({
roomArr: res || []
})
if (this.subChat) {
this.subChat.getData({name, id: eId}, 'pt')
}
})
}
onceGetInfo () {
const {eId} = this.$router.params
const { curObj, curNav, buildingNumList } = this.state
if (curObj.id === buildingNumList[curNav].id) {
return
}
Taro.api.house.apiestatelottery2batchinfo({
lottery_id: buildingNumList[curNav].id,
estate_id: eId,
}).then(res => {
this.setState({
curObj: res || {}
})
})
}
refChat = (ref) => {
this.subChat = ref
}
componentDidShow () { }
componentDidHide () { }
renderTop () {
const {eId, id, name} = this.$router.params
const curParams = `eId=${eId}&id=${id}&name=${name}`
const { curObj, curNav, buildingNumList } = this.state
const nameIcon = require('./img/yfyj/yfyj04.png')
const i1 = require('./img/yfyj/yfyj05.png')
const i2 = require('./img/yfyj/yfyj06.png')
const op1 = require('./img/yfyj/yfyj_icon1.png')
const op2 = require('./img/yfyj/yfyj_icon2.png')
const op3 = require('./img/yfyj/yfyj_icon3.png')
const op4 = require('./img/yfyj/yfyj_icon4.png')
const bg = require('./img/yfyj/bg.jpg')
return (
{name}
返回楼盘详情
{curObj.under_way}
{curObj.lottery_time}
{this.renderQrcode()}
)
}
urlLink (u, params) {
if (u === 'dev') {
Taro.$msg('开发中~敬请期待')
} else {
let url = u
if (params) url += `?${params}`
Taro.navigateTo({
url
})
}
}
navClick (value) {
this.setState({
curNav: value
}, () => {
this.getDtl()
this.onceGetInfo()
})
}
renderQrcode () {
const qrcodeImg = 'http://icon.honglounews.com/miniqrcode.jpg'
return (
)
}
previewQrcodeImageHandle (current, urls) {
Taro.previewImage({
current,
urls
})
}
//
urlDtlLink () {
const { eId } = this.$router.params
Taro.navigateTo({url: '/pagesHouse/indexDtl?id=' + eId + '&YH=zzyh'})
}
renderInfo () {
const { roomArr } = this.state
let cArr = roomArr || []
const htArr = cArr[0] ? cArr[0].data : []
const htArrIndex = htArr.length
const htitems = htArr.map((item, index) => {
let boxClassStr = `'srp-col num'${htArrIndex}`
return (
查看大图
{item.house_type}
{item.built}㎡
{
item.house_rate === '100%'
? ''
:
得房率:{item.house_rate}
}
)
})
return (
户型图
{htitems}
{
cArr.map((one, oIndex) => {
return (
{one.storey}层
{
one.data.map((two, tIndex) => {
const oneDataLength = one.data.length
let boxClassStr2 = `'srp-col num'${oneDataLength}`
if (two.house_sale_state === '小定') boxClassStr2 = `'srp-col t2 num'${oneDataLength}`
if (two.house_sale_state === '已定') boxClassStr2 = `'srp-col t3 num'${oneDataLength}`
if (two.house_sale_state === '已售') boxClassStr2 = `'srp-col t4 num'${oneDataLength}`
return (
{
two.house_sale_state === '小定' || two.house_sale_state === '已定' || two.house_sale_state === '已售'
?
{two.house_sale_state}
: ''
}
{two.room}
{'>>'}
{two.built}㎡
¥{parseInt(two.sale)}/㎡
总价:{(Number(two.price) / 10000).toFixed(1)}万
)
})
}
)
})
}
)
}
previewImageHandle (cur, arr) {
const current = `${cur}_plus`
const urls = arr.map(item => {
return `${item}_plus`
})
Taro.previewImage({
current,
urls
})
}
renderDtl () {
const { isDtlShow, curRoomObj, houseSaleStateArr } = this.state
let boxClassStr = 'p2 t1'
if (curRoomObj.house_sale_state === '小定') boxClassStr = `'p2 t2`
if (curRoomObj.house_sale_state === '已定') boxClassStr = `'p2 t3`
if (curRoomObj.house_sale_state === '已售') boxClassStr = `'p2 t4`
let newTotalPrice = curRoomObj.price
if (curRoomObj.house_discount) {
const hdArr = curRoomObj.house_discount.split(',')
hdArr.forEach(dis1 => {
const oneStr = dis1.substr(0,1)
const otherStr = dis1.substr(1,dis1.length)
if (oneStr === '*'){
newTotalPrice = (Number(newTotalPrice * otherStr).toFixed(2))
}
if (oneStr === '-'){
newTotalPrice = (Number(newTotalPrice - otherStr).toFixed(2))
}
if (oneStr === '+'){
newTotalPrice = (Number(newTotalPrice + otherStr).toFixed(2))
}
})
}
let newOnePrice = Number(newTotalPrice / curRoomObj.built).toFixed(2)
return (
查看大图
{curRoomObj.house_type}
{curRoomObj.building_num}
房号:{curRoomObj.room}
层高:{curRoomObj.floor_height}
建筑面积:{curRoomObj.built}㎡
套内面积:{curRoomObj.built === curRoomObj.space ? '未知' : curRoomObj.space}㎡
公摊面积:{curRoomObj.built === curRoomObj.space ? '未知' : curRoomObj.sharing}㎡
得房率:{curRoomObj.built === curRoomObj.space ? '未知' : curRoomObj.house_rate}
毛坯:{curRoomObj.blank}元/㎡
装修:{curRoomObj.decoration}元/㎡
单价:{curRoomObj.sale}元/㎡
总价:{curRoomObj.price}元
销控数据
{curRoomObj.house_sale_state}{'修改>>'}
折扣:
备注:
折后总价:{newTotalPrice || '暂无'}元
折后单价:{newOnePrice || '暂无'}元/㎡
关闭
保存
)
}
inputCHnage (str, e) {
let { curRoomObj } = this.state
curRoomObj[str] = e.target.value
this.setState({
curRoomObj
})
}
// const { valStr, bc } = this.props
// bc(valStr, strTrim())
onSaleStateChange = e => {
let { curRoomObj, houseSaleStateArr } = this.state
curRoomObj.house_sale_state = houseSaleStateArr[e.detail.value]
this.setState({
curRoomObj
})
}
openDtlPopup (item) {
this.setState({
curRoomObj: item,
isDtlShow: true
})
}
closeRulePopup (str) {
this.setState({
curRoomObj: {},
isDtlShow: false
})
if (str === 'edit') {
let { curRoomObj } = this.state
let house_discount = curRoomObj.house_discount.replace(/,|、|\/|\\/g, ',')
Taro.api.house.apiestatelotterypriceedit({
id: curRoomObj.id,
house_sale_state: curRoomObj.house_sale_state,
house_sale_remark: curRoomObj.house_sale_remark || '',
house_discount,
}).then(res => {
this.getDtl()
})
}
}
renderShare () {
const iconShare = require('@img/images/icon_g_share6.png')
return (
)
}
render () {
return (
{this.renderTop()}
{this.renderInfo()}
{this.renderDtl()}
{this.renderShare()}
)
}
}
export default Index