uniapp 合同 from表单模版

<template>
	<view class="wrap">
		<!-- <view style="width: 750rpx;height: 20rpx;background-color: aliceblue;"> -->
		<!-- </view> -->
		<form @submit="formSubmit" @reset="formReset">
			<view class="form_item_h">
				<view class="h">
					合同签约
				</view>
			</view>
			<view class="form_item">
				<view class="label">
					<text class="label_text"></text><text>门店名称</text>
				</view>
				<view class="input">
					{{deptName}}
				</view>
			</view>
			<view class="form_item">
				<view class="label">
					<text class="label_text"></text><text>户型类型</text>
				</view>
				<view class="input">
					{{modelName}}
				</view>
			</view>
			<view class="form_item">
				<view class="label">
					<text class="label_text"></text><text>房源号</text>
				</view>
				<view class="input">
					{{roomNum}}
				</view>
			</view>
			<view class="form_item">
				<view class="label">
					<text class="label_text"></text><text>租金</text>
				</view>
				<view class="input" style="color: #ff5a00;">
					{{mon}}
				</view>
			</view>

			<!-- 	<view class="form_item">
				<view class="label">
					<text class="label_text"></text><text>押金</text>
				</view>
				<picker class="input" :value="payTypeIndex" :range="payType" @change="payTypePciker">
					<view v-if="payTypeIndex==''">
						请选择租赁时长
					</view>
					<view v-else>
						{{payType[payTypeIndex]}}
					</view>
				</picker>
			</view> -->

			<!-- 	<view class="form_item">
				<view class="label">
					<text class="label_text">*</text><text>缴纳类型</text>
				</view>
				<picker class="input" :value="payTypeIndex" :range="payType" @change="payTypePciker">
					<view v-if="payTypeIndex==''">
						请选择缴纳类型
					</view>
					<view v-else>
						{{payType[payTypeIndex]}}
					</view>
				</picker>
			</view> -->
			<view class="form_item">
				<view class="label">
					<text class="label_text">*</text><text>主体</text>
				</view>
				<picker class="input" :value="entityIndex" :range="entity" @change="entityPciker">
					<!-- <view v-if="entityIndex==''">
						请选择主体
					</view>
					<view v-else> -->
					<view>
						{{entity[entityIndex]}}
					</view>
				</picker>
			</view>

			<view class="form_item">
				<view class="label">
					<text class="label_text">*</text><text>合同生效日期</text>
				</view>
				<picker class="input" mode="date" :value="date" :start="startDate" :end="endDate"
					@change="bindDateChange">
					<view v-if="date==''" style="color: #AAACAB;">
						请选择合同生效日期
					</view>
					<view v-else>
						{{date}}
					</view>
				</picker>
			</view>

			<view class="form_item">
				<view class="label">
					<text class="label_text">*</text><text>租赁时长</text>
				</view>
				<picker class="input" :value="timeIndex" :range="time" :range-key="'dictLabel'" @change="timePciker">
					<!-- <picker class="input" :value="timeIndex" :range="time" @change="timePciker"> -->
					<view v-if="timeIndex==''" style="color: #AAACAB;">
						请选择租赁时长
					</view>
					<view v-else>
						{{time[timeIndex].dictLabel}}
					</view>
				</picker>
			</view>

			<view class="form_item" v-if="timeIndex!=''&&date!=''">
				<view class="label">
					<text class="label_text"></text><text>合同结束日期</text>
				</view>
				<view class="input">
					{{all.endTime}}
				</view>
			</view>
			<view class="form_item" v-if="timeIndex!=''&&date!=''">
				<view class="label">
					<text class="label_text"></text><text>押金</text>
				</view>
				<view class="input" style="color: #ff5a00;">
					{{all.contractDeposit}}
				</view>
			</view>
			<view class="form_item" v-if="timeIndex!=''&&date!=''">
				<view class="label">
					<text class="label_text"></text><text>租赁总额</text>
				</view>
				<view class="input" style="color: #ff5a00;">
					{{all.rentalAmount}}
				</view>
			</view>

			<view class="form_item">
				<view class="label">
					<text class="label_text">*</text><text>缴纳方式</text>
				</view>
				<picker class="input" :value="payIndex" :range="pay" :range-key="'dictLabel'" @change="payPciker">
					<view v-if="payIndex==''" style="color: #AAACAB;">
						请选择缴纳方式
					</view>
					<view v-else>
						{{pay[payIndex].dictLabel}}
					</view>
				</picker>
			</view>

			<!-- <view class="form_item_logo" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>主体证明</text>
				</view>
				<view v-if="logo == ''" class="input flex" @click="upload">
					<view>
						请上传主体证明照片
					</view>
					<image class="flex_logo" src="/static/arrow_right.png">
					</image>
				</view>
			</view> -->
			<view v-if="entityIndex==1">
				<view class="from_file" style="border: none;">
					<view class="label">
						<text class="label_text">*</text><text>营业执照</text>
					</view>
				</view>
				<uni-file-picker class="file" v-model="entityFile" fileMediatype="image" limit="1" mode="grid"
					@select="entitySelect" @progress="entityProgress" @success="entitySuccess" @fail="entityFail"
					@delete="entityDel" />
			</view>

			<view class="form_item" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>单位名称</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入单位名称" v-model="enterpriseName">
			</view>

			<view class="form_item" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>单位地址</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入单位地址" v-model="enterpriseAddress">
			</view>

			<!-- 	<view class="form_item" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>企业代码</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入单位代码" v-model="enterpriseCode">
			</view> -->

			<view class="form_item" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>开户行</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入单位开户行" v-model="bankAddress">
			</view>
			<view class="form_item" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>账号</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入单位对公账号" v-model="bank">
			</view>
			<view class="form_item" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>税号</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入单位税号" v-model="validCode">
			</view>

			<!-- 	<view class="form_item_logo">
				<view class="label">
					<text class="label_text">*</text><text>银行卡照片</text>
				</view>
				<view v-if="logo == ''" class="input flex" @click="upload">
					<view>
						请上传银行卡照片
					</view>
					<image class="flex_logo" src="/static/arrow_right.png">
					</image>
				</view>
			
				<image v-else class="logo" :src="utils.imgUrl(list.image)" @click="upload"></image>
			</view> -->

			<view class="from_file" style="border: none;" v-if="entityIndex==0">
				<view class="label">
					<text class="label_text">*</text><text>身份证正面</text>
				</view>
			</view>
			<uni-file-picker class="file" v-if="entityIndex==0" v-model="idFrontFile" fileMediatype="image" limit="1"
				mode="grid" @select="idFrontSelect" @progress="idFrontProgress" @success="idFrontSuccess"
				@fail="idFrontFail" @delete="idFrontDel" />

			<view class="from_file" style="border: none;" v-if="entityIndex==0">
				<view class="label">
					<text class="label_text">*</text><text>身份证反面</text>
				</view>
			</view>
			<uni-file-picker class="file" v-if="entityIndex==0" v-model="idOppositeFile" fileMediatype="image" limit="1"
				mode="grid" @select="idOppositeSelect" @progress="idOppositeProgress" @success="idOppositeSuccess"
				@fail="idFail" @delete="idDel" />

			<view class="form_item" v-if="entityIndex==0">
				<view class="label">
					<text class="label_text">*</text><text>身份证</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入身份证" v-model="id">
			</view>

			<view class="form_item" v-if="entityIndex==0">
				<view class="label">
					<text class="label_text">*</text><text>姓名</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入姓名" v-model="name">
			</view>

			<view class="form_item" v-if="entityIndex==0">
				<view class="label">
					<text class="label_text">*</text><text>户籍所在地</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入户籍所在地" v-model="address">
			</view>

			<view class="form_item">
				<view class="label">
					<text class="label_text">*</text><text>联系电话</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入联系电话" v-model="phoneNum">
			</view>
			<!-- <view class="form_item">
				<view class="label">
					<text class="label_text">*</text><text>收件人</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入收件人" v-model="list.address">
			</view> -->



			<!-- 	<view class="form_item">
				<view class="label">
					<text class="label_text"></text><text>企业宣传语</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入企业宣传语" v-model="list.propaganda">
			</view> -->
			<!-- <view class="form_item">
				<view class="label">
					<text class="label_text"></text><text>企业网址</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入企业网址" v-model="list.website">
			</view> -->

			<!-- <view class="form_item">
				<view class="label">
					<text class="label_text">*</text><text>紧急联系人</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入紧急联系人" v-model="emergencyContact">
			</view>

			<view class="form_item">
				<view class="label">
					<text class="label_text">*</text><text>紧急联系电话</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入紧急联系电话" v-model="emergencyTel">
			</view> -->

			<view class="form_item" v-if="entityIndex==0">
				<view class="label">
					<text class="label_text"></text><text>个人邮箱</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入个人邮箱" v-model="mailbox">
			</view>
			<view v-if="entityIndex==1">
				<view class="from_file" style="border: none;">
					<view class="label">
						<text class="label_text">*</text><text>法人身份证正面</text>
					</view>
				</view>
				<uni-file-picker class="file" v-model="fridFrontFile" fileMediatype="image" limit="1" mode="grid"
					@select="fridFrontSelect" @progress="fridFrontProgress" @success="fridFrontSuccess"
					@fail="fridFrontFail" @delete="fridFrontDel" />
			</view>
			<view v-if="entityIndex==1">
				<view class="from_file" style="border: none;">
					<view class="label">
						<text class="label_text">*</text><text>法人身份证反面</text>
					</view>
				</view>
				<uni-file-picker class="file" v-model="fridOppositeFile" fileMediatype="image" limit="1" mode="grid"
					@select="fridOppositeSelect" @progress="fridOppositeProgress" @success="fridOppositeSuccess"
					@fail="fridOppositeFail" @delete="fridOppositeDel" />
			</view>
			<view class="form_item" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>法人身份证</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入法人身份证" v-model="frid">
			</view>

			<view class="form_item" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>法人姓名</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入法人姓名" v-model="frname">
			</view>

			<view class="form_item" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>法人户籍所在地</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入法人户籍所在地" v-model="fraddress">
			</view>

			<!-- 承租人 -->
			<view class="form_item_h" v-if="entityIndex==1">
				<view class="h">
					承租人信息
				</view>
			</view>
			<view v-if="entityIndex==1">
				<view class="from_file" style="border: none;">
					<view class="label">
						<text class="label_text">*</text><text>承租人身份证正面</text>
					</view>
				</view>
				<uni-file-picker class="file" v-model="czridFrontFile" fileMediatype="image" limit="1" mode="grid"
					@select="czridFrontFileSelect" @progress="czridFrontFileProgress" @success="czridFrontFileSuccess"
					@fail="czridFrontFileFail" @delete="czridFrontFileDel" />
			</view>
			<view v-if="entityIndex==1">
				<view class="from_file" style="border: none;">
					<view class="label">
						<text class="label_text">*</text><text>承租人身份证反面</text>
					</view>
				</view>
				<uni-file-picker class="file" v-model="czridOppositeFile" fileMediatype="image" limit="1" mode="grid"
					@select="czridOppositeSelect" @progress="czridOppositeProgress" @success="czridOppositeSuccess"
					@fail="czridOppositeFail" @delete="czridOppositeDel" />
			</view>
			<view class="form_item" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>姓名</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入承租人姓名" v-model="czrtogetherName">
			</view>
			<view class="form_item" v-if="entityIndex==1">
				<view class="label">
					<text class="label_text">*</text><text>身份证</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入承租人身份证" v-model="czrtogetherNum">
			</view><!-- 授权委托书 -->
			<view v-if="entityIndex==1">
				<view class="from_file" style="border: none;">
					<view class="label">
						<text class="label_text">*</text><text>授权委托书</text>
					</view>
				</view>
				<uni-file-picker class="file" v-model="sqwtFile" fileMediatype="image" limit="1" mode="grid"
					@select="sqwtSelect" @progress="sqwtProgress" @success="sqwtSuccess" @fail="sqwtFail"
					@delete="sqwtDel" />
			</view>



			<!-- 同住人信息 -->
			<view class="form_item_h" v-if="entityIndex==0">
				<view class="h">
					同住人信息
				</view>
			</view>
			<view v-if="entityIndex==0">
				<view class="from_file" style="border: none;">
					<view class="label">
						<text class="label_text"></text><text>同住人身份证正面</text>
					</view>
				</view>
				<uni-file-picker class="file" v-model="tzridFrontFile" fileMediatype="image" limit="1" mode="grid"
					@select="tzridFrontFileSelect" @progress="tzridFrontFileProgress" @success="tzridFrontFileSuccess"
					@fail="tzridFrontFileFail" @delete="tzridFrontFileDel" />
			</view>
			<view v-if="entityIndex==0">
				<view class="from_file" style="border: none;">
					<view class="label">
						<text class="label_text"></text><text>同住人身份证反面</text>
					</view>
				</view>
				<uni-file-picker class="file" v-model="tzridOppositeFile" fileMediatype="image" limit="1" mode="grid"
					@select="tzridOppositeSelect" @progress="tzridOppositeProgress" @success="tzridOppositeSuccess"
					@fail="tzridOppositeFail" @delete="tzridOppositeDel" />
			</view>
			<view class="form_item" v-if="entityIndex==0">
				<view class="label">
					<text class="label_text"></text><text>姓名</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入同住人姓名" v-model="togetherName">
			</view>
			<view class="form_item" v-if="entityIndex==0">
				<view class="label">
					<text class="label_text"></text><text>身份证</text>
				</view>
				<input type="text" placeholder-class="font_size" placeholder="请输入同住人身份证" v-model="togetherNum">
			</view>


			<button id="submit" @click="submit">提交保存</button>
		</form>
		<view style="width: 750rpx;height: 30rpx;">
		</view>
	</view>
