wangchao 3 vuotta sitten
vanhempi
commit
4ed96c9ee1
1 muutettua tiedostoa jossa 258 lisäystä ja 201 poistoa
  1. 258 201
      pageD/identity/driverIdentityThree.vue

+ 258 - 201
pageD/identity/driverIdentityThree.vue

@@ -1,15 +1,20 @@
 <template>
 	<view class="center">
 		<view class="picture">
-			<view style="margin: 0 auto;height: 240px;" v-if="travels != ''" @click="travel">
-				<image v-bind:src="travels" class="picture"></image>
+
+			<view style="margin: 0 auto;height: 240px;" v-if="travels != ''">
+				<!-- 	<image v-bind:src="travels" class="picture"></image>
 				<view class="floats" v-if="certificates == true">
 					<image src="../../static/img/authentication/xiangji@3x.png" style="width: 60px;height: 50px;">
 					</image>
 					<view class="words">
 						上传行驶证
 					</view>
-				</view>
+				</view> -->
+				<upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="1"
+					:size-type="['compressed']" @on-success="getImgUrl" @on-error="onError" @on-remove="onRemove"
+					@on-uploaded="isAdd = true" :before-upload="filterFileType" :options="uploadOptions"
+					:custom="uploadCustom" @on-progress="onProgress"></upload>
 			</view>
 			<view style="margin: 0 auto;height: 240px;" v-if="drives != ''" @click="drive">
 				<image v-bind:src="drives" class="picture"></image>
@@ -49,12 +54,27 @@
 </template>
 
 <script>
