Browse Source

添加判断

chubiao 1 year ago
parent
commit
4a95704d5b
14 changed files with 225 additions and 35 deletions
  1. 4 4
      App.vue
  2. 1 0
      api/kh.js
  3. 1 0
      api/login.js
  4. 3 1
      common/common.js
  5. 7 1
      common/request.js
  6. 1 1
      components/lzc-OCR/lzc-OCR.vue
  7. 3 2
      config.js
  8. 11 1
      manifest.json
  9. 1 0
      pages/index/index.vue
  10. 5 5
      pages/login/index.vue
  11. 15 8
      pages/lr/base.vue
  12. 8 4
      pages/lr/list.vue
  13. 35 7
      pages/lr/register.vue
  14. 130 1
      pages/test/index.vue

+ 4 - 4
App.vue

@@ -32,14 +32,14 @@
 <style>
 	/*每个页面公共css */
 	@font-face {
-		font-family: 'puhui';
-		src: url('./static/fonts/AlibabaPuHuiTi-3-65-Medium.ttf');
+	/* 	font-family: 'puhui';
+		src: url('./static/fonts/AlibabaPuHuiTi-3-65-Medium.ttf'); */
 	}
 
 	.global-font {
-		font-family: 'puhui';
+		/* font-family: 'puhui';
 		font-size: 16px;
-		color: #333;
+		color: #333; */
 	}
 
 	uni-page-body,

+ 1 - 0
api/kh.js

