<template>
	<view class="page">
		<view class="screen-list">
			<view class="list">
				<u-input type="select" @click="typeShow = true"
					:placeholder="pageindex.dataStatus == '1'?'租赁中':pageindex.dataStatus == '3'?'已终止':'状态筛选'" />
			</view>
		</view>
		<!-- 记录列表 -->
		<view class="record-list">
			<view class="record-list-box" v-for="(item,index) in recordList" :key="index"
				@click="item.dataStatus =='1' || item.dataStatus =='3'?recordXq(item):''">
				<view class="list">
					<view class="title" style="padding-bottom: 20rpx;">
						<view class="left">
							<!-- {{item.contractName}} -->
							{{item.cereBasicInformationShop&&item.cereBasicInformationShop.shopName?item.cereBasicInformationShop.shopName:item.cereBasicInformationVenue&&item.cereBasicInformationVenue.venueName?item.cereBasicInformationVenue.venueName:item.cereAdvertisingInformation&&item.cereAdvertisingInformation.advertisingName?item.cereAdvertisingInformation.advertisingName:''}}
						</view>
						<view class="right" v-if="item.dataStatus =='1' || item.dataStatus =='3'"><u-icon
								name="arrow-right"></u-icon></view>
					</view>
					<!-- <view class="info-item">申请时间：{{item.applicationTime}}</view> -->
					<view class="info-item">租赁时间 ：{{item.leaseStartDate}} 至 {{item.contractTerminationDate}}</view>
					<view class="info-item" v-if="item.dataStatus =='1'">状态：<span
							style="color: #0FBB59;">{{item.dataStatus =='1'?'租赁中':item.dataStatus =='3'?'已终止':'-'}}</span>
					</view>
				</view>
			</view>
		</view>
		<view v-if="recordList.length == 0" style="text-align: center;margin-top: 60rpx;color:#808080;">暂无数据</view>
		<u-select v-model="typeShow" :list="activesType" @confirm="typeChange" confirm-color="#808080"></u-select>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				activesType: [
					// {
					// 	value: 1,
					// 	label: '申请中'
					// },
					{
						value: '1',
						label: '租赁中'
					},
					{
						value: '3',
						label: '已终止'
					},
				],
				typeShow: false,
				recordList: [],
				pageindex: {
					dataStatus: '1',
					pageNumber: 0,
					pageSize: 10
				},
				total: 0
			}
		},
		mounted() {
			this.getALL()
		},
		onReachBottom(e) {
			console.error(e)
			if (this.recordList.length < this.total) {
				this.pageindex.pageNumber++
				this.gain()
			}
		},
		methods: {
			getALL() {
				// this.pageindex.relatedMerchants = uni.getStorageSync('user').phone
				this.$http.sendRequest('/cerePlatformMerchant/queryByPage', 'POST', {
					pageSize: 1,
					pageNumber: 0,
					phone: uni.getStorageSync('user').phone
				}, 1).then(res => {
					if (res.data.data.content.length > 0) {
						let c1 = res.data.data.content[0]
						if (c1.checkState == '2') {
							this.pageindex.relatedMerchants = c1.id
							this.gain()
						}
					}
				})
			},
			gain() {
				this.$http.sendRequest('/cereContractInformation/getPage', 'POST', this.pageindex, 1).then(res1 => {
					//成功回调
					console.error(res1)
					this.recordList = [...this.recordList,...res1.data.data.content]
					this.total = res1.data.data.totalElements
				})
			},
			recordXq(item) {

				const encodedItem = encodeURIComponent(JSON.stringify(item));
				uni.navigateTo({
					url: `/pagesA/myZiyuan/myZiDetailsnew?item=${encodedItem}`,
				})
			},
			contractdetail() {
				// uni.navigateTo({

				// })
			},
			typeChange(e) {
				this.pageindex.pageNumber = 0
				this.pageindex.start = e[0].labels
				this.pageindex.dataStatus = e[0].value
				this.recordList = []
				this.getALL()
			},
		
		}
	}
</script>

<style scoped lang="scss">
	@import 'myZiyuan.scss';
</style>