Bläddra i källkod

feature_20250926_数字题型&单行文本题型

zhujindu 1 månad sedan
förälder
incheckning
134bd0037f
2 ändrade filer med 88 tillägg och 12 borttagningar
  1. 9 0
      src/api/index.js
  2. 79 12
      src/views/deviceWithin/addStoreVisit.vue

+ 9 - 0
src/api/index.js

@@ -1064,3 +1064,12 @@ export function sendAndCheckVerCode(query) {
     params: query,
   });
 }
+
+// 电话确认接口
+export function confirmPhone(query) {
+  return request({
+    url: '/mobile/storeGroup/confirmPhone',
+    method: 'get',
+    params: query,
+  });
+}

+ 79 - 12
src/views/deviceWithin/addStoreVisit.vue

@@ -220,15 +220,15 @@
               v-model="item.answerValue"
               :placeholder="item.collectionOptionList[0].collectionOption"
               type="tel"
-              @blur="sendCodeTelFn(item, index, 'A')">
+              @blur="telConfirmBlur(item, index, 'A')">
               <template #button v-if="!verifyMobile">
                 <van-button
                   size="small"
                   style="color: white; background: rgb(0, 87, 186); border-radius: 6px"
-                  @click="sendCode(item, index)"
-                  :disabled="time != null">
-                  <span v-if="time">已发送({{ timeNum }})</span>
-                  <span v-else>发送验证码</span>
+                  @click="telConfirm(item, index)"
+                  :disabled="confirmed">
+                  <span v-if="confirmed">已确认</span>
+                  <span v-else>确认真实</span>
                 </van-button>
               </template>
             </van-field>
@@ -723,15 +723,15 @@
                         v-model="childitem.collectionOptionList[0].answerValue"
                         :placeholder="childitem.collectionOptionList[0].collectionOption"
                         type="tel"
-                        @blur="sendCodeTelFn(childitem, index)">
+                        @blur="telConfirmBlur(childitem, index)">
                         <template #button v-if="!verifyMobile">
                           <van-button
                             size="small"
                             style="color: white; background: rgb(0, 87, 186); border-radius: 6px"
-                            @click="sendCode(childitem, index)"
-                            :disabled="time != null">
-                            <span v-if="time">已发送({{ timeNum }})</span>
-                            <span v-else>发送验证码</span>
+                            @click="telConfirm(childitem, index)"
+                            :disabled="confirmed">
+                            <span v-if="confirmed">已确认</span>
+                            <span v-else>确认真实</span>
                           </van-button>
                         </template>
                       </van-field>
@@ -3763,6 +3763,7 @@ import {
   deleteTaskAnswer,
   getCollectionShowHistory,
   sendAndCheckVerCode,
+  confirmPhone,
 } from '@/api/index';
 import zRadio from '@/components/zRadio';
 import zCheckbox from '@/components/zCheckbox';
@@ -3877,6 +3878,7 @@ export default {
       currentDate: new Date(1945, 0, 1),
       continuousShoot: '0',
       validatorFlag: true, //是否验证通过
+      confirmed: false,
     };
   },
   beforeRouteLeave(to, from, next) {
@@ -3886,6 +3888,8 @@ export default {
     next();
   },
   activated() {
+    this.verificationPassedPhoneNum = '';
+    this.confirmed = false;
     this.showCode = false;
     this.flag = false;
     this.link = '3';
@@ -4327,6 +4331,25 @@ export default {
         this.verifyMobile = false;
       }
     },
+    telConfirmBlur(val) {
+      let answerValue = '';
+      if (val.answerValue != null) {
+        answerValue = val.answerValue;
+      } else if (val.answerValue && val.collectionOptionList.length) {
+        answerValue = val.collectionOptionList[0].answerValue;
+      }
+
+      if (!/^1[123456789]\d{9}$/.test(answerValue) || answerValue == '') {
+        this.$toast(val.collectionName + '格式错误');
+        return;
+      }
+      if (answerValue != this.verificationPassedPhoneNum) {
+        this.verifyMobile = false;
+        this.confirmed = false;
+      } else {
+        this.verifyMobile = true;
+      }
+    },
     numberFn(val, index, type) {
       let value = this.collectionItemList[index].answerValue;
       if (value) {
@@ -4643,6 +4666,19 @@ export default {
             if (collectionItemLists[q].answerType == 'xm') {
               this.XMsizeComparison(collectionItemLists[q], 'A');
             }
+            if (
+              collectionItemLists[q].answerType == 'tel_send_code' ||
+              collectionItemLists[q].answerType == 'tel_confirm'
+            ) {
+              if (
+                collectionItemLists[q].collectionOptionList[0].answerValue != null &&
+                this.verifyMobile
+              ) {
+                this.verificationPassedPhoneNum =
+                  collectionItemLists[q].collectionOptionList[0].answerValue;
+                console.log(this.verificationPassedPhoneNum);
+              }
+            }
             if (
               collectionItemLists[q].answerType == 'duox' ||
               collectionItemLists[q].answerType == 'dx'
@@ -4718,7 +4754,10 @@ export default {
                           listchild[qq1].answerValue = '';
                         }
                       }
-                      if (listchild[qq1].answerType == 'tel_send_code' || listchild[qq1].answerType == 'tel_confirm') {
+                      if (
+                        listchild[qq1].answerType == 'tel_send_code' ||
+                        listchild[qq1].answerType == 'tel_confirm'
+                      ) {
                         if (listchild[qq1].collectionOptionList[0].answerValue != null) {
                           listchild[qq1].answerValue =
                             listchild[qq1].collectionOptionList[0].answerValue;
@@ -6221,6 +6260,34 @@ export default {
         }
       );
     },
+    telConfirm(val) {
+      let item = '';
+      let answerValue = '';
+      if (val.collectionOptionList && val.collectionOptionList.length) {
+        answerValue = val.collectionOptionList[0].answerValue;
+        item = val.collectionOptionList[0];
+      } else {
+        answerValue = val.answerValue;
+        item = val;
+      }
+
+      if (!/^1[123456789]\d{9}$/.test(answerValue) || answerValue == '') {
+        this.$toast(val.collectionName + '格式错误');
+        return;
+      }
+      confirmPhone({
+        phone: answerValue, //	string	电话
+        visitId: this.visitId, //	Long	拜访id
+        taskId: this.taskId, //	Long	任务id
+        collectionId: item.collectionId, //	Long	采集项id
+      }).then((res) => {
+        if (res.code == 200) {
+          this.verificationPassedPhoneNum = answerValue;
+          this.confirmed = true;
+          this.$toast('发送成功');
+        }
+      });
+    },
     verification(item, collectionItems) {
       let answerValue = '';
       if (item.collectionOptionList && item.collectionOptionList.length) {
@@ -6233,7 +6300,7 @@ export default {
         return;
       }
       let telSendCode = collectionItems.find((res) => {
-        if (res.answerType == 'tel_send_code' || res.answerType == "tel_confirm") {
+        if (res.answerType == 'tel_send_code') {
           return res;
         }
       });