</template>

<script module="utils" lang="wxs" src="../../utils/imgSrc.wxs"></script>

<script>
	import config from '../../config.js';

	import {
		throttle
	} from "@/utils/throttle.js"

	export default {
		data() {
			return {
				deptName: uni.getStorageSync('deptName'),
				modelName: uni.getStorageSync('modelName'),
				roomNum: uni.getStorageSync('roomNum'),
				mon: uni.getStorageSync('mon'),

				all: '',

				// 合同生效日期
				date: '',
				startDate: '',
				endDate: '',

				sex: ['男', '女'],
				sexIndex: '',
				entity: ['个人', '单位'],
				entityIndex: 0,
				pay: [],
				payIndex: '',
				payType: ['线上', '线下'],
				payTypeIndex: '',
				time: [],
				timeIndex: '',

				entityFile: [],
				sqwtFile: [],
				idFrontFile: [],
				tzridFrontFile: [],
				czridFrontFile: [],
				fridFrontFile: [],

				idOppositeFile: [],
				tzridOppositeFile: [],
				czridOppositeFile: [],
				fridOppositeFile: [],

				idFrontFileUrl: '',
				tzridFrontFileUrl: '',
				czridFrontFileUrl: '',
				fridFrontFileUrl: '',
				sqwtFileUrl: '',

				idOppositeFileUrl: '',
				tzridOppositeFileUrl: '',
				czridOppositeFileUrl: '',
				fridOppositeFileUrl: '',

				enterpriseName: '',
				// enterpriseCode: '',
				bank: '',
				bankAddress: '',
				validCode: '',
				enterpriseAddress: '',

				cardBirth: '',
				frBirth: '',
				name: '',
				frname: '',
				id: '',
				frid: '',
				address: '',
				fraddress: '',
				phoneNum: '',
				emergencyContact: '',
				emergencyTel: '',
				mailbox: '',

				togetherNum: '',
				togetherName: '',

				czrtogetherNum: '',
				czrtogetherName: '',

				entityFileUrl: '',
			};
		},
		methods: {
			payArray() {
				this.api.get('system/dict/data/list?pageNum=1&pageSize=50&dictType=contract_type', '').then(res => {
					if (res.data.code == 200) {
						this.pay = res.data.rows
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 1500
						});
					}
				})
			},

			timeArray() {
				this.api.get('system/dict/data/list?pageNum=1&pageSize=50&dictType=yuefen', '').then(res => {
					if (res.data.code == 200) {
						this.time = res.data.rows
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 1500
						});
					}
				})
			},

			maskClick(e) {
				console.log('maskClick事件:', e);
			},
			
			submit: throttle(function() {
				// null
				// if 
				// (this.entityIndex >=0 ) {
				// 	uni.showToast({
				// 		title: '请选择主体',
				// 		icon: 'none',
				// 		duration: 1500
				// 	});
				// } else
				if (this.date == '') {
					uni.showToast({
						title: '请选择合同生效日期',
						icon: 'none',
						duration: 1500
					});
				} else if (this.timeIndex == '') {
					uni.showToast({
						title: '请选择租赁时长',
						icon: 'none',
						duration: 1500
					});
				}
				// else if (this.payTypeIndex == '') {
				// 	uni.showToast({
				// 		title: '请选择缴纳类型',
				// 		icon: 'none',
				// 		duration: 1500
				// 	});
				// }
				else if (this.payIndex == '') {
					uni.showToast({
						title: '请选择缴纳方式',
						icon: 'none',
						duration: 1500
					});
				} else if (this.entityFileUrl == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请上传营业执照',
						icon: 'none',
						duration: 1500
					});
				} else if (this.enterpriseName == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入单位名称',
						icon: 'none',
						duration: 1500
					});
				} else if (this.enterpriseAddress == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入单位所在地',
						icon: 'none',
						duration: 1500
					});
				} else if (this.bankAddress == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入开户行',
						icon: 'none',
						duration: 1500
					});
				} else if (this.bank == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入对公账号',
						icon: 'none',
						duration: 1500
					});
				} else if (this.validCode == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入税号',
						icon: 'none',
						duration: 1500
					});
				} else if (this.idFrontFileUrl == '' && this.entityIndex == 0) {
					uni.showToast({
						title: '请上传身份证正面',
						icon: 'none',
						duration: 1500
					});
				} else if (this.idOppositeFileUrl == '' && this.entityIndex == 0) {
					uni.showToast({
						title: '请上传身份证反面',
						icon: 'none',
						duration: 1500
					});
				} else if (this.id == '' && this.entityIndex == 0) {
					uni.showToast({
						title: '请输入身份证',
						icon: 'none',
						duration: 1500
					});
				} else if (this.name == '' && this.entityIndex == 0) {
					uni.showToast({
						title: '请输入姓名',
						icon: 'none',
						duration: 1500
					});
				} else if (this.address == '' && this.entityIndex == 0) {
					uni.showToast({
						title: '请输入户籍所在地',
						icon: 'none',
						duration: 1500
					});
				} else if (this.phoneNum == '') {
					uni.showToast({
						title: '请输入联系电话',
						icon: 'none',
						duration: 1500
					});
				} else if (this.fridFrontFileUrl == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请上传法人身份证正面',
						icon: 'none',
						duration: 1500
					});
				} else if (this.fridOppositeFileUrl == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请上传法人身份证反面',
						icon: 'none',
						duration: 1500
					});
				} else if (this.frid == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入法人身份证',
						icon: 'none',
						duration: 1500
					});
				} else if (this.frname == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入法人姓名',
						icon: 'none',
						duration: 1500
					});
				} else if (this.fraddress == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入法人户籍所在地',
						icon: 'none',
						duration: 1500
					});
				} else if (this.czridFrontFileUrl == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请上传承租人身份证正面',
						icon: 'none',
						duration: 1500
					});
				} else if (this.czridOppositeFileUrl == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请上传承租人身份证反面',
						icon: 'none',
						duration: 1500
					});
				} else if (this.czrid == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入承租人身份证',
						icon: 'none',
						duration: 1500
					});
				} else if (this.czrname == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入承租人姓名',
						icon: 'none',
						duration: 1500
					});
				} else if (this.czraddress == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入承租人户籍所在地',
						icon: 'none',
						duration: 1500
					});
				} else if (this.sqwt == '' && this.entityIndex == 1) {
					uni.showToast({
						title: '请上传授权委托书',
						icon: 'none',
						duration: 1500
					});
				}
				// else if (this.emergencyContact == '') {
				// 	uni.showToast({
				// 		title: '请输入紧急联系人',
				// 		icon: 'none',
				// 		duration: 1500
				// 	});
				// } else if (this.emergencyTel == '') {
				// 	uni.showToast({
				// 		title: '请输入紧急联系电话',
				// 		icon: 'none',
				// 		duration: 1500
				// 	});
				// }

				// !null
				else if (this.phoneNumReg(this.phoneNum) == false) {
					uni.showToast({
						title: '请输入正确的电话',
						icon: 'none',
						duration: 1500
					});
				} else if (this.IsChinese(this.enterpriseName) == false && this.entityIndex == 1) {
					uni.showToast({
						title: '企业名称必须全中文',
						icon: 'none',
						duration: 1500
					});
				} else if (this.addressReg(this.enterpriseAddress) == false && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入正确的单位地址',
						icon: 'none',
						duration: 1500
					});
				} else if (this.addressReg(this.bankAddress) == false && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入正确的开户行地址',
						icon: 'none',
						duration: 1500
					});
				} else if (this.validBank(this.bank) == false && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入正确的对公账号',
						icon: 'none',
						duration: 1500
					});
				} else if (this.validCodeReg(this.validCode) == false && this.entityIndex == 1) {
					uni.showToast({
						title: '请输入正确的税号',
						icon: 'none',
						duration: 1500
					});
				}

				// } else if (this.IsChinese(this.emergencyContact) == false) {
				// 	uni.showToast({
				// 		title: '紧急联系人必须全汉字',
				// 		icon: 'none',
				// 		duration: 1500
				// 	});
				// } 
				// else if (this.phoneNumReg(this.emergencyTel) == false) {
				// 	uni.showToast({
				// 		title: '请输入正确的电话号码',
				// 		icon: 'none',
				// 		duration: 1500
				// 	});
				// } else if (this.emergencyTel == this.phoneNum) {
				// 	uni.showToast({
				// 		title: '紧急联系不能为个人电话',
				// 		icon: 'none',
				// 		duration: 1500
				// 	});
				// }
				let contractForm = Number(this.entityIndex) + 1

				if (this.entityIndex == 0) {
					// 个人
				
				} else {
					// 企业

				}
			}, 1500),

			getSubmit(data) {
				if (uni.getStorageSync('openId')) {
					if (this.phoneNum != '' && this.phoneNumReg(this.phoneNum) != false) {
						this.api.post('hetong/contract/app/insert', data).then(res => {
							if (res.data.code == 200) {
								uni.navigateTo({
									url: '/pages/contract/payment',
								});
							} else {
								uni.showToast({
									title: res.data.msg,
									icon: 'none',
									duration: 1500
								});
							}
						})
					}
				} else {
					this.loginTip()
				}

			},

			loginTip() {
				uni.showToast({
					title: '请登陆',
					icon: 'none',
					duration: 2000
				});
				setTimeout(() => {
					uni.navigateTo({
						url: '/pages/login/login'
					})
				}, 2000);
			},

			timePciker(index) {
				this.timeIndex = index.detail.value
				if (this.date != '') {
					// this.timeIndex = index.detail.value
					let data = {
						roomId: uni.getStorageSync("roomId"),
						monthSum: this.time[this.timeIndex].dictValue,
						startTime: this.date,
					}
					this.api.get('hetong/contract/app/selContractPrice', data).then(res => {
						// console.log(res);
						if (res.data.code == 200) {
							this.all = res.data.data
						} else {
							uni.showToast({
								title: res.data.msg,
								icon: 'none',
								duration: 2000
							});
						}
					})
				} else {
					uni.showToast({
						title: '请优先选择合同生效日期',
						icon: 'none',
						duration: 2000
					});
				}
			},
			payTypePciker(index) {
				this.payTypeIndex = index.detail.value
			},
			payPciker(index) {
				this.payIndex = index.detail.value
			},
			entityPciker(index) {
				this.entityIndex = index.detail.value
			},

			phoneNumReg(value) {
				return /^1[3-9]\d{9}$/.test(value);
			},
			email(value) {
				return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(value);
			},
			IsChinese(value) {
				let reg = /^[\u4e00-\u9fa5]+$/gi;
				return reg.test(value);
			},
			addressReg(value) {
				let reg =
					/(\w+省|\w+自治区)?(\w+市|\w+自治州|\w+地区)?(\w+区|\w+县|\w+市|\w+镇|\w+乡|\w+街道)?(\w+路|\w+街|\w+巷|\w+村)?(\d+号|(\w+号)(\d+单元)?(\d+室)?)/
				return reg.test(value);
			},
			IDCard(value) {
				let reg = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
				return reg.test(value)

				// 引入 IDCard.js
				// var IDCard = new IdCardValidate(value);
				// if(!checkIdCard.IsValid()){
				//   alert('您输入的身份证格式不正确!');
				//   return;
				// }
			},

			money(value) {
				return /^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(value);
			},

			validBank(value) {
				return /^[1-9]\d{9,29}$/.test(value);
			},

			validCodeReg(value) {
				return /^[A-Z0-9]{15}$|^[A-Z0-9]{17}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/.test(value)
			},

			// 获取上传状态
			entitySelect(e) {
				uni.uploadFile({
					url: config.apiUrl + 'hetong/contract/app/upload',
					// header: {
					// 	'Content-Type': 'application/x-www-form-urlencoded'
					// },
					method: 'POST',
					dataType: 'json',
					filePath: e.tempFilePaths[0],
					name: 'file',
					success: uploadFileRes => {
						let data = JSON.parse(uploadFileRes.data)
						// console.log(data);
						console.log(data);
						if (data.code == 200) {
							this.entityFileUrl = data.data.ossId
						} else {
							uni.showToast({
								title: data.msg,
								icon: 'none',
								duration: 1500
							});
						}
					},
					fail(err) {
						console.log(err);
					}
				});
			},
			entityFail() {
				uni.showToast({
					title: '操作失败,请稍后再试',
					icon: 'none',
					duration: 1500
				});
			},
			entityDel(e) {
				this.entityFileUrl = ''
			},

			// 身份证正面 idOpposite
			// 获取上传状态
			idFrontSelect(e) {
				console.log(e)
				uni.uploadFile({
					url: config.apiUrl + 'hetong/contract/app/idCard',
					// header: {
					// 	'Content-Type': 'application/x-www-form-urlencoded'
					// },
					method: 'POST',
					dataType: 'json',
					filePath: e.tempFilePaths[0],
					name: 'file',
					success: uploadFileRes => {
						let data = JSON.parse(uploadFileRes.data)
						console.log(data);
						if (data.code == 200) {
							this.name = data.data.cardName
							this.cardBirth = data.data.cardBirth
							this.id = data.data.cardNum
							this.address = data.data.cardSite
							// idFrontFileUrl: '',
							// idOppositeFileUrl: '',
							this.idFrontFileUrl = data.data.ossId
						} else {
							uni.showToast({
								title: '格式错误,请重新上传',
								icon: 'none',
								duration: 1500
							});
						}
					},
					fail(err) {
						console.log(err);
					}
				});
			},
			idFrontFail() {
				uni.showToast({
					title: '操作失败,请稍后再试',
					icon: 'none',
					duration: 1500
				});
			},
			idFrontDel(e) {
				this.idFrontFileUrl = ''
				this.cardBirth = ''
				this.id = ''
				this.address = ''
				this.name = ''
			},

			// 身份证反面 idOpposite
			// 获取上传进度
			idOppositeSelect(e) {
				uni.uploadFile({
					url: config.apiUrl + 'hetong/contract/app/upload',
					// header: {
					// 	'Content-Type': 'application/x-www-form-urlencoded'
					// },
					method: 'POST',
					dataType: 'json',
					filePath: e.tempFilePaths[0],
					name: 'file',
					success: uploadFileRes => {
						let data = JSON.parse(uploadFileRes.data)
						// console.log(data);
						console.log(data);
						if (data.code == 200) {
							this.idOppositeFileUrl = data.data.ossId
						} else {
							uni.showToast({
								title: data.msg,
								icon: 'none',
								duration: 1500
							});
						}
					},
					fail(err) {
						console.log(err);
					}
				});
			},
			idOppositeFail() {
				uni.showToast({
					title: '操作失败,请稍后再试',
					icon: 'none',
					duration: 1500
				});
			},
			idOppositeDel(e) {
				this.idOppositeFileUrl = ''
			},
		},

		onLoad() {
			
		},
		onShow() {

		},
		onReady() {

		},
	};