@@ -12,6 +12,7 @@ export function updateKhjbxx(data) {
 
 // 老人信息新增
 export function SaveKhjbxx(data) {
+	data.source = '1'
 	return request({
 		url: '/api/business/lrjbxx',
 		method: 'post',

+ 1 - 0
api/login.js

@@ -13,6 +13,7 @@ export function Login(data) {
 
 // 注册
 export function Register(data) {
+	data.source = '1'
 	return request({
 		url: '/api/auth/gzhregister ',
 		method: 'post',

+ 3 - 1
common/common.js

@@ -17,12 +17,14 @@ export function toast(content) {
  * 显示模态弹窗
  * @param content 提示的标题
  */
-export function showConfirm(content) {
+export function showConfirm(content, showCancel) {
+	if (!showCancel) showCancel = false
 	return new Promise((resolve, reject) => {
 		uni.showModal({
 			title: '提示',
 			content: content,
 			cancelText: '取消',
+			showCancel: showCancel,
 			confirmText: '确定',
 			success: function(res) {
 				resolve(res)

+ 7 - 1
common/request.js

@@ -11,7 +11,13 @@ import config from '../config.js'
 const BASE_URL = ''
 
 const request = config => {
-	config.header = config.header || {}
+	config.header = config.header || {
+		'content-type': 'application/json',
+		'cache-control': 'no-cache',
+		'Access-Control-Allow-Headers': 'appId',
+		'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
+		'Access-Control-Max-Age': 86400,
+	}
 	let isRequest = true
 	if (getToken()) {
 		config.header['Authorization'] = 'Bearer ' + getToken()

+ 1 - 1
components/lzc-OCR/lzc-OCR.vue

@@ -118,7 +118,7 @@
 					},
 					success: (res) => {
 						uni.hideLoading()
-						console.log(res)
+						console.log(res,res.data, this.bSrc)
 						this.$emit('end', res.data, this.bSrc)
 					}
 				})

+ 3 - 2
config.js

@@ -1,8 +1,9 @@
 const build = {
-	"service": "http://121.36.73.159:807/prod-api",
+	"service": "",
 	// "service" : "http://10.16.9.114:8080",
 	// "service" : "http://10.16.4.5/dev-api",
-	"baseUrl": "http://121.36.73.159:807",
+	// "baseUrl": "http://121.36.73.159:810",
+	"baseUrl": "",
 	"head": "/uploadPath/2024/01/16/profile.png",
 	"appid": "wxeb15ff6b40432045",
 	"score": 70,

+ 11 - 1
manifest.json

@@ -84,12 +84,22 @@
                     }
                 },
                 "/api" : {
-                    "target" : "http://121.36.73.159:807/prod-api", // 需要跨域的域名
+                    // "target" : "http://10.16.4.7:9090", // 需要跨域的域名
+                    "target" : "http://121.36.73.159:805", // 需要跨域的域名
                     "changeOrigin" : true,
                     "secure" : false,
                     "pathRewrite" : {
                         "^/api" : ""
                     }
+                },
+                "/uploadPath" : {
+                    // "target" : "http://10.16.4.7:9090/file/uploadPath/", // 需要跨域的域名
+                    "target" : "http://121.36.73.159:805/file/uploadPath/", // 需要跨域的域名
+                    "changeOrigin" : true,
+                    "secure" : false,
+                    "pathRewrite" : {
+                        "^/uploadPath" : ""
+                    }
                 }
             }
         },

+ 1 - 0
pages/index/index.vue

@@ -116,6 +116,7 @@
 			} else {
 				this.form.createUserId = this.userInfo.userId
 			}
+			this.dataList = []
 			this.getDaiBanList()
 		},
 		methods: {

+ 5 - 5
pages/login/index.vue

@@ -79,7 +79,7 @@
 		},
 		onLoad() {
 			// 测试openid
-			setOpenid('owaO0uKdXNGMx7Zsy2jOZ0ZKsJGs')
+			// setOpenid('owaO0uKdXNGMx7Zsy2jOZ0ZKsJGs')
 			if (!getOpenid()) {
 				this.getCode(config.appid)
 			}
@@ -107,11 +107,11 @@
 						setOpenid(res.data)
 						this.formData.openid = res.data
 					})
-				} else {
-					// window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect`
-					window.location.href =
-						`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_base&state=${new Date().getTime()}#wechat_redirect`
 				}
+				//  else {
+				// 	window.location.href =
+				// 		`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_base&state=${new Date().getTime()}#wechat_redirect`
+				// }
 			},
 			getUrlCode() { // 截取url中的code方法
 				let url = location.search;

+ 15 - 8
pages/lr/base.vue

@@ -263,7 +263,7 @@
 								this.baseFormData.lrSpyj = ''
 								this.show = true
 								this.baseFormData.prelrZjz = this.zjcaijianSrc
-								uni.hideLoading()
+								this.faceSearch()
 							}
 
 						} else {
@@ -336,7 +336,8 @@
 					image: face,
 					image_type: 'BASE64',
 					group_id_list: this.groupId,
-					match_threshold: config.score
+					match_threshold: config.score,
+					max_user_num: 50
 				}
 				console.log("人脸搜索:", data)
 				uni.request({
@@ -369,7 +370,8 @@
 									})
 									this.baseFormData.xslrZjhm = JSON.stringify(xs)
 								}
-								this.faceAdd()
+								// this.faceAdd()
+								uni.hideLoading()
 							}
 						} else {
 							// this.isSearch = false
@@ -388,8 +390,12 @@
 					showConfirm('请上传人像')
 					return
 				} else {
+					if (!this.ocrXm) {
+						showConfirm('修改信息请重新上传身份证人像面')
+						return
+					}
 					if (this.ocrXm != this.baseFormData.lrXm) {
-						showConfirm('姓名与真实姓名不符,请重新上传身份证')
+						showConfirm('姓名与真实姓名不符,请重新上传身份证人像面')
 						return
 					}
 					// if (!this.isSearch) {
@@ -501,6 +507,10 @@
 			},
 			// 身份证识别
 			idcardEnd(words, src) {
+				if (words.image_status == "other_type_card") {
+					showConfirm('请上传正确的身份证人像面')
+					return
+				}
 				// 身份证号校验  性别  出生日期
 				// 修改之后的姓名和ocr返回校验,重新ocr
 				let id = words.words_result['公民身份号码'].words
@@ -532,10 +542,7 @@
 					showConfirm('请上传正确的身份证人像面')
 					return
 				}
-				if (words.image_status == "other_type_card") {
-					console.log('请上传正确的身份证人像面')
-					return
-				}
+				
 				this.baseFormData.lrXb = getDictInfo(this.dicts.C0007, words.words_result['性别'].words)[0].value
 				this.baseFormData.lrMz = getDictInfo(this.dicts.C0009, words.words_result['民族'].words)[0].value
 

+ 8 - 4
pages/lr/list.vue

@@ -9,22 +9,26 @@
 					<template v-slot:footer>
 						<view v-if="item.lzzt == '0'"
 							style="width: 60px;display: flex;flex-direction: column;background-image: url('../../static/images/caogao.png');background-position: left;background-size:58px 58px;background-repeat: no-repeat;">
-							<text>{{item.updateTime.substring(0,8) || item.createTime.substring(0,8)}}</text>
+							<text v-if="item.updateTime">{{item.updateTime.substring(0,8) }}</text>
+							<text v-else>{{item.createTime.substring(0,8) }}</text>
 							<text>{{item.lrSpyj || '无'}}</text>
 						</view>
 						<view v-else-if="item.lzzt == '1' || item.lzzt == '2'"
 							style="width: 60px;display: flex;flex-direction: column;background-image: url('../../static/images/daishenhe.png');background-position: left;background-size:58px 58px;background-repeat: no-repeat;">
-							<text>{{item.updateTime.substring(0,8) || item.createTime.substring(0,8)}}</text>
+							<text v-if="item.updateTime">{{item.updateTime.substring(0,8) }}</text>
+							<text v-else>{{item.createTime.substring(0,8) }}</text>
 							<text>{{item.lrSpyj || '无'}}</text>
 						</view>
 						<view v-else-if="item.lzzt == '3'"
 							style="width: 60px;display: flex;flex-direction: column;background-image: url('../../static/images/tongguo.png');background-position: left;background-size:58px 58px;background-repeat: no-repeat;">
-							<text>{{item.updateTime.substring(0,8) || item.createTime.substring(0,8)}}</text>
+							<text v-if="item.updateTime">{{item.updateTime.substring(0,8) }}</text>
+							<text v-else>{{item.createTime.substring(0,8) }}</text>
 							<text>{{item.lrSpyj || '无'}}</text>
 						</view>
 						<view v-else-if="item.lzzt == '4'"
 							style="width: 60px;display: flex;flex-direction: column;background-image: url('../../static/images/jujue.png');background-position: left;background-size:58px 58px;background-repeat: no-repeat;">
-							<text>{{item.updateTime.substring(0,8) || item.createTime.substring(0,8)}}</text>
+							<text v-if="item.updateTime">{{item.updateTime.substring(0,8) }}</text>
+							<text v-else>{{item.createTime.substring(0,8) }}</text>
 							<text>{{item.lrSpyj || '无'}}</text>
 						</view>
 					</template>

+ 35 - 7
pages/lr/register.vue

@@ -77,6 +77,12 @@
 		getOpenid,
 		setUser
 	} from '@/common/auth.js'
+	import {
+		updateKhjbxx,
+		infoKhjbxx,
+		GetLrByZjhm,
+		SaveKhjbxx
+	} from '@/api/kh.js'
 	export default {
 		components: {
 			lzcOCR
@@ -286,7 +292,7 @@
 								this.baseFormData.lrSpyj = ''
 								this.show = true
 								this.baseFormData.prelrZjz = this.zjcaijianSrc
-								uni.hideLoading()
+								this.faceSearch()
 							}
 
 						} else {
@@ -359,7 +365,8 @@
 					image: face,
 					image_type: 'BASE64',
 					group_id_list: this.groupId,
-					match_threshold: config.score
+					match_threshold: config.score,
+					max_user_num: 50
 				}
 				console.log("人脸搜索:", data)
 				uni.request({
@@ -391,9 +398,11 @@
 									})
 									this.baseFormData.xslrZjhm = JSON.stringify(xs)
 								}
-								this.faceAdd()
+								// this.faceAdd()
+								uni.hideLoading()
 							}
 						} else {
+							// uni.hideLoading()
 							this.faceAdd()
 						}
 					},
