You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							272 lines
						
					
					
						
							6.8 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							272 lines
						
					
					
						
							6.8 KiB
						
					
					
				| <template> | |
| 	<view class="bg"> | |
| 		<view class="list-forms"> | |
| 			<view class="list-item"> | |
| 				<view class="list-item-title">姓名</view> | |
| 				<view class="list-item-input"><input type="text" v-model="username" placeholder="请输入姓名" /></view> | |
| 			</view> | |
| 			<!-- <view class="list-item"> | |
| 				<picker mode="selector" :range="idcardTypeList" range-key="title" @change="changeIdType"> | |
| 					<view class="list-item-title flex-center" | |
| 						style="border: 1rpx solid #999999;border-radius: 7rpx;padding: 18rpx 19rpx;">{{idcardTypeValue}} | |
| 						<image src="https://static.ticket.sz-trip.com/yandu/images/user/dui.png" mode="" | |
| 							style="width: 40rpx;height: 40rpx;margin-left: 48rpx;"></image> | |
| 					</view> | |
| 				</picker> | |
| 				<view class="list-item-input"><input type="text" v-model="idNumber" placeholder="请输入正确的证件号" /></view> | |
| 			</view> --> | |
| 			<view class="list-item"> | |
| 				<view class="list-item-title">手机号</view> | |
| 				<view class="list-item-input"><input type="number" v-model="mobile" placeholder="请输入手机号" | |
| 						maxlength="11" /></view> | |
| 			</view> | |
| 			<view class="list-item"> | |
| 				<view class="list-item-title">身份证号</view> | |
| 				<view class="list-item-input"><input type="text" v-model="idNumber" placeholder="请输入正确的证件号" /></view> | |
| 			</view> | |
| 			<view class="list-item"> | |
| 				<view class="list-item-title">设为默认</view> | |
| 				<view class="list-item-switch"> | |
| 					<switch :checked="idDefault" @change="switchChange" color="#6A8A2D"/> | |
| 				</view> | |
| 			</view> | |
| 		</view> | |
|  | |
| 		<view class="btn" @click="submit">保存</view> | |
| 	</view> | |
| </template> | |
|  | |
| <script> | |
| 	export default { | |
| 		data() { | |
| 			return { | |
| 				username: '', | |
| 				mobile: '', | |
| 				idNumber: '', | |
| 				idcardTypeValue: '身份证', | |
| 				show: false, | |
| 				idcardTypeList: [], | |
| 				document_type: 'DAM01001', | |
| 				idCardType: 1, | |
| 				id: '', | |
| 				type: '', | |
| 				idDefault: false, | |
| 			} | |
| 		}, | |
| 		onLoad(option) { | |
| 			if (option) { | |
| 				this.id = option.id | |
| 			} | |
| 			if(option && option.type){ | |
| 				this.type = option.type | |
| 			} | |
| 		}, | |
| 		onShow() { | |
| 			this.getIdcardTypeList() | |
| 			if (this.id) { | |
| 				this.getDetail() | |
| 			} | |
| 			// uni.setNavigationBarTitle({ | |
| 			//     title: '' | |
| 			// }) | |
| 			var pages = getCurrentPages();//获取页面 | |
| 			var beforePage = pages[pages.length - 2];//上个页面 | |
| 			// if(beforePage.route == 'subPackages/scenic/scenicOrder' || beforePage.route == 'subPackages/venue/venueOrder'){ | |
| 			// 	uni.setStorageSync('route', 1) | |
| 			// } | |
| 		}, | |
| 		methods: { | |
| 			switchChange(e){ | |
| 				this.idDefault = e.detail.value | |
| 			}, | |
| 			getDetail() { | |
| 				this.Post({ | |
| 					id: this.id | |
| 				}, '/api/uservice/user/getContactInfoById').then(res => { | |
| 					if (res.code === 1) { | |
| 						res = res.data | |
| 						if (res && res.id > 0) { | |
| 							this.username = res.name | |
| 							this.mobile = res.tel | |
| 							this.idNumber = res.id_number | |
| 							this.idDefault = res.is_default == 1 ? true : false | |
| 							this.idcardType = res.idcard_type | |
| 							this.idcardTypeValue = res.document_type_text | |
| 							this.document_type = res.document_type | |
| 						} | |
| 					} | |
| 				}) | |
| 			}, | |
| 			//获取证件类型 | |
| 			getIdcardTypeList() { | |
| 				this.Post({}, '/api/uservice/user/getCardTypeList').then(res => { | |
| 					this.idcardTypeList = res.data | |
| 				}) | |
| 			}, | |
| 			// 选择证件类型 | |
| 			changeIdType(e) { | |
| 				this.idcardTypeValue = this.idcardTypeList[e.detail.value].title | |
| 				this.document_type = this.idcardTypeList[e.detail.value].code | |
| 				this.idCardType = this.idcardTypeList[e.detail.value].type | |
| 			}, | |
| 			// 提交 | |
| 			submit() { | |
| 				this.username = this.username.trim() | |
| 				this.mobile = this.mobile.trim() | |
| 				this.idNumber = this.idNumber.trim() | |
| 				if (this.username.length < 1) { | |
| 					uni.showToast({ | |
| 						title: '请输入姓名', | |
| 						icon: 'none' | |
| 					}) | |
| 					return | |
| 				} | |
| 				if (!this.IsTel(this.mobile)) { | |
| 					uni.showToast({ | |
| 						title: '请输入正确的手机号', | |
| 						icon: 'none' | |
| 					}) | |
| 					return | |
| 				} | |
| 				if (this.idcardTypeValue == '身份证') { | |
| 					if (!this.idCardNumber(this.idNumber)) { | |
| 						uni.showToast({ | |
| 							title: '请输入正确的身份证', | |
| 							icon: 'none' | |
| 						}) | |
| 						return | |
| 					} | |
| 				} else if (this.idcardTypeValue == '护照') { | |
| 					if (!this.passportValid(this.idNumber)) { | |
| 						uni.showToast({ | |
| 							title: '请输入正确的护照', | |
| 							icon: 'none' | |
| 						}) | |
| 						return | |
| 					} | |
| 				} else if (this.idcardTypeValue == '台胞证') { | |
| 					if (!this.taiwanValid(this.idNumber)) { | |
| 						uni.showToast({ | |
| 							title: '请输入正确的台胞证', | |
| 							icon: 'none' | |
| 						}) | |
| 						return | |
| 					} | |
| 				} else if (this.idcardTypeValue == '港澳通行证') { | |
| 					if (!this.gangaoValid(this.idNumber)) { | |
| 						uni.showToast({ | |
| 							title: '请输入正确的港澳通行证', | |
| 							icon: 'none' | |
| 						}) | |
| 						return | |
| 					} | |
| 				} else if (this.idcardTypeValue == '外国人永久居留证') { | |
| 					if (!this.foreignerValid(this.idNumber)) { | |
| 						uni.showToast({ | |
| 							title: '请输入正确的外国人永久居留证', | |
| 							icon: 'none' | |
| 						}) | |
| 						return | |
| 					} | |
| 				} else if (this.idcardTypeValue == '军官证') { | |
| 					if (!this.officerValid(this.idNumber)) { | |
| 						uni.showToast({ | |
| 							title: '请输入正确的军官证', | |
| 							icon: 'none' | |
| 						}) | |
| 						return | |
| 					} | |
| 				} | |
| 				this.Post({ | |
| 					contactId: this.type == 'edit'?this.id:'', | |
| 					id_number: this.idNumber, | |
| 					username: this.username, | |
| 					mobile: this.mobile, | |
| 					document_type: this.document_type, | |
| 					idcard_type: this.idCardType, | |
| 					is_default: this.idDefault ? '1' : '0', | |
| 				}, this.type=='edit'?'/api/uservice/user/editContactById':'/api/uservice/user/addNewContact').then(res => { | |
| 					if (res.code == 1) { | |
| 						uni.showModal({ | |
| 							title: '提示', | |
| 							content: '成功', | |
| 							showCancel: false, | |
| 							success: res => { | |
| 								if (res.confirm) { | |
| 									uni.navigateBack({}) | |
| 								} | |
| 							} | |
| 						}) | |
| 					} | |
| 				}) | |
| 			} | |
| 		} | |
| 	} | |
| </script> | |
|  | |
| <style scoped lang="scss"> | |
| 	.bg { | |
| 		min-height: 100vh; | |
| 		background-color: #FFFFFF; | |
| 		position: relative; | |
| 	} | |
| 
 | |