</script>

<style lang="scss">
	.flex_most {
		width: 28rpx;
		height: 28rpx;
		margin-top: 5rpx;
	}

	.flex_logo {
		width: 28rpx;
		height: 28rpx;
		margin-top: 46rpx;
	}

	.logo {
		width: 80rpx;
		height: 80rpx;
		margin-top: 20rpx;
		margin-left: 310rpx;
	}

	.wrap {
		margin: 0 auto 54rpx;
		width: 718rpx;
	}

	.flex {
		display: flex;
		justify-content: flex-end;
	}

	.form_item_h {
		width: 718rpx;
		height: 40rpx;
		border-bottom: 1rpx solid #aaacba;
		display: flex;
		justify-content: flex-start;
		flex-wrap: nowrap;
		overflow: hidden;
		padding: 40rpx 0;
	}

	#submit {
		width: 660rpx;
		height: 112rpx;
		line-height: 112rpx;
		background: #ff6900;
		border-radius: 8rpx;
		text-align: center;
		font-size: 34rpx;
		font-family: PingFangSC-Semibold, PingFang SC;
		font-weight: 600;
		color: #FFFFFF;
		margin-top: 30rpx;
	}

	.gray_h {
		width: auto;
		height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #AAACAB;
		line-height: 40rpx;
		margin: 34rpx 0 44rpx 24rpx;
		box-sizing: border-box;
	}

	textarea {
		width: 564rpx;
		height: 190rpx;
		border: 2rpx solid #F7F4F4;
		margin: 0 auto;
		font-size: 28rpx;
		font-weight: 400;
		color: #AAACAB;
		padding: 24rpx 38rpx 14rpx 38rpx;
	}

	.placeholder_textarea {
		font-size: 28rpx;
		font-weight: 400;
		color: #AAACAB;

	}

	.h {
		height: 48rpx;
		font-size: 34rpx;
		font-weight: 400;
		color: #1A1A1A;
		line-height: 48rpx;
		margin-left: 44rpx;
	}

	form {
		width: 718rpx;

		.form_item_logo {
			width: 718rpx;
			height: 120rpx;
			border-bottom: 1rpx solid #F7F4F4;
			display: flex;
			justify-content: flex-start;
			flex-wrap: nowrap;
			overflow: hidden;

			.label {
				width: 40%;
				height: 120rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: #AAACAB;
				line-height: 120rpx;

				.label_text {
					color: red;
					margin-left: 28rpx;
					margin-top: 16rpx;
					margin-right: 10rpx;
				}
			}

			.font_size {
				font-size: 28rpx;
				font-weight: 400;
				color: #AAACAB;
			}

			.input {
				width: 55%;
				height: 120rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: black;
				line-height: 120rpx;
				text-align: end;
			}

		}

		.uni-file-picker__container {
			display: flex;
			box-sizing: border-box;
			flex-wrap: wrap;
			margin: -5px;
			width: 660rpx;
			margin: 0 auto;
		}

		.from_file {
			width: 718rpx;
			height: 40rpx;
			border-bottom: 1rpx solid #F7F4F4;
			display: flex;
			justify-content: flex-start;
			flex-wrap: nowrap;
			overflow: hidden;
			padding: 40rpx 0 20rpx;

			.label {
				width: 40%;
				height: 40rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: #AAACAB;
				line-height: 40rpx;

				.label_text {
					color: red;
					margin-left: 28rpx;
					margin-top: 16rpx;
					margin-right: 10rpx;
				}
			}

			.input {
				width: 55%;
				height: 40rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: black;
				line-height: 40rpx;
				text-align: end;
			}

			.font_size {
				font-size: 28rpx;
				font-weight: 400;
				color: #AAACAB;
			}

			input {
				width: 55%;
				height: 40rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: black;
				line-height: 40rpx;
				text-align: end;
			}
		}


		.form_item {
			width: 718rpx;
			height: 40rpx;
			border-bottom: 1rpx solid #F7F4F4;
			display: flex;
			justify-content: flex-start;
			flex-wrap: nowrap;
			overflow: hidden;
			padding: 40rpx 0;


			.label {
				width: 40%;
				height: 40rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: #AAACAB;
				line-height: 40rpx;

				.label_text {
					color: red;
					margin-left: 28rpx;
					margin-top: 16rpx;
					margin-right: 10rpx;
				}
			}

			.input {
				width: 55%;
				height: 40rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: black;
				line-height: 40rpx;
				text-align: end;
			}

			.font_size {
				font-size: 28rpx;
				font-weight: 400;
				color: #AAACAB;
			}

			input {
				width: 55%;
				height: 40rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: black;
				line-height: 40rpx;
				text-align: end;
			}
		}
	}
