|
|
@@ -402,6 +402,10 @@ export default {
|
|
|
}
|
|
|
this.requestStatus = true
|
|
|
|
|
|
+ // 保存原来的照片信息,用于识别失败时恢复
|
|
|
+ const originalFacePhoto = this.userInfo.facePhoto;
|
|
|
+ const originalFacePhotoUrl = this.userInfo.facePhotoUrl;
|
|
|
+
|
|
|
this.$api.verifyFace({
|
|
|
auth: true,
|
|
|
facePath: data.ossId,
|
|
|
@@ -409,30 +413,45 @@ export default {
|
|
|
}).then((res) => {
|
|
|
this.requestStatus = false
|
|
|
uni.hideLoading();
|
|
|
- console.log(this.userInfo.id,'this.userInfo.id')
|
|
|
- console.log(res.data.data.id,'res.data.data.id')
|
|
|
- // 判断回调中的 id 是否等于原服务对象 id
|
|
|
- if (res.data && this.userInfo.id && res.data.data.id !== this.userInfo.id) {
|
|
|
- uni.showModal({
|
|
|
- title: '温馨提示',
|
|
|
- content: '人脸识别的服务对象与当前服务对象不一致,不允许修改照片!',
|
|
|
- showCancel: false,
|
|
|
- success: function (modalRes) {
|
|
|
- if (modalRes.confirm) {
|
|
|
- console.log('用户点击确定');
|
|
|
- // 清空人脸照片信息,不允许保存
|
|
|
- that.userInfo.facePhoto = '';
|
|
|
- that.userInfo.facePhotoUrl = '';
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ console.log(this.userInfo.id, 'this.userInfo.id')
|
|
|
+ console.log(res.data, 'res.data')
|
|
|
+
|
|
|
+ // 情况1: code === 500,查无此人,直接通过
|
|
|
+ if (res.data.code === 500) {
|
|
|
+ console.log('查无此人,允许直接通过,相当于新增')
|
|
|
+ this.userInfo.facePhoto = data.ossId
|
|
|
+ this.userInfo.facePhotoUrl = data.url
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- this.userInfo.facePhoto = data.ossId
|
|
|
- this.userInfo.facePhotoUrl = data.url
|
|
|
+ // 情况2: 存在 id,需要判断回调中的 id 是否等于原服务对象 id
|
|
|
+ if (res.data.data && res.data.data.id) {
|
|
|
+ if (this.userInfo.id && res.data.data.id !== this.userInfo.id) {
|
|
|
+ // 识别到的服务对象与当前服务对象不一致
|
|
|
+ uni.showModal({
|
|
|
+ title: '温馨提示',
|
|
|
+ content: '人脸识别的服务对象与当前服务对象不一致,不允许修改照片!',
|
|
|
+ showCancel: false,
|
|
|
+ success: function (modalRes) {
|
|
|
+ if (modalRes.confirm) {
|
|
|
+ console.log('用户点击确定');
|
|
|
+ // 恢复原来的照片信息,不允许保存新照片
|
|
|
+ that.userInfo.facePhoto = originalFacePhoto;
|
|
|
+ that.userInfo.facePhotoUrl = originalFacePhotoUrl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // id 一致或当前是新服务对象,允许修改
|
|
|
+ this.userInfo.facePhoto = data.ossId
|
|
|
+ this.userInfo.facePhotoUrl = data.url
|
|
|
+ }
|
|
|
}).catch((err) => {
|
|
|
this.requestStatus = false
|
|
|
+ // 识别失败时也恢复原来的照片
|
|
|
+ this.userInfo.facePhoto = originalFacePhoto;
|
|
|
+ this.userInfo.facePhotoUrl = originalFacePhotoUrl;
|
|
|
uni.$u.toast(err.data.msg || '识别失败,请重新上传照片')
|
|
|
});
|
|
|
|
|
|
@@ -563,7 +582,7 @@ export default {
|
|
|
//头像上传
|
|
|
uploadImg1(imgIndex) {
|
|
|
console.log(this.isAuthUpdate)
|
|
|
- if (!this.isAuthUpdate){
|
|
|
+ if (!this.isAuthUpdate) {
|
|
|
return //关闭头像上传
|
|
|
}
|
|
|
|