<template>
	<view class="container">
		<view class="form-box">
			<view class="item">
				<view class="label">客户姓名</view>
				<view class="input">
					<u-input :clearable="false" type="text" input-align="right" v-model="form.customerName" placeholder="请输入客户姓名"></u-input>
				</view>
			</view>
			<view class="item">
				<view class="label">身份证号</view>
				<view class="input">
					<u-input :clearable="false" type="text" input-align="right" v-model="form.idno" placeholder="请输入身份证号"></u-input>
				</view>
			</view>
			<view class="item">
				<view class="label">客户电话</view>
				<view class="input">
					<u-input :clearable="false" max-length="11" type="text" input-align="right" v-model="form.mobile" placeholder="请输入客户电话"></u-input>
				</view>
			</view>
			<view class="item">
				<view class="label">定金金额(元)</view>
				<view class="input">
					<u-input :clearable="false" type="text" input-align="right" v-model="form.money" placeholder="请输入定金金额"></u-input>
				</view>
			</view>
			<view class="item">
				<view class="label">租金金额(元)</view>
				<view class="input">
					<u-input :clearable="false" type="text" input-align="right" v-model="form.rent_price" placeholder="请输入租金金额"></u-input>
				</view>
			</view>
			<view class="item">
				<view class="label">服务费(元)</view>
				<view class="input">
					<u-input :clearable="false" type="text" input-align="right" v-model="form.fee" placeholder="请输入服务费"></u-input>
				</view>
			</view>
			<view class="item">
				<view class="label">卫生费(元)</view>
				<view class="input">
					<u-input :clearable="false" type="text" input-align="right" v-model="form.ws_fee" placeholder="请输入卫生费"></u-input>
				</view>
			</view>
			<view class="item">
				<view class="label">有线费(元)</view>
				<view class="input">
					<u-input :clearable="false" type="text" input-align="right" v-model="form.tv_price" placeholder="请输入有线费"></u-input>
				</view>
			</view>
			<view class="item">
				<view class="label">付款方式</view>
				<view class="input">
					<u-input height="100" @click="payTypeShow = true" type="text" disabled input-align="right" v-model="form.payTypeName" placeholder="请选择付款方式"></u-input>
					<image class="path" src="/static/path.png" mode="" @click="payTypeShow = true"/>
					<u-select confirm-color="#FF6D25" v-model="payTypeShow" :list="payTypeList" @confirm="confirmPaytype"></u-select>
				</view>
			</view>
			<view class="item">
				<view class="label">租约期限</view>
				<view class="input" >
					<u-input height="100" @click="openCalendar(0)" disabled input-align="right" v-model="form.starDate" placeholder="请选择开始时间"></u-input>
					<image class="calendar" @click="openCalendar(0)" src="/static/kehu/calendar.png" mode=""/>
					<u-calendar :min-date="form.mindate" :max-date="form.maxdate"  v-model="calendarShow1" mode="date" @change="dateConfirm1"></u-calendar>
				</view>
			</view>
			<view class="item">
				<view class="label">至</view>
				<view class="input" >
					<u-input height="100" @click="openCalendar(1)" disabled input-align="right" v-model="form.endDate" placeholder="请选择结束时间"></u-input>
					<image class="calendar" @click="openCalendar(1)" src="/static/kehu/calendar.png" mode=""/>
				</view>
			</view>
			<view class="item">
				<view class="label">签约时间</view>
				<view class="input" >
					<u-input height="100" @click="calendarShow2 = true" disabled input-align="right" v-model="form.rent_date" placeholder="请选择签约时间"></u-input>
					<image class="calendar" @click="calendarShow2 = true" src="/static/kehu/calendar.png" mode=""/>
					<u-calendar v-model="calendarShow2" maxdate='2099-12-31' mode="date" @change="dateConfirm2"></u-calendar>
				</view>
			</view>
		</view>
		<view class="submit-btn" @click="submit">提交</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				mindate: '',
				maxdate: '2099-12-31',
				calendarShow1: false,
				calendarShow2: false,
				payTypeShow: false,
				form: {
					customerName: '',
					mobile: '',
					money: '',
					fee: '',
					rent_price: '',
					idno: '',//身份证号
					endDate:'',
					starDate:'',
					ws_fee: '',
					tv_price: '',
					rent_date: '',
					payment_way:'1',
					payTypeName:''
				},
				payTypeList: [
					{
						value: '1',
						label: '月付'
					},
					{
						value: '3',
						label: '季付'
					},
					{
						value: '6',
						label: '半年付'
					},
					{
						value: '12',
						label: '年付'
					},
				],
				type:0,
				customStyle:{
					maxHeight:'200rpx',
					padding: '20rpx',
					fontSize: '30rpx',
					borderBottom:'1px solid #e0e0e0'
				},
				roomId: ''
			};
		},
		onLoad(options) {
			this.roomId = options.id;
		},
		onShow() {
		
		},
		methods: {
			openCalendar(type){
				if(type==0){
					this.type = 0
					this.form.mindate = ''
					this.form.maxdate = this.form.endDate
				}else{
					this.type = 1
					this.form.mindate = this.form.starDate
					this.form.maxdate = '2099-12-31'
				}
				this.calendarShow1 = true;
			},
			dateConfirm1(e){
				if(this.type==0){
					this.form.starDate = e.result
				}else{
					this.form.endDate = e.result
				}
			},
			dateConfirm2(e){
				this.form.rent_date = e.result
			},
			confirmPaytype(e){
				console.log(e)
				this.form.payment_way = e[0].value
				this.form.payTypeName = e[0].label
			},
			submit() {
				let body={
					// "companyId": 22,
					"roomId": this.roomId,
					"customerName": this.form.customerName,
					"customerTel": this.form.mobile,
					"money": this.form.money,
					"rent_price": this.form.rent_price,
					"fee": this.form.fee,
					"ws_fee": this.form.ws_fee,
					"tv_price": this.form.tv_price,
					"payment_way": this.form.payment_way,
					"rent_date_start":this.form.starDate,
					"rent_date_end": this.form.endDate,
					"rent_date": this.form.rent_date,
					"idno": this.form.idno,
				}
				this.$u.api.appSave({body:body}).then((res)=>{
					console.log(res)
					if(res.ErrNo=='0000'){
						// this.$refs.uToast.show({
						// 	title: res.ErrMsg,
						// 	icon: 'none',
						// 	type:'success'
						// })
						uni.navigateBack()
					}
				})
			},
		},
	};
</script>

<style lang="scss" scoped>
.container {
	width: 750rpx;
	min-height: 100vh;
	background: #F8F8F8;
	padding-top: 20rpx;
	.form-box{
		background: #fff;
		padding: 0 30rpx 150rpx;
		.item{
			height: 100rpx;
			font-size: 30rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
			border-bottom: 1px solid #e0e0e0;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.label{
				width: 200rpx;
				margin-right: 20rpx;
			}
			.input{
				width: 380rpx;
				display: flex;
				align-items: center;
				justify-content: flex-end;
				.path{
					width: 14rpx;
					height: 30rpx;
					margin-left: 20rpx;
				}
				.calendar{
					width: 40rpx;
					height: 40rpx;
					margin-left: 20rpx;
				}

			}
		}
		.last-item{
			display: flex;
			.label{
				line-height: 102rpx;
				font-size: 30rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				margin-right: 150rpx;
			}

		}
	}
	.submit-btn{
		width: 690rpx;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		background: #FF6D25;
		border-radius: 12rpx;
		margin-left: 30rpx;
		font-size: 32rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		position: fixed;
		bottom: 30rpx;
		z-index: 99;
	}
}
</style>
