Procházet zdrojové kódy

fix:修改服务对象照片识别结果 与 原服务对象进行对比

xuyunhui před 2 měsíci
rodič
revize
1510088778
1 změnil soubory, kde provedl 80 přidání a 60 odebrání
  1. 80 60
      myPages/serviceObjectAllInfo/index.vue

+ 80 - 60
myPages/serviceObjectAllInfo/index.vue

@@ -60,17 +60,17 @@
           </view>
           <view class="arrow-right">
 
-<!--            <picker mode="date" :value="date" :start="date" @change="bindDateChange">-->
-<!--              <view class="picker-change-store">-->
-<!--                <text v-if="userInfo.birthday">{{ userInfo.birthday }}</text>-->
-<!--                <text v-else>请选择生日</text>-->
-<!--                <u-icon name="arrow-right" color="#666" size="16"></u-icon>-->
-<!--              </view>-->
-<!--            </picker>-->
-
-            <picker @change="bindDateChange" mode='date' :disabled="isAuthUpdate ? false : true " range-key="label" >
+            <!--            <picker mode="date" :value="date" :start="date" @change="bindDateChange">-->
+            <!--              <view class="picker-change-store">-->
+            <!--                <text v-if="userInfo.birthday">{{ userInfo.birthday }}</text>-->
+            <!--                <text v-else>请选择生日</text>-->
+            <!--                <u-icon name="arrow-right" color="#666" size="16"></u-icon>-->
+            <!--              </view>-->
+            <!--            </picker>-->
+
+            <picker @change="bindDateChange" mode='date' :disabled="isAuthUpdate ? false : true " range-key="label">
               <view class="flex-row justify-end picker-change-store">
-                <text>{{ userInfo.birthday ?  userInfo.birthday.substring(0,10) : '请选择出生日期' }}</text>
+                <text>{{ userInfo.birthday ? userInfo.birthday.substring(0, 10) : '请选择出生日期' }}</text>
                 <u-icon name="arrow-right" color="#666" size="16"></u-icon>
               </view>
             </picker>
@@ -218,13 +218,15 @@
 
     <!-- 性别选择 -->
     <u-picker :show="genderShow" keyName="gender" @confirm="sureChooseGender" :columns="genderList"></u-picker>
-      <cropper selWidth="660rpx" selHeight="660rpx" ref="cropper" quality="0.5" @uploadImg="uploadCropImg"  @upload="userInfo.facePhotoUrl" />
+    <cropper selWidth="660rpx" selHeight="660rpx" ref="cropper" quality="0.5" @uploadImg="uploadCropImg"
+             @upload="userInfo.facePhotoUrl"/>
 
   </view>
 </template>
 
 <script>
