import Taro, { Component } from '@tarojs/taro'
import { View, Map, Image, Swiper, SwiperItem, Button, ScrollView } from '@tarojs/components'
import { arrToObj } from '@utils'
import LoginPopup from '@/c/login/Popup'
import Comment from './components/indexDtl/comment'
import ListMore from '@/c/pageDataList/listMore'
import Header from './components/indexDtl/header'
import News from './components/indexDtl/news'
import Chat from './components/indexDtl/chat/com'
import Rooms from './components/indexDtl/rooms'
import MoreHouse from './components/indexDtl/moreHouse'
import HouseChannel from './components/indexDtl/channel'
import './indexDtl.scss'
class Index extends Component {
onShareAppMessage() {
const userInfo = Taro.getStorageSync('APP_userInfo') || {}
const { curId, curObj } = this.state
if (userInfo.is_sale == 1) {
return {
title: `${userInfo.nickname}给您推荐:${curObj.estate_name}`,
path: `/pagesHouse/indexDtl?id=${curId}&referrer=${userInfo.user_id}`,
}
} else {
return {
title: `${curObj.estate_name}-楼盘详情`,
path: `/pagesHouse/indexDtl?id=${curId}`,
}
}
}
onShareTimeline () {
const userInfo = Taro.getStorageSync('APP_userInfo') || {}
const { curId, curObj } = this.state
if (userInfo.is_sale == 1) {
return {
title: `${userInfo.nickname}给您推荐:${curObj.estate_name}`,
path: `/pagesHouse/indexDtl?id=${curId}&referrer=${userInfo.user_id}`,
}
} else {
return {
title: `${curObj.estate_name}-楼盘详情`,
path: `/pagesHouse/indexDtl?id=${curId}`,
}
}
}
constructor (props) {
super(props)
const {id: curId} = this.$router.params
this.state = {
curId,
curObj: {},
curImgIndex: 0,
isLoginPopupShow: false,
token: '',
userInfo: '',
photoList: [],
buyRuleObj: {},
viewId: '',
referrer: '',
}
}
config = {
navigationBarTitleText: '楼盘详情',
}
componentWillMount () {
let userInfo = Taro.getStorageSync('APP_userInfo')
if (userInfo) {
this.setState({
userInfo
})
}
Taro.removeStorageSync('APP_MY_REFERRER')
const {referrer} = this.$router.params
if (referrer) {
this.setState({
referrer
})
Taro.removeStorageSync('APP_cur_sale')
Taro.setStorageSync("APP_MY_REFERRER", referrer)
}
}
componentDidMount () {
Taro.$AHU(this)
const { curId } = this.state
this.getDtl(() => {
const { curId, curObj } = this.state
let historyRecordArr = Taro.getStorageSync('APP_historyRecord') || []
let cIndex = -1
historyRecordArr.forEach((item, index) => {
if (String(item.id) === String(curId)) {
cIndex = index
}
})
if (cIndex !== -1) historyRecordArr.splice(cIndex, 1)
if (historyRecordArr.length > 19) historyRecordArr.splice(19, 1)
historyRecordArr.unshift(curObj)
Taro.setStorageSync('APP_historyRecord', historyRecordArr)
// Taro.api.house.estatephotolist({estate_id: curId}).then(res => {
// const cArr = res.data ? JSON.parse(res.data) : []
// this.setState({
// photoList: cArr
// })
// })
// Taro.api.other.apiactivityruleinfo({estate_id: curId}).then(res => {
// this.setState({
// buyRuleObj: res.rule || {}
// })
// })
const { scrollInto } = this.$router.params
if (scrollInto === 'comment') {
setTimeout(() => {
this.setState({
viewId: 'stComment'
})
}, 500)
}
})
}
getDtl = (bc) => {
const { fromViews, YH } = this.$router.params
const { curId } = this.state
this.setState({
token: Taro.getStorageSync('APP_token') || ''
})
let params = {
id: curId
}
if (fromViews) params.from = fromViews
// if (YH === 'zzyh' || YH === 'yhjg') {
// Taro.api.house.apiestatelottery2detail(params).then(res => {
// let curObj = res || {}
// curObj.longitude = Number(curObj.longitude)
// curObj.latitude = Number(curObj.latitude)
// this.subComment.getData(curObj || {})
// this.subNews.getData(curObj.information_list || [])
// this.setState({
// curObj
// }, () => {
// if (bc) bc()
// })
// })
// }
Taro.api.house.admestatedetail(params).then(res => {
let curObj = res || {}
curObj.longitude = Number(curObj.longitude)
curObj.latitude = Number(curObj.latitude)
this.setState({
curObj
}, () => {
if (this.subHeader) this.subHeader.getData(curObj || {})
if (this.subComment) this.subComment.getData(curObj || {})
if (this.subNews) this.subNews.getData(curObj.information_list || [])
// if (this.subChat) this.subChat.getData(curObj.estate_sale || [], {name: curObj.estate_name, id: curObj.id})
if (this.subChat) this.subChat.getData({name: curObj.estate_name, id: curObj.id}, 'estateDtl')
if (this.subMoreHouse) this.subMoreHouse.getData(curObj.estate_compete || [])
if (this.subRooms) this.subRooms.getData(curObj.old_house_list || [])
if (this.subChannel) this.subChannel.getData(curObj.estate_channel || [])
if (bc) bc()
})
})
}
componentDidShow () { }
componentDidHide () { }
renderHeader () {
const { curImgIndex, curObj, photoList } = this.state
let morePhoto = []
photoList.forEach(item => {
item.urls.forEach(url => {
morePhoto.push({img_url: `${url}`})
})
})
// if (morePhoto.length > 0) morePhoto.shift()
const imgArr = [{img_url: `${curObj.pri_image}`}, ...morePhoto]
const iconShare = require('@img/images/icon_g_share.png')
return (
{
imgArr.map((item, index) => {
return (
)
})
}
PK
{curImgIndex + 1}/{imgArr.length}
)
}
pkHandle () {
const { curId } = this.state
let oldPkList = Taro.getStorageSync('APP_pkList') || []
let addFalg = true
oldPkList.forEach(item => {
if (String(item.id) === String(curId)) {
addFalg = false
}
})
if (addFalg) {
Taro.api.house.admestatesimple({id: curId}).then(res => {
oldPkList.unshift(res)
if (oldPkList.length > 19) oldPkList.splice(19, 1)
Taro.setStorageSync('APP_pkList', oldPkList)
Taro.navigateTo({
url: '/pagesHouse/pkList'
})
})
} else {
Taro.navigateTo({
url: '/pagesHouse/pkList'
})
}
}
headerImgChange (e) {
this.setState({
curImgIndex: e.detail.current || 0
})
}
previewImageHandle (cur, arr) {
const current = `${cur}_plus`
const urls = arr.map(item => {
return `${item.img_url}_plus`
})
Taro.previewImage({
current,
urls
})
}
renderInfo () {
const { curId, curObj, token } = this.state
const iconPos = require('@img/i_g_pos.png')
const iconHeart = require('@img/i_g_heart.png')
const iconHeartGif = require('@img/i_g_warn.gif')
const iconHeart2 = require('@img/i_g_heart2.png')
const cTagStr = curObj.custom_tag || ''
const tagViews = cTagStr.split(',').map((tag, tagIndex) => {
return (
{tag}
)
})
return (
{curObj.estate_name}
¥{curObj.price_range || 'loading'}/㎡
{
curObj.estate_tag === '售罄'
? {curObj.estate_tag}
: curObj.estate_tag === '待售'
? {curObj.estate_tag}
: {curObj.estate_tag}
}
{tagViews}
{curObj.address}
{
curObj.is_follow
?
已关注
:
关注楼盘
}
)
}
followHandle (apiStr) {
const { curId, curObj } = this.state
Taro.api.house[apiStr]({estate_id: curId}).then(res => {
Taro.$msgConfirm(apiStr === 'apiestatefollow' ? '已关注' + curObj.estate_name : '已取消关注' + curObj.estate_name)
this.getDtl()
})
}
renderEntry () {
const { curId, curObj } = this.state
const icon1 = require('./img/dtl/icon1.png')
const icon2 = require('./img/dtl/icon2.png')
const icon3 = require('./img/dtl/icon3.png')
const icon4 = require('./img/dtl/icon4.png')
const icon5 = require('./img/dtl/icon5.png')
const icon6 = require('./img/dtl/icon6-new.png')
const icon6s = require('./img/dtl/icon6s.png')
const icon7 = require('./img/dtl/icon7.png')
const icon8 = require('./img/dtl/icon8-new.png')
const icon9 = require('./img/dtl/icon9-new.png')
const icon10 = require('./img/dtl/icon10-new.png')
return (
户型图
{
curObj.estate_tag === '二手'
?
二手房源
:
楼盘动态
}
楼盘详情
周边配套
楼盘相册
历史成交
{
curObj.estate_tag === '二手'
?
楼盘评论
:
团购报名
}
纠错补图
房友群
房贷计算
)
}
renderOptionsDkSchool () {
const { curObj } = this.state
return (
对口学校
注:目前该楼盘在此学区中
{this.renderDkSchool()}
)
}
renderDkSchool () {
const { curObj } = this.state
const dictData = Taro.getStorageSync('dictData')
const arr = curObj.school_list.duikou || []
const curItems = arr.map((item, index) => {
return (
{item.school_name}
{item.address}
{arrToObj(dictData.school_attrib)[item.school_attrib]}
{arrToObj(dictData.school_type)[item.school_type]}
)
})
return (
{curItems}
)
}
renderOptionsGhSchool () {
const { curObj } = this.state
return (
可能就读
注:未来该楼盘有可能划入该学校
{this.renderGhSchool()}
)
}
renderGhSchool () {
const { curObj } = this.state
const dictData = Taro.getStorageSync('dictData')
const arr = curObj.school_list.guihua || []
const curItems = arr.map((item, index) => {
return (
{item.school_name}
{item.address}
{arrToObj(dictData.school_attrib)[item.school_attrib]}
{arrToObj(dictData.school_type)[item.school_type]}
)
})
return (
{curItems}
)
}
renderQrcode () {
const qrcodeImg = 'http://icon.honglounews.com/miniqrcode.jpg'
return (
)
}
previewQrcodeImageHandle (current, urls) {
Taro.previewImage({
current,
urls
})
}
renderOptionsInfo () {
const dictData = Taro.getStorageSync('dictData')
const { curObj, curId } = this.state
const product_type = curObj.product_type || ''
const productTypeArr = product_type.split(',').map(v => {
return arrToObj(dictData.product_type)[v]
})
return (
{this.renderQrcode()}
基本信息
更多楼盘详细信息{' >'}
所属区域
{arrToObj(dictData.area_type)[curObj.area_type]}
产品类型
{productTypeArr.length > 0 ? `${productTypeArr.join('/')}` : ''}
参考价格
{curObj.price_range}/㎡
户型面积
{curObj.built_area}㎡
总户数
{curObj.household || '未知'}
车位数
{curObj.parking || '未知'}
绿化率
{curObj.green_rate || '未知'}%
初次交付
{curObj.deliver_time || '未知'}
)
}
renderDesc () {
const { curObj } = this.state
return (
洪楼简评
{curObj.remarked}
)
}
renderProductType () {
const { curObj } = this.state
const aData = curObj.area_data || []
const vrIcon = require('@img/icon_vr.png')
const dictData = Taro.getStorageSync('dictData')
const ptObj = arrToObj(dictData.product_type)
const htObj = arrToObj(dictData.house_type)
let ptArr = []
if (aData) {
aData.map(one =>{
one.house_type_list.map(two => {
two.area_list.map(three => {
ptArr.push({
imgUrl: three.img_url + '_xs',
area: three.area + '㎡',
ptName: ptObj[one.product_type_val],
htName: htObj[two.house_type_val],
vr_key: three.vr_key,
})
})
})
})
}
const pt3Arr = ptArr.slice(0, 3)
return (
户型图
全部户型图{'>>'}
{
pt3Arr.map((item, index) => {
return (
{item.area}({item.ptName})
{
item.vr_key
?
: ''
}
{item.htName}
)
})
}
{
ptArr.length > 2
&&
点击查看更多
}
{
aData.length === 0
&&
}
)
}
morePtLink () {
const { curObj } = this.state
Taro.navigateTo({
url: '/pagesHouse/produceType?id=' + curObj.id + '&name=' + curObj.estate_name
})
}
renderPos () {
const { curObj } = this.state
const markers = [{
longitude: curObj.longitude,
latitude: curObj.latitude,
iconPath: 'https://img2.honglounews.com/20220110041411-6675.png',
width: '20',
height: '20',
id: curObj.id,
label: {
content: curObj.estate_name,
color: '#fff',
fontSize: 12,
anchorX: curObj.estate_name ? - curObj.estate_name.length * 6 : 0,
anchorY: -50,
textAlign: 'center',
bgColor: '#369af7',
padding: 5,
borderRadius: 5,
borderColor: '#f2f2f2',
borderWidth: 1,
}
}]
return (
楼盘位置
)
}
mapHandle () {
const { curId, curObj } = this.state
Taro.navigateTo({
// url: `/pagesOther/map/dtl2?longitude=${curObj.longitude}&latitude=${curObj.latitude}&more=es`
// url: '/pagesHouse/indexDtlAround?id=' + curId + '&name=' + curObj.estate_name
url: '/pagesHouse/indexDtlAround?id=' + curId + '&name=' + curObj.estate_name
})
}
posHandle () {
const { curObj } = this.state
const key = '5WFBZ-LCZ3J-D5AFM-KNUUL-BTT46-45BWB'
const referer = '洪楼Plus'
const location = JSON.stringify({
latitude: curObj.latitude,
longitude: curObj.longitude
})
const category = '地铁公交,医院,购物美食'
Taro.navigateTo({
url: 'plugin://chooseLocation/index?key=' + key + '&referer=' + referer + '&location=' + location + '&category=' + category
})
}
refHeader = (ref) => {
this.subHeader = ref
}
renderOptionsNews () {
return (
洪楼观点
)
}
refNews = (ref) => {
this.subNews = ref
}
refChat = (ref) => {
this.subChat = ref
}
renderRooms () {
const { curObj } = this.state
return (
洪楼房源
查看更多{' >'}
)
}
refRooms = (ref) => {
this.subRooms = ref
}
renderComment () {
const { curObj } = this.state
return (
)
}
refComment = (ref) => {
this.subComment = ref
}
openLoginPopup (obj) {
this.setState({
isLoginPopupShow: true
})
}
closeLoginPopup (str) {
this.setState({
isLoginPopupShow: false
})
if (str && str === 'success') {
this.getDtl()
}
}
getUserProfile (e) {
wx.getUserProfile({
desc: '用于完善头像和昵称资料',
success: (res) => {
const dtlObj = res || {}
this.setState({
userInfo: dtlObj.userInfo
})
Taro.setStorageSync('APP_userInfo', dtlObj.userInfo)
Taro.$msgConfirm(`登录成功~有任何建议或者反馈,可以进个人中心给我们反馈哦`, () => {}, () => {})
}
})
}
linkHome () {
Taro.reLaunch({
url: '/pages/index/index'
})
}
renderGoHome () {
const icon = require('@img/images/icon_go_home.png')
return (
)
}
linkPlan () {
const {id} = this.$router.params
const { curObj } = this.state
Taro.navigateTo({
url: `/pagesPlan/apply2?eId=${id}&eName=${curObj.estate_name}`
})
}
renderPlan () {
const footerBanner = require('./img/dtl/footer_banner.png')
return (
)
}
renderEntryYH () {
const i1 = require('./img/yfyj/yfyj01.png')
const i2 = require('./img/yfyj/yfyj02.png')
const bg = require('./img/yfyj/yfyj03s.jpg')
const { curObj } = this.state
const lotteryObj = curObj.estate_lottery || {}
return (
{lotteryObj.under_way}
{lotteryObj.lottery_time}
)
}
renderYH () {
const { curObj } = this.state
const lotteryObj = curObj.estate_lottery || {}
const bg = require('./img/yfyj/yfyj03s.jpg')
let lotteryImg = []
if (lotteryObj.lottery_img) lotteryImg = lotteryObj.lottery_img.split(',')
return (
{
lotteryObj.lottery_res && lotteryImg.length > 0
&&
{lotteryObj.lottery_res}{'-查看结果>>'}
{/*
摇号结果图
{
lotteryImg.map((hImg, hi) => {
return (
查看大图
)
})
}
*/}
}
)
}
YHImageHandle (current, urls) {
Taro.previewImage({
current,
urls
})
}
linkBuyTg () {
const { curId, curObj } = this.state
Taro.navigateTo({
url: `/pagesPlan/discountGroup?eId=${curId}&eName=${curObj.estate_name}`
})
}
renderBuyTg () {
const iconTg = require('./img/dtl/icon_tg.png')
return (
)
}
renderMoreHouse () {
const { curObj } = this.state
return (
看了这个楼盘还看了
)
}
refMoreHouse = (ref) => {
this.subMoreHouse = ref
}
renderOptionsChannel () {
return (
相关视频
)
}
refChannel = (ref) => {
this.subChannel = ref
}
loginJudge () {
const { userInfo, token } = this.state
const uInfo = userInfo || Taro.getStorageSync('APP_userInfo')
const { isLoginPopupShow } = this.state
return (
{
uInfo && uInfo.avatarUrl
? token || isLoginPopupShow
? ''
:
:
}
)
}
renderAdBanner () {
const { curObj, curId } = this.state
const adBanner = require('./img/dtl/ad_banner3.jpg')
return (
)
}
renderAdBanner2 () {
const adBanner = require('./img/dtl/ad_banner4.jpg')
return (
)
}
callHandle () {
Taro.makePhoneCall({
phoneNumber: '18100792072'
})
}
render () {
const { curObj, buyRuleObj } = this.state
const pages = getCurrentPages()
const pagesLength = pages.length
const schoolList = curObj.school_list || {}
const { YH } = this.$router.params
const lotteryObj = curObj.estate_lottery || {}
const channelList = curObj.estate_channel || []
const { viewId } = this.state
return (
{this.loginJudge()}
{
buyRuleObj.id
&&
this.renderBuyTg()
}
{/* {this.renderHeader()} */}
{this.renderInfo()}
{
curObj.estate_tag === '待售' || curObj.estate_tag === '在售' || curObj.estate_tag === '尾盘'
? this.renderAdBanner()
: this.renderAdBanner2()
}
{/* {
YH === 'yhjg'
&&
this.renderYH()
} */}
{
lotteryObj.lottery_res
? this.renderYH()
:
lotteryObj.under_way
?
this.renderEntryYH()
: ''
}
{this.renderEntry()}
{this.renderOptionsInfo()}
{
curObj.remarked
&&
this.renderDesc()
}
{this.renderProductType()}
{
(curObj.old_house_list && curObj.old_house_list.length > 0)
&& this.renderRooms()
}
{
(curObj.estate_compete && curObj.estate_compete.length > 0)
&& this.renderMoreHouse()
}
{
channelList && channelList.length > 0
&&
this.renderOptionsChannel()
}
{this.renderOptionsNews()}
{
schoolList.duikou && schoolList.duikou.length > 0
&&
this.renderOptionsDkSchool()
}
{
schoolList.guihua && schoolList.guihua.length > 0
&&
this.renderOptionsGhSchool()
}
{this.renderComment()}
{this.renderPos()}
{pagesLength < 3 && this.renderGoHome()}
{/* {this.renderPlan()} */}
)
}
}
export default Index