@@ -507,6 +516,10 @@
 			},
 			// 身份证识别
 			idcardEnd(words, src) {
+				if (words.image_status == "other_type_card") {
+					showConfirm('请上传正确的身份证人像面')
+					return
+				}
 				// 身份证号校验  性别  出生日期
 				// 修改之后的姓名和ocr返回校验,重新ocr
 				let id = words.words_result['公民身份号码'].words
@@ -534,10 +547,7 @@
 					showConfirm('请上传正确的身份证人像面')
 					return
 				}
-				if (words.image_status == "other_type_card") {
-					console.log('请上传正确的身份证人像面')
-					return
-				}
+
 				this.baseFormData.lrXb = getDictInfo(this.dicts.C0007, words.words_result['性别'].words)[0].value
 				this.baseFormData.lrMz = getDictInfo(this.dicts.C0009, words.words_result['民族'].words)[0].value
 
@@ -550,6 +560,24 @@
 				this.ocrXm = words.words_result['姓名'].words
 				this.zjSrc = src
 				this.zjcaijianSrc = base64ToUrl(words.card_image);
+
+
+				if (id) {
+					GetLrByZjhm({
+						lrJmzjhm: this.idcardMD5
+					}).then(res => {
+						console.log(res);
+						if (res.data) {
+							showConfirm('该账号已存在,请登录').then(res => {
+								if (res.confirm == true) {
+									uni.reLaunch({
+										url: '/pages/login/index'
+									})
+								}
+							})
+						}
+					})
+				}
 			},
 		}
 	}