-import cropper  from '@/components/lxiaoxiao-cropper/lxiaoxiao-cropper.vue';
+import cropper from '@/components/lxiaoxiao-cropper/lxiaoxiao-cropper.vue';
+
 export default {
   components: {
     cropper
@@ -270,12 +272,12 @@ export default {
   mounted() {
   },
   onLoad(option) {
-     this.accessToken = uni.getStorageSync("accessToken");
+    this.accessToken = uni.getStorageSync("accessToken");
     this.getServiceObjectList()
     if (option.data) {
       const data = JSON.parse(option.data);
       console.log('+++++++JSON.parse(option.data)++++++', option.data)
-      if(data.authServiceIds){
+      if (data.authServiceIds) {
         this.userInfo.serviceProjectId = data.authServiceIds.split(',');
       }
       this.userInfo.facePhotoUrl = data.facePhotoUrl;
@@ -296,17 +298,15 @@ export default {
       this.userInfo.nickName = data.nickName;
       this.userInfo.remark = data.remark;
       this.userInfo.id = data.id;
-      if (this.userInfo.id && this.userInfo.isSelf != 1){
+      if (this.userInfo.id && this.userInfo.isSelf != 1) {
         this.getServiceObjectPhotoRecord(this.userInfo.id)
       }
       console.log('+++++++JSON.parse(option.data)++++++', this.userInfo)
     }
-
-
   },
   methods: {
 
-    unbindServiceObject(){
+    unbindServiceObject() {
       let that = this
 
       uni.showModal({
@@ -317,8 +317,8 @@ export default {
             console.log('用户点击确定');
 
             that.$api.unbindServiceObject({
-              id:that.userInfo.id
-            }).then(res=>{
+              id: that.userInfo.id
+            }).then(res => {
               uni.showToast({
                 icon: 'none',
                 title: '解绑成功!'
@@ -334,21 +334,21 @@ export default {
 
     },
 
-    uploadCropImg(e){
+    uploadCropImg(e) {
       uni.compressImage({
         src: e,
         success: res => {
           uni.uploadFile({
             url: this.$baseUrl + '/resource/oss/upload',
-            filePath:res.tempFilePath,
+            filePath: res.tempFilePath,
             name: 'file',
             header: {
               'Authorization': 'Bearer ' + uni.getStorageInfo('accessToken'),
             },
             success: (uploadFileRes) => {
               let res = JSON.parse(uploadFileRes.data)
-              console.log(res,'成功回调')
-              if(res.code !== 200){
+              console.log(res, '成功回调')
+              if (res.code !== 200) {
                 uni.showToast({
                   icon: 'none',
                   duration: 3000,
@@ -357,63 +357,83 @@ export default {
               }
               res.data.url.replace("http", "https");
               this.verifyFace(res.data)
-              this.userInfo.facePhotoUrl =  res.data.url.replace("http", "https");
+              this.userInfo.facePhotoUrl = res.data.url.replace("http", "https");
             }
           });
         }
       })
     },
 
-    getServiceObjectPhotoRecord(serviceObjectId){
-        this.$api.getServiceObjectPhotoRecord(
-            {
-              serviceObjectId:serviceObjectId
-            }).then(res=>{
-          console.log(res)
-              if (res.data.data){
-                uni.showModal({
-                  title:"温馨提示",
-                  content:"当前服务对象已授权,照片可修改",
-                  showCancel: false,
-                  success: function (res) {
-                    if (res.confirm) {
-                      console.log('用户点击确定');
-                    } else if (res.cancel) {
-                      console.log('用户点击取消');
-                    }
-                  }
-                })
+    getServiceObjectPhotoRecord(serviceObjectId) {
+      this.$api.getServiceObjectPhotoRecord(
+          {
+            serviceObjectId: serviceObjectId
+          }).then(res => {
+        console.log(res)
+        if (res.data.data) {
+          uni.showModal({
+            title: "温馨提示",
+            content: "当前服务对象已授权,照片可修改",
+            showCancel: false,
+            success: function (res) {
+              if (res.confirm) {
+                console.log('用户点击确定');
+              } else if (res.cancel) {
+                console.log('用户点击取消');
               }
+            }
+          })
+        }
 
-              this.isAuthUpdate = res.data.data
+        this.isAuthUpdate = res.data.data
 
-        })
+      })
     },
 
     // 验证人象
-    verifyFace(data){
-      let that  = this;
+    verifyFace(data) {
+      let that = this;
       uni.showLoading({
         title: '人脸识别中'
       })
 
-      if(this.requestStatus){
+      if (this.requestStatus) {
         return;
       }
-      this.requestStatus=true
+      this.requestStatus = true
 
       this.$api.verifyFace({
         auth: true,
         facePath: data.ossId,
         businessId: ''
-      }).then((res)=>{
-        this.requestStatus=false
+      }).then((res) => {
+        this.requestStatus = false
         uni.hideLoading();
-        this.userInfo.facePhoto= data.ossId
-        this.userInfo.facePhotoUrl=data.url
-      }).catch((err) =>{
-        this.requestStatus=false
-        uni.$u.toast(err.data.msg||'识别失败,请重新上传照片')
+        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 = '';
+              }
+            }
+          })
+          return;
+        }
+
+        this.userInfo.facePhoto = data.ossId
+        this.userInfo.facePhotoUrl = data.url
+      }).catch((err) => {
+        this.requestStatus = false
+        uni.$u.toast(err.data.msg || '识别失败,请重新上传照片')
       });
 
     },
@@ -469,21 +489,21 @@ export default {
       if (!this.userInfo.nickName) {
         uni.showToast({
           title: "请认真填写宝贝昵称",
-          icon:"none"
+          icon: "none"
         })
         return;
       }
       if (!this.userInfo.blood) {
         uni.showToast({
           title: "请认真填写关系",
-          icon:"none"
+          icon: "none"
         })
         return;
       }
       if (!this.userInfo.birthday) {
         uni.showToast({
           title: "请认真填写宝贝生日",
-          icon:"none"
+          icon: "none"
         })
         return;
       }