shinnosuke
5 天以前 e52934f6527027bd6008c2ade61c3083159efd4a
rencaika/pages/policy-detail/policy-detail.uvue
@@ -29,11 +29,17 @@
   const policyCategory = ref('东区政策')
   const policyContent = ref('')
   const policyContentImages = ref<string[]>([])
   const policyCover = ref('/static/home-assets/home-banner-v2.jpg')
   const policyCover = ref('')
   const policyId = ref('')
   const initialLoading = ref(true)
   const initialError = ref(false)
   const policyUnavailable = ref(false)
   const policyContentText = (data: any): string => {
      const extracted = data != null && data.contentText != null ? (data.contentText as string).trim() : ''
      if (extracted != '') return extracted
      const raw = data != null && data.content != null ? data.content as string : ''
      return raw.replace(/<[^>]+>/g, '').replace(/&nbsp;/g, ' ').trim()
   }
   onLoad((options: any) => {
      if (options != null && options.id != null) policyId.value = decodeURIComponent(options.id as string)
@@ -55,9 +61,10 @@
      getPolicyDetail(policyId.value, (data: any) => {
         policyTitle.value = data != null && data.title != null ? data.title as string : '人才政策'
         policySummary.value = data != null && data.subtitle != null ? data.subtitle as string : ''
         policyCategory.value = data != null && data.categoryName != null ? data.categoryName as string : '东区政策'
         policyContent.value = data != null && data.contentText != null ? data.contentText as string : ''
         policyCover.value = '/static/home-assets/home-banner-v2.jpg'
         policyCategory.value = data != null && data.subtitle != null && (data.subtitle as string).trim() != '' ? data.subtitle as string : '人才政策'
         // 正文直接取后台政策内容;contentText 为空时兼容后台仅返回富文本 content 的情况。
         policyContent.value = policyContentText(data)
         policyCover.value = ''
         const heroImage = data != null && data.heroImage != null ? data.heroImage : (data != null ? data.coverUrl : null)
         if (heroImage != null && (heroImage as string).length > 0) policyCover.value = resolveApiUrl(heroImage as string)
         const images: string[] = []
@@ -75,10 +82,10 @@
         initialError.value = !policyUnavailable.value
      })
   }
   const useHeroFallback = () => { policyCover.value = '/static/home-assets/home-banner-v2.jpg' }
   const useHeroFallback = () => { policyCover.value = '' }
   const useContentImageFallback = (index: number) => {
      const next = policyContentImages.value.slice()
      next[index] = '/static/policy-assets/policy-explanation.jpg'
      next[index] = '/static/common/image-placeholder.png'
      policyContentImages.value = next
   }
   const goBack = () => safeBack('/pages/policy/policy')