<template>
	<view class="container">
		<view class="pic-wrap" >
			<u-swiper height="460" :border-radius="0" @click="preview" :list="picList" :autoplay="true" mode="number" indicator-pos="bottomRight"></u-swiper>
		</view>
		<view class="house-info">
			<view class="top-cont">
				<view class="title"><view class="u-line-1">{{roomInfo.address}}</view>
				</view>
				<view class="call-info" @click="call(item.tellPhone)">
					<image class="call" src="/static/czDetail/call.png" mode="" />{{roomInfo.personName}}
				</view>
			</view>
			<view class="mid-cont">
				<view class="item">
					<view class="item-val">{{roomInfo.masterHouseType}}</view>
					<view class="item-type">房型</view>
				</view>
				<view class="item">
					<view class="item-val">{{roomInfo.roomType}}</view>
					<view class="item-type">户型</view>
				</view>
				<view class="item">
					<view class="item-val">{{roomInfo.area}}㎡</view>
					<view class="item-type">面积</view>
				</view>
			</view>
		</view>
		<view class="detail-info">
			<view class="info-item"><view class="label">区域：</view>{{roomInfo.belongDistrict}}</view>
			<view class="info-item"><view class="label">部门：</view>{{roomInfo.deptName}}</view>
			<view class="info-item"><view class="label">代理人：</view>{{roomInfo.personName}}</view>
		</view>
	
		<view class="bottom-box">
			<view class="item" @click="openmodal">
				<!--isStore 0未关注  1关注  -->
				<image class="item-icon" v-if="roomInfo.isStore==1" src="/static/kehu/love.png" mode="" />
				<image class="item-icon" v-else src="/static/czDetail/care_icon.png" mode="" />
				<view class="item-text">关注</view>
			</view>
			<view class="line"></view>
			<view class="item" @click="visitFun">
				<image class="item-icon" src="/static/czDetail/visit_icon.png" mode="" />
				<view class="item-text">拜访</view>
			</view>
			<view class="line"></view>
			<view class="item" @click="topage('otherPage/jjrentFollow')">
				<image class="item-icon" src="/static/czDetail/follow_icon.png" mode="" />
				<view class="item-text">跟进</view>
			</view>
			<view class="line"></view>
			<view class="item" @click="historyList">
				<image class="item-icon" src="/static/czDetail/book.png" mode="" />
				<view class="item-text">历史记录</view>
			</view>
		</view>
		<u-modal v-model="modalShow" :content="tip" :show-cancel-button="true" confirm-color="#FF6D25" title="确认操作" @confirm="careFun" ref="uModal" :async-close="false"></u-modal>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				modalShow: false,
				picList: [],
				roomId:'',
				tip:'',
				roomInfo:{}
			};
		},
		onLoad(options) {
			this.roomId = options.id;
			this.roomInfo = {}
			this.roomInfo = uni.getStorageSync('roomInfo')
			// console.log(this.roomInfo)
			if(this.roomInfo.pictrues&&this.roomInfo.pictrues.length){
				this.picList = this.roomInfo.pictrues.map(item=>
					item.pictureUrl
				)
			}
		},
		methods: {
			//拜访
				visitFun(){
        uni.navigateTo({
					url: '/pages/otherPage/jjrentVisit?masterHouseId='+ this.roomInfo.masterHouseId+'&mediacyId='+ this.roomInfo.mediacyId+'&address='+this.roomInfo.address+'&personName='+this.roomInfo.personName
				})
      },
			historyList(){
        uni.navigateTo({
					url: '/pages/otherPage/historyList?mediacyId='+ this.roomInfo.mediacyId
				})
      },
			openmodal(){
				if(this.roomInfo.isStore==1){
					this.tip = '您确认要取消关注该房源吗'
				}else{
					this.tip = '您确认要关注该房源吗'
				}
				this.modalShow = true
			},
			// 关注，取消关注
			careFun(){
				if(this.roomInfo.isStore==1){
					this.$u.api.cancelStoreUp({body:{mediacyId: this.roomInfo.mediacyId}}).then((res)=>{
						if(res.ErrNo=='0000'){
							this.roomInfo.isStore =0
							uni.showToast({
								title: res.ErrMsg,
								icon: 'none'
							})
						}
					})
				}else{
					this.$u.api.storeUp({body:{masterHouseId:this.roomInfo.masterHouseId,mediacyId: this.roomInfo.mediacyId}}).then((res)=>{
						if(res.ErrNo=='0000'){
							this.roomInfo.isStore = 1
							uni.showToast({
								title: res.ErrMsg,
								icon: 'none'
							})
						}
					})
				}
			},
			topage(page){
				uni.navigateTo({
					url: "/pages/" + page+'?mediacyId='+this.roomInfo.mediacyId+ '&isStore='+this.roomInfo.isStore+'&masterHouseId='+this.roomInfo.masterHouseId
				});
			},
			call(tel){
				wx.makePhoneCall(
					{
						phoneNumber: tel
					}
				)
			},
			preview(e){
				// console.log(e)
				let that = this
				wx.previewImage({
						current: that.picList[e], // 当前显示图片的http链接
						urls: that.picList // 需要预览的图片http链接列表
					})
			}
		},
		onHide: function() {},
	};
