<template>
	<view class="container">
		<view class="form-box">
			<view class="item">
				<view class="label">类型</view>
				<view class="input">
					<u-input height="102" @click="typeShow = true" type="text" disabled input-align="right" v-model="form.isNewName" placeholder="请选择带看类型"></u-input>
					<image class="path" src="/static/path.png" mode="" @click="typeShow = true"/>
					<u-select confirm-color="#FF6D25" v-model="typeShow" :list="typeList" @confirm="confirmType"></u-select>
				</view>
			</view>
			<view class="item">
				<view class="label">地址</view>
				<view class="input">
					<u-input :clearable="false" type="text" input-align="right" v-model="form.address" 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.houseType" 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.houseArea" 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.agentPrice" 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.rentFree" placeholder="请输入免租期"></u-input>
				</view>
			</view>
			
			<view class="item">
				<view class="label">付款方式</view>
				<view class="input">
					<u-input height="102" @click="paymentMethod = true" type="text" disabled input-align="right" v-model="form.paymentMethodName" placeholder="请选择付款方式"></u-input>
					<image class="path" src="/static/path.png" mode="" @click="paymentMethod = true"/>
					<u-select confirm-color="#FF6D25" v-model="paymentMethod" :list="paymentMethodlist" @confirm="confirmPaymentMethod"></u-select>
				</view>
			</view>
			<view class="item">
				<view class="label">装修配货支付总计</view>
				<view class="input">
					<u-input style="width: 320rpx" :clearable="false" type="text" input-align="right" v-model="form.totalPayment" 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.estimateRentPrice" placeholder="请输入预计出租价格"></u-input>
				</view>
			</view>
			<view class="item last-item">
				<view class="label">预估利润</view>
				<view class="input">
					<u-input :clearable="false" type="text" input-align="right" v-model="form.estimateRentPrice" placeholder="请输入预估利润"></u-input>
				</view>
			</view>
		</view>
		<view class="submit-btn" @click="submit">提交</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				typeShow: false,
				paymentMethod: false,
				form: {
					address: '',
					houseType: '',//原始户型新增
					houseArea: '',
					agentPrice: '',
					rentFree: '',
					addressName: '',
					paymentMethod: '',//付款方式1年付2半年付3季付4月付
					totalPayment: '',//装修配货支付总计
					estimateRentPrice:'',//预估出租价格
					isNew: 0,//0 新签 1 续签 类型
					isNewName:''
				},
				typeList: [
					{
						value: 0,
						label: '新签 '
					},
					{
						value: 1,
						label: '续签'
					},
					{
						value: 2,
						label: '其他'
					}
				],
				paymentMethodlist: [
					{
						value: '1',
						label: '年付'
					},
					{
						value: '2',
						label: '半年付'
					},
					{
						value: '3',
						label: '季付'
					},
					{
						value: '4',
						label: '月付'
					},
				]
			};
		},
		onLoad(options) {
		},
		onShow() {
		},
		methods: {
			confirmType(e){
				console.log(e)
				this.form.isNew = e[0].value
				this.form.isNewName = e[0].label
			},
			confirmPaymentMethod(e){
				this.form.paymentMethod = e[0].value
				this.form.paymentMethodName = e[0].label
			},
			submit() {
				if(this.form.isNew==''){
					uni.showToast({
						title: '请选择带看类型',
						icon: 'none'
					})
					return;
				}
				if(this.form.address==''){
					uni.showToast({
						title: '请输入地址',
						icon: 'none'
					})
					return;
				}
				if(this.form.houseArea==''){
					uni.showToast({
						title: '请输入房本面积',
						icon: 'none'
					})
					return;
				}
				if(this.form.paymentMethod==''){
					uni.showToast({
						title: '请选择付款方式',
						icon: 'none'
					})
					return;
				}
				let params = {
					"isNew": this.form.isNew,
					"address": this.form.address,
					"houseType": this.form.houseType,
					"houseArea": this.form.houseArea,
					"agentPrice": [
							{
									"firstYear": "300",
									"secondYear": "200",
									"thirdYear": "100"
							}
						],
					"rentFree": [
							{
									"firstYear": "1",
									"secondYear": "2",
									"thirdYear": "3"
							}
					],
					"paymentMethod": this.form.paymentMethod,
					"totalPayment": this.form.totalPayment,
					"estimateRentPrice": this.form.totalPayment
				}
				this.$u.api.takeHouseApply({body:params}).then((res)=>{
					console.log(res)
				})
			}
		},
	};
</script>

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