| 	.list-forms { | |
| 		padding: 0 33rpx; | |
| 
 | |
| 		.list-item { | |
| 			display: flex; | |
| 			border-bottom: 1rpx solid #D8D8D8; | |
| 			padding: 30rpx 0; | |
| 			height: 60rpx; | |
| 			box-sizing: content-box; | |
| 			align-items: center; | |
| 
 | |
| 			.list-item-title { | |
| 				font-size: 34rpx; | |
| 				margin-right: 20rpx; | |
| 			} | |
| 			 | |
| 			.list-item-switch { | |
| 				display: flex; | |
| 				flex: 1; | |
| 				justify-content: flex-end; | |
| 			} | |
| 
 | |
| 			.list-item-input { | |
| 				flex: 1; | |
| 
 | |
| 				input { | |
| 					width: 100%; | |
| 					height: 100%; | |
| 					padding: 0; | |
| 					margin: 0; | |
| 					border: 0; | |
| 					background-color: transparent; | |
| 					line-height: 34rpx; | |
| 					font-size: 31rpx; | |
| 					text-align: right; | |
| 					font-weight: 500; | |
| 				} | |
| 
 | |
| 				input::placeholder { | |
| 					font-size: 26rpx; | |
| 				} | |
| 			} | |
| 		} | |
| 	} | |
| 
 | |
| 	.btn { | |
| 		width: 333rpx; | |
| 		height: 80rpx; | |
| 		background: #6A8A2D; | |
| 		border-radius: 40rpx; | |
| 		text-align: center; | |
| 		line-height: 80rpx; | |
| 		font-size: 36rpx; | |
| 		font-family: PingFang SC; | |
| 		font-weight: 500; | |
| 		color: #FFFFFF; | |
| 		margin: 271rpx auto 0; | |
| 	} | |
| </style>
 | |
| 
 |