<template>
	<view class="page">
		<view class="zhutu">
		
				 <swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="500" style="height:100%">
				      <!-- 使用 v-for 指令遍历图片链接数组 -->
				      <swiper-item v-for="(imageUrl, index) in lunbo" :key="index">
				        <!-- u-image 组件用于展示图片 -->
				        <u-image :showLoading="true" :src="imgurl+imageUrl" width="100%" height="100%" border="20"></u-image>
				      </swiper-item>
				    </swiper>
			
			  <!-- <u-image width="100%" height="300rpx" :src="imgurl+record.appendicesContract" border-radius="10"></u-image> -->
			  <!-- <u-image width="100%" height="300rpx" :src="record.cereBasicInformationShop&&record.cereBasicInformationShop.displayMainImage?imgurl + record.cereBasicInformationShop.displayMainImage:record.cereBasicInformationVenue&&record.cereBasicInformationVenue.displayImage?imgurl + record.cereBasicInformationVenue.displayImage:record.cereAdvertisingInformation&&record.cereAdvertisingInformation.locationDiagram?imgurl + record.cereAdvertisingInformation.locationDiagram:''"></u-image> -->
		</view>
		<view class="msglist">
			
			<view class="form-item">
				<view class="label">租赁状态</view>
				<text>{{record.auditStatus =='1'?'待审核':record.auditStatus =='2'?'待签约':record.auditStatus =='3'?'已驳回':record.auditStatus =='4'?'已签约':'已终止'}}</text>
			</view>
			<view class="form-item" v-if="!record.advertisingSpaceType">
				<view class="label">经营用途</view>
				<text>{{record.businessPurpose}}</text>
			</view>
			<view class="form-item">
				<view class="label">租赁期限</view>
				<text>{{heData.contractSigningDate?heData.contractSigningDate+ '至' +heData.contractTerminationDate:'无'}}</text>
			</view>
			<view class="form-item">
				<view class="label">租金</view>
				<text>{{heData.contractAmount || '无'}}</text>
			</view>
			<view class="form-item">
				<view class="label">付款日</view>
				<text>{{heData.paymentDay || '无'}}</text>
			</view>	
		</view>
		<view class="msglist">
		<u-read-more show-height="300" color="#3f9b6a" close-text="查看更多" text-indent="0em"  v-if="mapType == '商铺'">
			<view class="form-item">
				<view class="label">商铺名称</view>
				<text>{{record.cereBasicInformationShop.shopName}}</text>
			</view>
			<view class="form-item">
				<view class="label">商铺类型</view>
				<text>{{record.cereBasicInformationShop.shopType=='1'?'移动铺位':record.cereBasicInformationShop.shopType=='2'?'固定铺位':'无'}}</text>
			</view>
			
			<view class="form-item">
				<view class="label">实际使用面积</view>
				<text>{{record.cereBasicInformationShop.actualUsableArea || '无'}}</text>
			</view>
			<view class="form-item">
				<view class="label">产权面积</view>
				<text>{{record.cereBasicInformationShop.propertyArea || '无' }}</text>
			</view>
			<view class="form-item">
				<view class="label">所属区域</view>
				<text>{{record.cereBasicInformationShop.belongingRegion}}</text>
			</view>
			<view class="form-item">
				<view class="label">归属部门</view>
				<text>{{record.cereBasicInformationShop.belongingDepartment || '无'}}</text>
			</view>
			<view class="form-item">
				<view class="label">详细地址</view>
				<text>{{record.cereBasicInformationShop.detailedLocation}}</text>
			</view>	
			</u-read-more>
			</view>
				
				<view class="msglist" v-if="mapType == '广告位'">
				<u-read-more show-height="300" color="#3f9b6a" close-text="查看更多" text-indent="0em">
					
					<view class="form-item">
						<view class="label">广告位名称</view>
						<text>{{record.cereAdvertisingInformation.advertisingName}}</text>
					</view>
					<view class="form-item">
						<view class="label">广告位类型</view>
						<text>{{record.cereAdvertisingInformation.advertisingType}}</text>
					</view>
					<view class="form-item" v-if="record.cereAdvertisingInformation.advertisingType == '线上广告位'">
						<view class="label">所属端</view>
						<text>{{record.cereAdvertisingInformation.applicationTime}}</text>
					</view>
					<view class="form-item" v-if="record.cereAdvertisingInformation.advertisingType == '实体广告位'">
						<view class="label">广告材质</view>
						<text>{{record.cereAdvertisingInformation.advertisingMaterial}}</text>
					</view>
					<view class="form-item">
						<view class="label">广告尺寸</view>
						<text>{{record.cereAdvertisingInformation.dimensions}}</text>
					</view>
					</u-read-more>
						</view>
						<view class="msglist" v-if="mapType == '场地'">
						<u-read-more show-height="300" color="#3f9b6a" close-text="查看更多" text-indent="0em">
							
							<view class="form-item">
								<view class="label">场地名称</view>
								<text>{{record.cereBasicInformationVenue.venueName}}</text>
							</view>
							<view class="form-item">
								<view class="label">场地类型</view>
								<text>{{record.cereBasicInformationVenue.venueType}}</text>
							</view>
							<view class="form-item">
								<view class="label">实际使用面积</view>
								<text>{{record.cereBasicInformationVenue.actualArea}}</text>
							</view>
							<view class="form-item">
								<view class="label">所属区域</view>
								<text>{{record.cereBasicInformationVenue.district}}</text>
							</view>
							<view class="form-item">
								<view class="label">详细位置</view>
								<text>{{record.cereBasicInformationVenue.detailedLocation}}</text>
							</view>	
							</u-read-more>
								</view>
				
				<view class="msglist"  v-if="btnShow == false&&mapType == '商铺'" style="margin-bottom:80px;">
				
					
					<view class="form-item">
						<view class="label">店铺名称</view>
						<text>{{myshopMsg.shopName}}</text>
					</view>
					<view class="form-item">
						<view class="label">店铺介绍</view>
					</view>
					<view class="" style="background-color: #F0F0F0;border-radius: 20rpx;">
						<view style="padding:10px;">{{myshopMsg.shopDescription}}</view>
					</view>
					<view class="form-item">
						<view class="label">营业时间</view>
					</view>
					<view class="" style="background-color: #F0F0F0;border-radius: 20rpx;">
						<view style="padding:10px;">{{myshopMsg.businessHours}}</view>
					</view>
					<view class="form-item">
						<view class="label">联系电话</view>
						<text>{{myshopMsg.contactNumber}}</text>
					</view>
					<view class="form-item">
						<view class="label">位置描述</view>
					</view>	
					<view class="" style="background-color: #F0F0F0;border-radius: 20rpx;">
						<view style="padding:10px;">{{myshopMsg.locationDescription}}</view>
					</view>
					<view class="form-item">
						<view class="label">店内照片</view>
					</view>
					<view class="image-container">
						<view style="width: 48%;" v-for="(item,index) in myshopMsg.shopPhotos" :key="index">
							<u-image  class="image-item" width="100%"   height="180rpx" border-raduis="10" :src="imgurl+item" ></u-image>
						</view>
						
						
					</view>
						</view>
						
						<view class="msglist"  v-if="mapType == '广告位'"  style="margin-bottom:80px;">
							<view class="form-item">
								<view class="label">投放内容</view>
							</view>

							 <u-image    class="image-item" width="100%" border-raduis="10" mode="heightFix" height="300rpx" :src="imgurl+record.coverImage" ></u-image> 
						

								</view>
								<view style="margin-bottom: 80px;" v-if="btnShow && mapType == '商铺'"><u-button @click="xiuMsg(1)" shape="circle" :custom-style="hoverStyle" hover-class="none" :plain="true">添加我的店铺信息</u-button></view>
						<view class="page-footer" v-if="record.auditStatus =='4'">
							<u-button style="background-color: #DFE0E4; flex: 1; margin: 0 10px;" @click="getQuit('/pagesA/myZiyuan/myZiyuanQuit')"
								>申请退租</u-button>
							<u-button type="success" style="flex: 1; margin: 0 10px;" @click="xuShow = true" >申请续租</u-button>
							<u-button type="success" style="flex: 1; margin: 0 10px;" @click="xiuMsg(2)"  v-if="btnShow == false&&mapType == '商铺'">修改资料</u-button>
						</view>
							<u-modal v-model="xuShow" :content="contentxu" @confirm="xufirm" :show-cancel-button="true" ></u-modal>
							<u-toast ref="uToast" />
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				imgurl:this.$img,
				record:{},
				btnShow:false,
				hoverStyle:{
					
					color:'#3f9b6a'
				},
				mapType:'',
				content:'',
				xuShow:false,
				contentxu:'您确定是否需要续租',
				pageindex: {
					pageNumber: 0,
					pageSize: 10,
					contractId:''
				},
				myshopMsg:{},
				heData:{},
				xuForm: {
				reasonForApplication:'',
				applicationTime:'',
				contractId:0,
				contractType:1,
				createTime:'',
				createUser:'',
				lunbo:[]
					},
			}
		},
		 onLoad(options) {
			   this.imgurl = this.$img
		    const item = JSON.parse(decodeURIComponent(options.item));
		     console.log(item,'1123123213')
			this.record = item
			 let imgsList  = item.cereBasicInformationShop&&item.cereBasicInformationShop.displayMainImage?item.cereBasicInformationShop.displayMainImage:item.cereBasicInformationVenue&&item.cereBasicInformationVenue.displayImage?item.cereBasicInformationVenue.displayImage:item.cereAdvertisingInformation&&item.cereAdvertisingInformation.locationDiagram?item.cereAdvertisingInformation.locationDiagram:''
			  this.lunbo = imgsList.split(',')
			  console.log(this.lunbo)
			let pageHe={
				pageNumber: 0,
				pageSize: 10,
				shopNumber:'',
				dataStatus:1
			}
			if(item.cereBasicInformationShop && item.cereBasicInformationShop.shopName){
				this.mapType = '商铺'
				pageHe.shopNumber = `sp${item.cereBasicInformationShop.id}`
			}else if( item.cereBasicInformationVenue && item.cereBasicInformationVenue.venueName){
				this.mapType = '场地'
				pageHe.shopNumber = `cd${item.cereBasicInformationVenue.id}`
			}else if(item.cereAdvertisingInformation && item.cereAdvertisingInformation.advertisingName){
				this.mapType = '广告位'
				pageHe.shopNumber = `gg${item.cereAdvertisingInformation.id}`
			}
			
			this.$http.sendRequest('/cereContractInformation/getPage', 'POST', pageHe,1).then(res => {
				 if(res.data.data.content[0]){
					 this.heData  = res.data.data.content[0] || {}
					 this.pageindex.contractId = this.heData.id
					 if(this.mapType == '商铺'){
					 	this.$http.sendRequest('/cereAssetShopInformation/queryByPage', 'POST', this.pageindex,1).then(res => {
					 			if(res.data.data.content.length == 0){
					 				this.btnShow = true
					 			}else{
					 				this.btnShow = false
					 				this.myshopMsg = res.data.data.content[0]
					 				this.myshopMsg.shopPhotos = this.myshopMsg.shopPhotos.split(',')
					 					console.log(this.myshopMsg.shopPhotos)
					 				this.myshopMsg.shopPhotos.map(item=>{
					 					item = this.imgurl + item
					 				})
					 				
					 			}
					 	})
					 }
				 }
				
			})
		  },
		  onShow() {
		  	
		  },
		methods: {
			getQuit(urls){
				uni.navigateTo({
					url: urls+`?ids=${this.heData.id}`
				})
			},
			xufirm(){
				
				this.xuForm.createUser = uni.getStorageSync('user').phone
				this.xuForm.createTime = this.getCurrentTime()
				this.xuForm.contractId = Number(this.heData.id)
				this.$http.sendRequest('/changeContractInformation/add', 'POST',this.xuForm, 1).then(res => {
			
									this.$refs.uToast.show({
										title: '续租申请已提交，请耐心等待',
										icon: 'success',
										url: '/pages/my/my'
									})
					
					// uni.switchTab({
					// 	url: '/pages/my/my'
					// })
					// uni.showToast({
					// 	title: '续租申请已提交，请耐心等待',
					// 	icon: 'success',
					// })
				
				})
			},
			xiuMsg(val){
				if(val == 1){
					uni.navigateTo({
						url: `/pagesA/myZiyuan/addMyshop?ids=${this.heData.id}`
					})
				}else{
					let lists = JSON.stringify(this.myshopMsg)
					uni.navigateTo({
						url: `/pagesA/myZiyuan/addMyshop?ids=${this.heData.id}&msg=${lists}`
					})
				}
			},
			getCurrentTime() {
				const now = new Date();
				const year = now.getFullYear();
				const month = ('0' + (now.getMonth() + 1)).slice(-2);
				const day = ('0' + now.getDate()).slice(-2);
				const hours = ('0' + now.getHours()).slice(-2);
				const minutes = ('0' + now.getMinutes()).slice(-2);
				const seconds = ('0' + now.getSeconds()).slice(-2);
			
				return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
			},
		}
	}
