<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" @click="tomap(roomInfo.address)"><view class="u-line-1">{{roomInfo.address}}</view>
					 <image class="map" src="/static/czDetail/map.png" mode="" /></view>
				<view class="call-info" @click="call(roomInfo.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.houseType}}</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 class="bot-cont">
				<view class="item-btn color1" @click="topage()">改价历史</view>
				<view class="item-btn color2" @click="topage('my/changePrice_check')">改价审核</view>
				<view class="item-btn color3" @click="tohtpage('my/electContract')">成交合同</view>
			</view>
		</view>
		<view class="detail-info">
			<view class="info-item"><view class="label">台账号：</view>{{roomInfo.roomNum}}</view>
			<view class="info-item"><view class="label">区域：</view>{{roomInfo.district}}</view>
			<view class="info-item"><view class="label">部门：</view>{{roomInfo.deptName}}</view>
			<view class="info-item"><view class="label">代理人：</view>{{roomInfo.personName}}</view>
			<view class="info-item"><view class="label">剩余期限：</view>{{roomInfo.remainderPeriod}}个月</view>
			<view class="info-item"><view class="label">截止日期：</view>{{roomInfo.houseDetails}}</view>
		</view>
		<!-- 房间信息 -->
		<view class="room-info" v-if="roomInfo.otherRoom.length">
			<view class="title">房间信息</view>
			<view class="item" v-for="(item,index) in roomInfo.otherRoom" :key="index">
				<view class="left">
					<image class="sex" v-if="item.sex=='男'" src="/static/czDetail/man.png" mode="" />
					<image class="sex" v-else src="/static/czDetail/woman.png" mode="" />
					<view class="number">0{{item.roomType}}</view>
					<view class="other-info">卧·{{item.accountNum}}｜{{item.area||0}}㎡｜{{item.orientation||''}}</view>
				</view>
				<view class="right">
				{{item.sex}}｜{{item.job||''}}
				</view>
			</view>
		</view>
		<view class="bottom-box">
			<view class="item" @click="topage('my/changePrice_apply')">
				<image class="item-icon" src="/static/czDetail/money.png" mode="" />
				<view class="item-text">改价申请</view>
			</view>
			<view class="line"></view>
			<view class="item" @click="sendPassword">
				<image class="item-icon" src="/static/czDetail/lock.png" mode="" />
				<view class="item-text">门锁密码</view>
			</view>
			<view class="line"></view>
			<view class="item" v-if="roomInfo.rentPeriod!=1" @click="toShoudingPage('otherPage/shouding')">
				<image class="item-icon" src="/static/czDetail/money1.png" mode="" />
				<view class="item-text">收定</view>
			</view>
			<view class="line" v-if="roomInfo.rentPeriod!=1"></view>
			<view class="item" @click="topage('otherPage/ledList')">
				<image class="item-icon" src="/static/czDetail/book.png" mode="" />
				<view class="item-text">带看历史</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				picList: [],
				roomId:'',
				roomInfo:{}
			};
		},
		onLoad(options) {
			this.roomId = options.id;
			this.roomInfo = {}
			this.roomInfo = uni.getStorageSync('roomInfo')
			this.roomPictureList()
		},
		onShow() {
		
		},
		methods: {
		// 图片列表
			roomPictureList(){
				this.$u.api.roomPictureList({body:{roomId:this.roomId}}).then((res)=>{
					// 图片类型10 .封面 11.轮播图 
					if(res.result&&res.result.length){
						this.picList = res.result.map(item=>item.pictureUrl)
					}
				})
			},
		// 密码锁
			sendPassword(){
				this.$u.api.sendPassword({body:{roomId:this.roomId}}).then((res)=>{
					if(res.ErrNo=='0000'){
						uni.showToast({
							title: res.ErrMsg,
							icon: 'none',
							duration: 3000
						})
					}
				})
			},
			topage(page){
				uni.navigateTo({
					url: "/pages/" + page +'?id='+this.roomId,
				});
			},
			toShoudingPage(page){
				uni.navigateTo({
					url: "/pages/" + page +'?id='+this.roomId+'&roomNum='+this.roomInfo.roomNum
				});
			},
			tohtpage(page){
				uni.navigateTo({
					url: "/pages/" + page +'?id='+this.roomId+'&roomNum='+this.roomInfo.roomNum
				});
			},
			tomap(info){
				const latitude = 39.9219
				const longitude = 116.44355
				wx.openLocation({
					latitude,
					longitude,
					name: info,
					scale: 18
				})
			},
			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: flex-start;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
			margin-bottom: 24rpx;
			word-break: break-all;
			.label{
				flex: 0 0 145rpx;
				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>
