shinnosuke
4 天以前 5ce0d76154bf4c1d70543476cdfad9a30195b0f8
rencaika/pages/policy-detail/policy-detail.uvue
@@ -1,7 +1,7 @@
<template>
   <view class="page">
      <view class="custom-nav"><view class="safe-space" :style="'height:' + navTop + 'px'"></view><view class="nav-row" :style="'height:' + navHeight + 'px;padding-right:' + navRight + 'px'"><view class="back-button" hover-class="back-button-active" @tap="goBack"><image src="/static/news-assets/arrow-left.svg"></image></view><text class="nav-title">人才政策</text><view class="capsule-space" :style="'width:' + navWidth + 'px'"></view></view></view>
      <scroll-view class="content" scroll-y>
      <scroll-view :show-scrollbar="false" class="content" scroll-y>
         <view v-if="initialLoading" class="detail-state"><view class="loading-spinner"></view><text>正在加载政策详情</text></view>
         <view v-else-if="policyUnavailable" class="detail-state error-state"><text>政策已失效</text><text class="retry-text" @tap="goBack">返回政策列表</text></view>
         <view v-else-if="initialError" class="detail-state error-state"><text>政策详情加载失败</text><text class="retry-text" @tap="loadPolicy">重新加载</text></view>
@@ -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')