Pārlūkot izejas kodu

完成签约渠道加载实现

yuanmingze 3 nedēļas atpakaļ
vecāks
revīzija
f3148ad330

+ 39 - 34
src/pages-auth/settlement-channel-sign/index.vue

@@ -145,6 +145,7 @@ const SELECTABLE_CERT_STATUS = new Set(['UN_SIGN', 'FAIL_SIGN'])
 const userStore = useUserStore()
 
 const subjectLocationDictList = ref<DictItem[]>([])
+const isSubjectLocationDictLoaded = ref(false)
 const selectedSubjectLocation = ref('')
 const isSubmitting = ref(false)
 
@@ -163,6 +164,8 @@ const certList = computed(() => {
 })
 
 const channelList = computed<ChannelItem[]>(() => {
+  if (!isSubjectLocationDictLoaded.value) return []
+
   return subjectLocationList.value.map((subjectLocation) => {
     const certItem = findCertItem(subjectLocation)
     const selectable = isSelectableChannel(certItem)
@@ -204,6 +207,8 @@ const getSubjectLocationDict = async (): Promise<void> => {
   } catch (error) {
     console.log('getSubjectLocationDict error:', error)
     subjectLocationDictList.value = []
+  } finally {
+    isSubjectLocationDictLoaded.value = true
   }
 }
 
@@ -298,15 +303,6 @@ const signCert = async (): Promise<void> => {
   await afterSignCert()
 }
 
-// 判断是否是有感签约
-const isExternal = computed(() => {
-  const externalValueArr = ['BOSS_KG_YJB', 'OSAIS']
-  const currentGigItem = subjectLocationDictList.value.find(
-    (item) => item.value === selectedSubjectLocation.value
-  )
-  return externalValueArr.includes(currentGigItem?.externalValue || '')
-})
-
 const afterSignCert = async (): Promise<void> => {
   if (selectedSubjectLocation.value === 'FESCO') {
     uni.navigateTo({
@@ -321,15 +317,18 @@ const afterSignCert = async (): Promise<void> => {
     (!certList.value.length ||
       !currentCert ||
       !currentCert.agreementUrl ||
-      currentCert.commonCertStatus === 'FAIL_SIGN') &&
-    !isExternal.value
+      currentCert.commonCertStatus === 'FAIL_SIGN')
 
   if (shouldLoadAgreement) {
+    const certResult = await certFn(false)
+
+    if (certResult !== 'NO_H5_SIGN') return
+
     await getSubjectLocationAgreement()
     return
   }
 
-  certFn()
+  await certFn()
 }
 
 const getSubjectLocationAgreement = async (): Promise<void> => {
@@ -340,19 +339,20 @@ const getSubjectLocationAgreement = async (): Promise<void> => {
 
     agreementList.value = normalizeAgreementInfos(res.data?.agreementInfos)
 
-    showAgreementPopupIfNeeded()
+    await showAgreementPopupIfNeeded()
   } catch (error) {
     console.error('getSubjectLocationAgreement error:', error)
   }
 }
 
-const showAgreementPopupIfNeeded = (): void => {
+const showAgreementPopupIfNeeded = async (): Promise<void> => {
   agreementChecked.value = false
   if (agreementList.value.length) {
     agreementPopupVisible.value = true
     return
   }
-  certFn()
+
+  await handleCertSuccess()
 }
 
 const handleCloseAgreementPopup = (): void => {
@@ -373,11 +373,6 @@ const handleConfirmAgreement = () => {
   agreementChecked.value = false
   agreementPopupVisible.value = false
 
-  // 有感签约下 直接去认证
-  if (isExternal.value) {
-    certFn()
-    return
-  }
   uni.navigateTo({
     url: `/pages-common/signature/index?type=SETTLEMENT_CHANNEL_SIGN`,
     events: {
@@ -401,7 +396,7 @@ const handleSignatureSuccess = async (payload: SignatureSuccessPayload) => {
   }
 
   await signAgreementApi(obj)
-  certFn()
+  await certFn()
 }
 
 const handlePreviewAgreementPdf = (agreement: AgreementPdfItem): void => {
@@ -410,12 +405,26 @@ const handlePreviewAgreementPdf = (agreement: AgreementPdfItem): void => {
   })
 }
 
-const certFn = async () => {
+type ChannelCertResult = 'FAILED' | 'H5_SIGN_REDIRECTED' | 'NO_H5_SIGN'
+
+const handleCertSuccess = async (): Promise<void> => {
+  settlementSignStore.clearContext()
+
+  uni.showToast({
+    title: '签约成功',
+    icon: 'success',
+    duration: 2000,
+  })
+
+  await userStore.getUserInfoByCode()
+}
+
+const certFn = async (completeWhenNoH5 = true): Promise<ChannelCertResult> => {
   const subjectLocation = selectedSubjectLocation.value
 
   if (!subjectLocation) {
     showToast('请选择认证渠道')
-    return
+    return 'FAILED'
   }
 
   const accountInfo = wx.getAccountInfoSync()
@@ -437,7 +446,7 @@ const certFn = async () => {
 
   if (res.data.commonCertStatus === 'FAIL_SIGN') {
     showToast(res.msg || res.data.errMsg || '签约失败')
-    return
+    return 'FAILED'
   }
 
   const h5SignUrl = res.data?.h5SignUrl
@@ -453,18 +462,14 @@ const certFn = async () => {
       )}&signTraceId=${encodeURIComponent(context.signTraceId)}`,
     })
 
-    return
+    return 'H5_SIGN_REDIRECTED'
   }
 
-  settlementSignStore.clearContext()
-
-  uni.showToast({
-    title: '签约成功',
-    icon: 'success',
-    duration: 2000,
-  })
+  if (completeWhenNoH5) {
+    await handleCertSuccess()
+  }
 
-  await userStore.getUserInfoByCode()
+  return 'NO_H5_SIGN'
 }
 
 const signRedirect = async (subjectLocation: string): Promise<boolean> => {
@@ -497,7 +502,7 @@ onLoad(async (query) => {
     await signRedirect(subjectLocation)
   }
 
-  getSubjectLocationDict()
+  await getSubjectLocationDict()
 })
 </script>
 

+ 0 - 4
src/pages-task/task-form/components/DynamicTaskFormFields.vue

@@ -164,13 +164,11 @@ const props = withDefaults(
     selectLevel: AreaSelectLevel
     disabled?: boolean
     hiddenFieldTypes?: string[]
-    hiddenFieldKeys?: string[]
     hiddenFieldAliases?: string[]
   }>(),
   {
     disabled: false,
     hiddenFieldTypes: () => [],
-    hiddenFieldKeys: () => [],
     hiddenFieldAliases: () => [],
   }
 )
@@ -186,7 +184,6 @@ const taskFieldConfigListRef = computed(() => props.taskFieldConfigList)
 const activeTaskTypeIdRef = computed(() => props.activeTaskTypeId)
 const taskTypesRef = computed(() => props.taskTypes)
 const hiddenFieldTypeSet = computed(() => new Set(props.hiddenFieldTypes))
-const hiddenFieldKeySet = computed(() => new Set(props.hiddenFieldKeys))
 const hiddenFieldAliasSet = computed(() => new Set(props.hiddenFieldAliases))
 
 const {
@@ -225,7 +222,6 @@ const shouldRenderField = (field: TaskFieldConfigViewItem) => {
     field.show &&
     isSupported(field.taskFiledType) &&
     !hiddenFieldTypeSet.value.has(field.taskFiledType) &&
-    !hiddenFieldKeySet.value.has(field.taskFiledKey) &&
     !hiddenFieldAliasSet.value.has(field.alias ?? '')
   )
 }

+ 0 - 2
src/pages-task/task-visit-add/index.vue

@@ -61,7 +61,6 @@
             :task-types="taskTypes"
             :select-level="selectLevel"
             :hidden-field-types="hiddenFieldTypes"
-            :hidden-field-keys="hiddenFieldKeys"
             :hidden-field-aliases="hiddenFieldAliases"
             @derived-change="handleDerivedFieldChange"
           />
@@ -158,7 +157,6 @@ const TASK_TYPE_META: Readonly<Record<string, { typeName: string; title: string
 
 const GLOBAL_COOLDOWN_SECONDS = 30 * 60
 const hiddenFieldTypes = ['map', 'location']
-const hiddenFieldKeys = ['temp30']
 const hiddenFieldAliases = ['taskDate']
 
 const userStore = useUserStore()