</style>

以下是使用Vue 3和uni-app实现表单校验的示例代码: ```vue <template> <div> <form @submit.prevent="submitForm"> <label for="name">姓名:</label> <input type="text" id="name" v-model="formData.name" /> <p v-if="errors.name" class="error">{{ errors.name }}</p> <label for="email">邮箱:</label> <input type="email" id="email" v-model="formData.email" /> <p v-if="errors.email" class="error">{{ errors.email }}</p> <button type="submit">提交</button> </form> </div> </template> <script> import { ref } from 'vue'; export default { setup() { const formData = ref({ name: '', email: '', }); const errors = ref({}); const validateForm = () => { errors.value = {}; if (!formData.value.name) { errors.value.name = '请输入姓名'; } if (!formData.value.email) { errors.value.email = '请输入邮箱'; } else if (!isValidEmail(formData.value.email)) { errors.value.email = '请输入有效的邮箱地址'; } return Object.keys(errors.value).length === 0; }; const submitForm = () => { if (validateForm()) { // 表单校验通过,提交表单 console.log('表单校验通过,提交表单'); } }; const isValidEmail = (email) => { // 简单的邮箱格式校验 const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return emailRegex.test(email); }; return { formData, errors, submitForm, }; }, }; </script> <style> .error { color: red; } </style> ``` 这个示例代码演示了如何使用Vue 3和uni-app实现表单校验。在模板中,我们使用`v-model`指令绑定表单输入的值,并使用`v-if`指令根据校验结果显示错误信息。在`setup`函数中,我们定义了`formData`和`errors`的响应式变量,并编写了`validateForm`函数来进行表单校验。最后,在提交表单时,我们调用`validateForm`函数来判断表单是否通过校验,如果通过则提交表单
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值