</script>

<style scoped lang="scss">
	.page{
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		
		padding: 0 24rpx;
		
	}
	.zhutu{
		margin: 15px 0;
		background-color: #fff;
		width: 100%;
		height: 20vh;
	}

	/* 记录列表 */
	.record-list{
		margin-top: 20rpx;
		.good-item {
			width: 100%;
			display: flex;
			background-color: #fff;
			padding: 16rpx;
			border-radius: 14rpx;
			margin-bottom: 26rpx;
			.img {
				width: 200rpx;
				height: 200rpx;
			}
			.info {
				width: calc(100% - 220rpx);
				margin-left: 20rpx;
				.title {
					width: 100%;
					font-size: 28rpx;
					line-height: 44rpx;
					font-weight: 700;
					white-space: nowrap;
					overflow : hidden;
					text-overflow: ellipsis;
					margin-bottom: 20rpx;
				}
				.info-item {
					display: flex;
					line-height: 30rpx;
					font-size: 26rpx;
					color: #717981;
					text {
						white-space: nowrap;
						overflow : hidden;
						text-overflow: ellipsis;
						margin-left: 10rpx;
						span {
							font-size: 30rpx;
							color: #000;
							font-weight: 700;
						}
					}
					.u-tag {
						margin: 0 6rpx;
						border: unset;
					}
				}
			}
		}
	}
	.msglist{
		padding: 0 30rpx;
		background-color: #Fff;
		border-radius: 14rpx;
		margin-bottom: 20rpx;
		.form-item {
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			line-height: 70rpx;
			border-bottom: #eee solid 1rpx;
			padding: 10rpx 0;
			&[label-top] {
				flex-direction: column;
				justify-content: flex-start;
				align-items: flex-start;
			}
			text {
				font-size: 24rpx;
				color: #3D3D3D;
			}
			.img {
				padding-bottom: 18rpx;
			}
			.deom-box {
				width: 100%;
				display: flex !important;
				margin: 0 -20rpx;
				background-color: #FFFFFF;
				border-radius: 9px;
				// margin-top: 9px;
				width: 100%;
				// .u-upload {
				// .u-add-wrap {
				// 	width: 304rpx !important;
				// 	height: 182rpx !important;
				// }
				// }
				// .u-upload {
				// 	height: 88px;
				// 	width: 155px;
				// 	background: url(/static/images/uploadID1.png);
				// 	background-size:134rpx 188rpx;
				// 	background-repeat:no-repeat;
				// }
				.img-deom {
					flex: 1;
					display: flex;
					flex-direction: column;
					align-items: center;
					padding: 20rpx;
					text {
						margin-top: 18rpx;
					}
				}
			}
		}
		:last-child {
			border-bottom: unset;
		}
	}
	.footbtn{
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 10;
		height:180rpx;
		width: 100%;
		border-radius: 26rpx 26rpx 0 0;
		background-color: #fff;
		.info-total {
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			margin: 24rpx 50rpx;
			font-weight: 700;
			font-size: 24rpx;
			span {
				color: #0FBB59;
				font-size: 32rpx
			}
		}
		.footer-btn {
			display: flex;
			.u-btn {
				width: 40%;
			}
		}
	}
	.page-footer{
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		align-items: center;
		width: 100%;
		background-color: #FFFFFF;
		z-index: 20;
		padding: 15px 0;
		.footer-buy{
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 100%;
			height: 100%;
			.cart-add{
				display: flex;
				align-items: center;
				justify-content: center;
				width: 100%;
				height: 100rpx;
				background-color: #3f9b6a;
				text{
					font-size: 28rpx;
					color: #FFFFFF;
				}
			}
		}
	}
	.image-container {
		padding: 10rpx 0;
	  display: flex;
	  flex-wrap: wrap; /* 启用换行 */
	  justify-content: space-between; /* 图片之间均匀分布 */
	}
	
	.image-item {
	  box-sizing: border-box;
	  margin-bottom: 10rpx; /* 图片之间的垂直间距 */
	}
</style> 
