|
|
@@ -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>
|
|
|
|