</script>

<style lang="scss" scoped>
.container{
	width: 750rpx;
	min-height: 100vh;
	background: #f8f8f8;
	padding-bottom: 150rpx;
	.pic-wrap{
		width: 750rpx;
		height: 460rpx;
	}
	.house-info{
		padding: 30rpx;
		margin-bottom: 20rpx;
		background: #fff;
		.top-cont{
			display: flex;
			justify-content: space-between;
			align-items: center;
			.title{
				max-width: 460rpx;
				height: 44rpx;
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #333333;
				line-height: 44rpx;
				letter-spacing: 1rpx;
				display: flex;
				align-items: center;
				.map{
					flex: 0 0 32rpx;
					width: 32rpx;
					height: 32rpx;
					margin-left: 12rpx;
				}
			}
			.call-info{
				height: 42rpx;
				font-size: 30rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 42rpx;
				display: flex;
				align-items: center;
				.call{
					width: 38rpx;
					height: 38rpx;
					margin-right: 12rpx;
				}
			}
		}
		.mid-cont{
			margin: 28rpx 0;
			display: flex;
			align-items: center;
			justify-content: space-around;
			.item{
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				.item-val{
					height: 44rpx;
					font-size: 32rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #FF6D25;
					line-height: 44rpx;
					margin-bottom: 10rpx;
				}
				.item-type{
					height: 40rpx;
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
					line-height: 40rpx;
				}
			}
		}
		.bot-cont{
			display: flex;
			justify-content: space-around;
			align-items: center;
			.item-btn{
				width: 210rpx;
				height: 64rpx;
				line-height:64rpx;
				text-align: center;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #FFFFFF;
				border-radius: 8rpx;
				&.color1{
					background: #2671E2;
				}
				&.color2{
					background: #07B79D;
				}
				&.color3{
					background: #FF6D25;
				}

			}
		}
	}
	.detail-info{
		background-color: #fff;
		margin-bottom: 20rpx;
		padding: 30rpx;
		.info-item{
			display: flex;
			align-items: center;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
			margin-bottom: 24rpx;

			.label{
				width: 120rpx;
				color: #666666;
			}
		}

	}
	.room-info{
		width: 750rpx;
		padding: 30rpx;
		background: #fff;
		.title{
			height: 44rpx;
			font-size: 32rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #333333;
			line-height: 44rpx;
			margin-bottom: 24rpx;
		}
		.item{
			margin-bottom: 24rpx;
			width: 690rpx;
			height: 80rpx;
			line-height: 80rpx;
			background: #F8F8F8;
			border-radius: 8rpx;
			padding: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.left{
				height: 40rpx;
				font-size: 28rpx;
				color: #333333;
				line-height: 40rpx;
				display: flex;
				align-items: center;
				.sex{
				width: 40rpx;
				height: 40rpx;
				margin-right: 12rpx;
			}
			.number{
				font-weight: 500;
				
			}
			.other-info{
				font-weight: 400;
				font-family: PingFangSC-Regular, PingFang SC;
			}
			}
			.right{
			height: 40rpx;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
			line-height: 40rpx;
			}
			
		}

}
.bottom-box{
	position: fixed;
	/* iphonex 等安全区设置，底部安全区适配 */
	bottom: constant(safe-area-inset-bottom); /* 兼容 iOS < 11.2 */
	bottom: env(safe-area-inset-bottom); /* 兼容 iOS >= 11.2 */
	// box-sizing: content-box;
	width: 750rpx;
	height: 122rpx;
	background: #FFFFFF;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20rpx 46rpx;
	.line{
		width: 1px;
			height: 50rpx;
			background: #E0E0E0;
	}
	.item{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		.item-icon{
			width: 40rpx;
			height: 40rpx;
			margin-bottom: 10rpx;
		}
		.item-text{
			height: 32rpx;
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
			line-height: 32rpx;
		}
	}
}
	
}
</style>