+ 130 - 1
pages/test/index.vue

@@ -1,9 +1,138 @@
 <template>
-	<web-view src="@/static/index.html"></web-view>
+	<!-- <web-view src="../../static/index.html"></web-view> -->
 </template>
 
 <script>
+	import {
+		getUser
+	} from '@/common/auth.js';
+	import config from '@/config.js';
+	import {
+		translate,
+		base64ToUrl
+	} from '@/common/image.js'
+	export default {
+		data() {
+			return {
+				face: '',
+				groupId: '',
+				userInfo: {},
+				// 百度云access_token
+				token: '',
+				client_id: config.face_client_id,
+				client_secret: config.face_client_secret,
+			}
+		},
+		onLoad() {
+			this.getImage()
+			this.userInfo = getUser()
+			this.groupId = this.userInfo.dept.locationCode.substring(0, 6)
+		},
+		methods: {
+			getImage() {
+				uni.chooseImage({
+					count: 1,
+					sourceType: ['camera'],
+					sizeType: ['compressed'],
+					success: (res) => {
+						uni.showLoading({
+							title: '正在上传中...'
+						})
 
+						let size = res.tempFiles[0].size
+						let scale = 1
+						if (size / 1024 / 1024 > 0.9) scale = 0.6
+
+						translate(res.tempFilePaths[0], scale, 'blob', this.setSrc)
+					}
+				})
+			},
+			setSrc(e, blobUrl) {
+				this.src = blobUrl
+				uni.getFileInfo({
+					filePath: blobUrl,
+					success: (res) => {
+						console.log(res);
+						let size = res.size
+						let scale = 1
+						if (size / 1024 / 1024 > 0.9) {
+							scale = 0.6
+							translate(this.src, scale, 'blob', this.setSrc)
+						} else {
+							e = e.replace('data:image/jpeg;base64,', "");
+							this.face = e
+							this.getAccessToken()
+						}
+					},
+					fail: (err) => {
+						console.log("err:", err);
+					}
+				})
+			},
+			// 人脸搜索
+			faceSearch() {
+				let face = this.face
+				let data = {
+					image: face,
+					image_type: 'BASE64',
+					group_id_list: this.groupId,
+					match_threshold: config.score
+				}
+				console.log("人脸搜索:", data)
+				uni.request({
+					url: '/baiduApi/rest/2.0/face/v3/search?access_token=' + this.token,
+					data: data,
+					method: 'POST',
+					header: {
+						'Content-Type': 'application/json'
+					},
+					success: (res) => {
+						uni.hideLoading()
+						console.log("人脸搜索:", res)
+						if (res.data.error_msg == 'SUCCESS') {
+							// this.isSearch = true
+							if (res.data.result.user_list.length < 1) {
+								console.log("人脸不存在");
+							} else {
+
+
+							}
+						} else {
+							console.log("人脸不存在1111");
+
+						}
+
+					},
+					error: (err) => {
+						uni.hideLoading()
+					}
+				})
+			},
+			getAccessToken() {
+				uni.request({
+					url: '/baiduApi/oauth/2.0/token',
+					data: {
+						grant_type: 'client_credentials',
+						client_id: this.client_id,
+						client_secret: this.client_secret
+					},
+					method: 'POST',
+					header: {
+						'Content-Type': 'application/x-www-form-urlencoded'
+					},
+					success: (res) => {
+						if (res.statusCode == 200) {
+							this.token = res.data.access_token
+							this.faceSearch()
+						}
+					},
+					error: (err) => {
+						uni.hideLoading()
+					}
+				})
+			},
+		}
+	}
 </script>
 
 <style>