+	import upload from '@/components/upload.vue';
 	import {
 		mapState
 	} from 'vuex';
 	export default {
+		components: {
+			upload
+		},
 		data() {
 			return {
+				action: this.$uploadUrl,
+				maxSize: 5 * 1024 * 1024, //限制文件大小 2M
+				btnLoading: false, //防止重复点击
+				isAdd: true,
+				imgUrls: [],
+				uploadCustom: true,
+				uploadCustom1: true,
+				uploadOptions: {
+					"text": "上传行驶证",
+					"bgc": "https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/tmp/bankup%282%29.png"
+				},
 				travels: "../../static/img/authentication/travel(3).png",
 				drives: "../../static/img/authentication/drive(3).png",
 				practices: "../../static/img/authentication/business@3x.png",
@@ -65,7 +85,7 @@
 				certificatesTwo: true,
 				certificatesThree: true,
 				certificatesFour: true,
-				identityAuthenticationInfo:{},
+				identityAuthenticationInfo: {},
 			}
 		},
 		computed: {
@@ -75,6 +95,37 @@
 			this.DriverViewInfo = JSON.parse(options.DriverViewInfo)
 		},
 		methods: {
+			filterFileType(index, lists) {
+				if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
+					lists.splice(index, 1);
+					// 当前文件不支持
+					uni.showModal({
+						title: '暂不支持当前图片类型',
+						showCancel: false
+					});
+				} else {
+					this.isAdd = false;
+				}
+			},
+			getImgUrl(res) {
+				console.log(res)
+				console.log('------------res-----------')
+				that.travels = res
+				that.addressUrl[0] = res
+				that.certificates = false
+
+			},
+			onError(error) {
+				alert(error)
+				console.log('------------error-----------')
+				console.log(error)
+			},
+			onProgress(e) {
+				console.log(e)
+			},
+			onRemove(index) {
+				this.imgUrls.splice(index, 1);
+			},
 			commit() {
 				var that = this
 				if (this.addressUrl[0] == "" || this.addressUrl[0] == null) {
@@ -101,50 +152,26 @@
 				var that = this
 				that.identityAuthenticationInfo.driverPhone = that.DriverViewInfo.driverPhone
 				uni.showModal({
-							content: "确认提交司机信息?",
-							showCancel: true,
-							confirmText: '确定',
-							success: function(res) {
-								if (res.confirm) {
-									that.$api.doRequest('get', '/driverViewInfo/selectPhone', that.identityAuthenticationInfo)
-										.then(res => {
-											if (res.data.code == '11018') {
-												uni.showModal({
-													title: '提示',
-													content: '该手机号已认证过司机,再次认证将覆盖之前的认证信息,是否确定认证?',
-													success: function(res) {
-														if (res.confirm) {
-													
-															console.log(that.identityAuthenticationInfo, "已覆盖")
-															that.$api.doRequest('post','/driverViewInfo/api/addInfo', that.DriverViewInfo).then(res => {
-																if (res.data.code == 200) {
-																	uni.showToast({
-																		title: '提交成功',
-																		icon: 'none',
-																		duration: 2000
-																	})
-																	uni.navigateBack({
-																		delta:3
-																	})
-																} else if (res.data.code ==
-																	'ERROR002') {
-																	uni.showModal({
-																		title: '提示',
-																		content: '司机身份证号重复,添加失败',
-																	});
-																} else if (res.data.code == 'ERROR003') {
-																	uni.showModal({
-																		title: '提示',
-																		content: '收款人身份证号重复,添加失败',
-																	});
-																	
-																}
-															})
-														}
-													}
-												});
-											}else if(res.data.code == 200){
-												that.$api.doRequest('post','/driverViewInfo/api/addInfo', that.DriverViewInfo).then(res => {
+					content: "确认提交司机信息?",
+					showCancel: true,
+					confirmText: '确定',
+					success: function(res) {
+						if (res.confirm) {
+							that.$api.doRequest('get', '/driverViewInfo/selectPhone', that
+									.identityAuthenticationInfo)
+								.then(res => {
+									if (res.data.code == '11018') {
+										uni.showModal({
+											title: '提示',
+											content: '该手机号已认证过司机,再次认证将覆盖之前的认证信息,是否确定认证?',
+											success: function(res) {
+												if (res.confirm) {
+
+													console.log(that
+														.identityAuthenticationInfo, "已覆盖")
+													that.$api.doRequest('post',
+														'/driverViewInfo/api/addInfo', that
+														.DriverViewInfo).then(res => {
 														if (res.data.code == 200) {
 															uni.showToast({
 																title: '提交成功',
@@ -152,188 +179,218 @@
 																duration: 2000
 															})
 															uni.navigateBack({
-																delta:3
+																delta: 3
 															})
-														} else if (res.data.code =='ERROR002') {
+														} else if (res.data.code ==
+															'ERROR002') {
 															uni.showModal({
 																title: '提示',
 																content: '司机身份证号重复,添加失败',
 															});
-														} else if (res.data.code == 'ERROR003') {
+														} else if (res.data.code ==
+															'ERROR003') {
 															uni.showModal({
 																title: '提示',
 																content: '收款人身份证号重复,添加失败',
 															});
+
 														}
 													})
+												}
+											}
+										});
+									} else if (res.data.code == 200) {
+										that.$api.doRequest('post', '/driverViewInfo/api/addInfo', that
+											.DriverViewInfo).then(res => {
+											if (res.data.code == 200) {
+												uni.showToast({
+													title: '提交成功',
+													icon: 'none',
+													duration: 2000
+												})
+												uni.navigateBack({
+													delta: 3
+												})
+											} else if (res.data.code == 'ERROR002') {
+												uni.showModal({
+													title: '提示',
+													content: '司机身份证号重复,添加失败',
+												});
+											} else if (res.data.code == 'ERROR003') {
+												uni.showModal({
+													title: '提示',
+													content: '收款人身份证号重复,添加失败',
+												});
 											}
-										}).catch(res => {
-											uni.showToast({
-												title: res.data.message,
-												icon: 'none',
-												duration: 2000
-											})
 										})
+									}
+								}).catch(res => {
+									uni.showToast({
+										title: res.data.message,
+										icon: 'none',
+										duration: 2000
+									})
+								})
 
 
 
-									// 	that.$api.doRequest('post', '/driverViewInfo/api/addInfo', that.DriverViewInfo)
-									// 		.then(res => {
-									// 			if (res.data.code == 'ERROR001') {
-									// 				uni.showModal({
-									// 					title: '提示',
-									// 					content: '该手机号已认证过司机,再次认证将覆盖之前的认证信息,是否确定认证?',
-									// 					success: function(res) {
-									// 						if (res.confirm) {
-									// 							that.DriverViewInfo.cover = 1
-									// 							that.$api.doRequest('post',
-									// 								'/driverViewInfo/api/editInfo',
-									// 								that.DriverViewInfo).then(
-									// 								res => {}).catch(res => {
-									// 								uni.showToast({
-									// 									title: '提交成功',
-									// 									icon: 'none',
-									// 									duration: 2000
-									// 								})
-									// 								uni.navigateTo({
-									// 									url: `/pages/attestation/indexThree`
-									// 								})
-									// 							})
-									// 						} else if (res.cancel) {
-									// 							uni.showToast({
-									// 								title: '提交失败',
-									// 								icon: 'none',
-									// 								duration: 2000
-									// 							})
-									// 						}
-									// 					}
-									// 				});
-									// 			} else if (res.data.code == 'ERROR002') {
-									// 				uni.showModal({
-									// 					title: '提示',
-									// 					content: '司机身份证号重复',
-									// 				});
-									// 			} else if (res.data.code == 'ERROR003') {
-									// 				uni.showModal({
-									// 					title: '提示',
-									// 					content: '收款人身份证号重复',
-									// 				});
-									// 			} else if (res.data.code == 200) {
-									// 				uni.showToast({
-									// 					title: '提交成功',
-									// 					icon: 'none',
-									// 					duration: 2000
-									// 				})
-									// 				uni.navigateTo({
-									// 					url: `/pages/attestation/indexThree`
-									// 				})
-									// 			} else if (res.data.code == 200) {
-									// 				uni.showToast({
-									// 					title: '提交成功',
-									// 					icon: 'none',
-									// 					duration: 2000
-									// 				})
-									// 				uni.navigateTo({
-									// 					url: `/pages/attestation/indexThree`
-									// 				})
-									// 			}
+							// 	that.$api.doRequest('post', '/driverViewInfo/api/addInfo', that.DriverViewInfo)
+							// 		.then(res => {
+							// 			if (res.data.code == 'ERROR001') {
+							// 				uni.showModal({
+							// 					title: '提示',
+							// 					content: '该手机号已认证过司机,再次认证将覆盖之前的认证信息,是否确定认证?',
+							// 					success: function(res) {
+							// 						if (res.confirm) {
+							// 							that.DriverViewInfo.cover = 1
+							// 							that.$api.doRequest('post',
+							// 								'/driverViewInfo/api/editInfo',
+							// 								that.DriverViewInfo).then(
+							// 								res => {}).catch(res => {
+							// 								uni.showToast({
+							// 									title: '提交成功',
+							// 									icon: 'none',
+							// 									duration: 2000
+							// 								})
+							// 								uni.navigateTo({
+							// 									url: `/pages/attestation/indexThree`
+							// 								})
+							// 							})
+							// 						} else if (res.cancel) {
+							// 							uni.showToast({
+							// 								title: '提交失败',
+							// 								icon: 'none',
+							// 								duration: 2000
+							// 							})
+							// 						}
+							// 					}
+							// 				});
+							// 			} else if (res.data.code == 'ERROR002') {
+							// 				uni.showModal({
+							// 					title: '提示',
+							// 					content: '司机身份证号重复',
+							// 				});
+							// 			} else if (res.data.code == 'ERROR003') {
+							// 				uni.showModal({
+							// 					title: '提示',
+							// 					content: '收款人身份证号重复',
+							// 				});
+							// 			} else if (res.data.code == 200) {
+							// 				uni.showToast({
+							// 					title: '提交成功',
+							// 					icon: 'none',
+							// 					duration: 2000
+							// 				})
+							// 				uni.navigateTo({
+							// 					url: `/pages/attestation/indexThree`
+							// 				})
+							// 			} else if (res.data.code == 200) {
+							// 				uni.showToast({
+							// 					title: '提交成功',
+							// 					icon: 'none',
+							// 					duration: 2000
+							// 				})
+							// 				uni.navigateTo({
+							// 					url: `/pages/attestation/indexThree`
+							// 				})
+							// 			}
 
-									// 		}).catch(res => {
-									// 			uni.showToast({
-									// 				title: res.data.message,
-									// 				icon: 'none',
-									// 				duration: 2000
-									// 			})
-									// 		})
-									} else if (res.cancel) {
-										// console.log('用户点击取消');
-									}
-								},
+							// 		}).catch(res => {
+							// 			uni.showToast({
+							// 				title: res.data.message,
+							// 				icon: 'none',
+							// 				duration: 2000
+							// 			})
+							// 		})
+						} else if (res.cancel) {
+							// console.log('用户点击取消');
+						}
+					},
 
-							})
+				})
 
 
 
-					},
-					travel() {
-						var that = this
-						uni.chooseImage({
-							success: function(res) {
-								uni.uploadFile({
-									url: 'https://www.zthymaoyi.com/upload/admin',
-									filePath: res.tempFilePaths[0],
-									name: 'file',
-									success(res) {
-										var data = res.data
-										var strToObj = JSON.parse(data)
-										that.travels = strToObj.url
-										that.addressUrl[0] = strToObj.url
-										that.certificates = false
-									}
-								})
-							}
-						})
-					},
-					drive() {
-						var that = this
-						uni.chooseImage({
-							success: function(res) {
-								uni.uploadFile({
-									url: 'https://www.zthymaoyi.com/upload/admin',
-									filePath: res.tempFilePaths[0],
-									name: 'file',
-									success(res) {
-										var data = res.data
-										var strToObj = JSON.parse(data)
-										that.drives = strToObj.url
-										that.addressUrl[1] = strToObj.url
-										that.certificatesTwo = false
-									}
-								})
+			},
+			// travel() {
+			// 	var that = this
+			// 	uni.chooseImage({
+			// 		success: function(res) {
+			// 			uni.uploadFile({
+			// 				url: 'https://www.zthymaoyi.com/upload/admin',
+			// 				filePath: res.tempFilePaths[0],
+			// 				name: 'file',
+			// 				success(res) {
+			// 					var data = res.data
+			// 					var strToObj = JSON.parse(data)
+			// 					that.travels = strToObj.url
+			// 					that.addressUrl[0] = strToObj.url
+			// 					that.certificates = false
+			// 				}
+			// 			})
+			// 		}
+			// 	})
+			// },
+			drive() {
+				var that = this
+				uni.chooseImage({
+					success: function(res) {
+						uni.uploadFile({
+							url: 'https://www.zthymaoyi.com/upload/admin',
+							filePath: res.tempFilePaths[0],
+							name: 'file',
+							success(res) {
+								var data = res.data
+								var strToObj = JSON.parse(data)
+								that.drives = strToObj.url
+								that.addressUrl[1] = strToObj.url
+								that.certificatesTwo = false
 							}
 						})
-					},
-					practice() {
-						var that = this
-						uni.chooseImage({
-							success: function(res) {
-								uni.uploadFile({
-									url: 'https://www.zthymaoyi.com/upload/admin',
-									filePath: res.tempFilePaths[0],
-									name: 'file',
-									success(res) {
-										var data = res.data
-										var strToObj = JSON.parse(data)
-										that.practices = strToObj.url
-										that.addressUrl[2] = strToObj.url
-										that.certificatesThree = false
-									}
-								})
+					}
+				})
+			},
+			practice() {
+				var that = this
+				uni.chooseImage({
+					success: function(res) {
+						uni.uploadFile({
+							url: 'https://www.zthymaoyi.com/upload/admin',
+							filePath: res.tempFilePaths[0],
+							name: 'file',
+							success(res) {
+								var data = res.data
+								var strToObj = JSON.parse(data)
+								that.practices = strToObj.url
+								that.addressUrl[2] = strToObj.url
+								that.certificatesThree = false
 							}
 						})
-					},
-					operate() {
-						var that = this
-						uni.chooseImage({
-							success: function(res) {
-								uni.uploadFile({
-									url: 'https://www.zthymaoyi.com/upload/admin',
-									filePath: res.tempFilePaths[0],
-									name: 'file',
-									success(res) {
-										var data = res.data
-										var strToObj = JSON.parse(data)
-										that.operates = strToObj.url
-										that.addressUrl[3] = strToObj.url
-										that.certificatesFour = false
-									}
-								})
+					}
+				})
+			},
+			operate() {
+				var that = this
+				uni.chooseImage({
+					success: function(res) {
+						uni.uploadFile({
+							url: 'https://www.zthymaoyi.com/upload/admin',
+							filePath: res.tempFilePaths[0],
+							name: 'file',
+							success(res) {
+								var data = res.data
+								var strToObj = JSON.parse(data)
+								that.operates = strToObj.url
+								that.addressUrl[3] = strToObj.url
+								that.certificatesFour = false
 							}
 						})
-					},
+					}
+				})
+			},
 
-			}
 		}
+	}
 </script>
 
 <style lang="scss" scoped>