<template>
	<view class="page">
		<view class="item">
			<view class="contents">
				<view class="add-list">
					<view class="list">
						<view class="title">
							<text style="font-weight: bold;">*意向租赁类型</text>
						</view>
						<view class="content" style="text-align: right;">
							<u-input v-model="ruleForm.leaseType" style="text-align: right;" type="select" @click="IdtypeShow = true"
								placeholder='请选择类型' />
						</view>
					</view>
					<view class="list">
						<view class="title">
							<text style="font-weight: bold;">*意向租赁周期</text>
						</view>
						<view class="content">
							<input type="text" placeholder="请输入" v-model="ruleForm.leaseCycle">
						</view>
					</view>
					<view class="list">
						<view class="title">
							<text style="font-weight: bold;">*意向租金(月)</text>
						</view>
						<view class="content">
							<input type="digit"  placeholder="请输入" v-model="ruleForm.rentalRent">
						</view>
					</view>
					<view class="list">
						<view class="title">
							<text style="font-weight: bold;">*意向经营类型</text>
						</view>
						<view class="content">
							<input type="text" placeholder="请输入" v-model="ruleForm.operationType">
						</view>
					</view>
					<view class="list">
						<view class="title">
							<text style="font-weight: bold;">*意向区域</text>
						</view>
						<view class="content">
							<input type="text" placeholder="请输入" v-model="ruleForm.intentionRegion">
						</view>
					</view>
					<view class="item">
						<view class="contents" style="background-color:#fff;">
							<view class="feedback-data">
								<view>
									<view class="title">
										<text style="font-weight: bold;">备注信息</text>

									</view>
								</view>
								<view class="voucher-img">
									<view class="voucher-list" style="width: 100%;">
										<view class="" style="background-color: #F0F0F0;border-radius: 20rpx;">
											<textarea name="" id="" cols="30" rows="10" placeholder="请输入"
												style="font-size: 24rpx;background-color: #F0F0F0;border-radius: 20rpx;width: 96%;margin: 0 auto;padding:10px;"
												v-model="ruleForm.remark"></textarea>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>

				</view>
			</view>
		</view>
		<u-select v-model="IdtypeShow" :list="idType" @confirm="IdtypeChange"></u-select>
		<!-- 保存按钮 -->
		<view class="page-footer">
			<u-button type="success" style="width: 100%;border-radius: 10px;" @click="submit">提交</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fist: [],
				ruleForm: {
					leaseType: '',
					leaseCycle: '',
					rentalRent:null,
					operationType: '',
					remark: '',
					intentionRegion: '',
					source: 1
				},
				idType: [{
					value: 1,
					label: '商铺'
				}, {
					value: 2,
					label: '场地'
				}, {
					value: 3,
					label: '广告位'
				}],
				edit: false,
				IdtypeShow: false,
			}
		},
		onLoad(options) {},
		methods: {
			IdtypeChange(e) {
				this.ruleForm.leaseType = e[0].label;
			},
			chooseLocation(val, item) {
				this.popup1 = true
			},
			choose(val, item) {
				this.popup2 = true
			},
			pops(val) {

				this.ruleForm.warrantyIssue = val[0].label
			},
			pops1(val) {
				this.ruleForm.deviceType = val[0].label
			},
			check() {
				if (!this.ruleForm.leaseType) {
					uni.showToast({
						icon: 'none',
						title: '请选择租赁类型'
					});
					return false;
				}
				if (!this.ruleForm.leaseCycle) {
					uni.showToast({
						icon: 'none',
						title: '请输入租赁周期'
					});
					return false;
				}
				if (!this.ruleForm.rentalRent) {
					uni.showToast({
						icon: 'none',
						title: '请输入意向租金(月)'
					});
					return false;
				}
				
				if (!this.ruleForm.operationType) {
					uni.showToast({
						icon: 'none',
						title: '请输入经营类型'
					});
					return false;
				}
				if (!this.ruleForm.intentionRegion) {
					uni.showToast({
						icon: 'none',
						title: '请输入意向区域'
					});
					return false;
				}


				return true;
			},
			submit() {
				let show = this.check()
				if (show == false) {
					return
				}

				this.ruleForm.phone = uni.getStorageSync('user').phone
				this.$http.sendRequest('/cereCustomerInfo/add', 'POST', this.ruleForm, 1).then(res => {
					if (res.data.code === '20006') {
						uni.showToast({
							icon: 'none',
							title: '请入驻成为商家后再填写'
						})
						uni.switchTab({
							url: '/pagesA/leaseAdd/leaseAdd'
						});
					} else {
						uni.showToast({
							title: '提交成功',
							icon: 'none',
						});
						uni.switchTab({
							url: '/pages/my/my'
						});
					}

				}).catch(err => {
					console.log(err)
					//请求失败
				})



			},
			// 获取时间
			currentTime() {
				let date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1; // 月份从0~11，所以加一
				let day = date.getDate();
				let hours = date.getHours();
				let minutes = date.getMinutes();
				let seconds = date.getSeconds();

				// 为月、日、时、分、秒添加前导零（如果需要）
				month = month < 10 ? '0' + month : month;
				day = day < 10 ? '0' + day : day;
				hours = hours < 10 ? '0' + hours : hours;
				minutes = minutes < 10 ? '0' + minutes : minutes;
				seconds = seconds < 10 ? '0' + seconds : seconds;

				// 拼接日期和时间字符串
				let strDate = `${year}-${month}-${day} ${hours}:${minutes}`;
				return strDate;
			},

			removeList(e, file, fileList) {
				this.ruleForm.shopPhotos.splice(e, 1)
				this.fist.splice(e, 1)
			}
		}
	}
</script>

<style scoped lang="scss">
	.page {
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		background-color: #f6f6f6;
	}

	.add-list {
		padding: 0 4%;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		margin-top: 20rpx;
		width: 100%;

		.list {
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 100%;
			height: 100rpx;
			border-bottom: 2rpx solid #f6f6f6;

			.title {
				display: flex;
				align-items: center;
				height: 100%;

				text {
					font-size: 26rpx;
					color: #222222;
				}

				.star {
					color: red;
				}
			}

			.content {
				display: flex;
				align-items: center;
				text-align: right;

				input {
					width: 100%;
					color: #222222;
					font-size: 26rpx;
					padding-top: 6rpx;
					/* #ifdef MP */
					padding-top: 5rpx;
					/* #endif */
				}

				image {
					width: 20rpx;
					height: 20rpx;
					margin-left: 10rpx;
					/* #ifdef MP */
					margin-top: 5rpx;
					/* #endif */
				}
			}
		}
	}

	/* 保存按钮 */
	.page-footer {
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		z-index: 999;
		width: 100%;
		height: 100rpx;
		background-color: #FFFFFF;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		padding: 0 20px;
	}

	.feedback-data {
		width: 100%;
		padding-bottom: 20rpx;
		border-bottom: 2rpx solid #f6f6f6;

		.title {
			display: flex;
			align-items: center;
			height: 100rpx;

			text {
				font-size: 26rpx;
				color: #222222;
			}

			.star {
				color: red;
			}
		}

		.voucher-img {
			display: flex;
			align-items: center;

			.voucher-list {
				width: 33%;
				height: 100%;

				image {
					width: 160rpx;
					height: 160rpx;
					border-radius: 10rpx;
				}
			}
		}
	}
</style>