Browse Source

banner 完善需求

bding 4 weeks ago
parent
commit
b82c06567b
2 changed files with 56 additions and 19 deletions
  1. 28 12
      src/views/hzyb/report/ChapterDetail.vue
  2. 28 7
      src/views/hzyb/report/Detail.vue

+ 28 - 12
src/views/hzyb/report/ChapterDetail.vue

@@ -262,13 +262,7 @@ export default {
       collectIcons,
 
       isReportPublishCancel:false,//报告取消发布
-      bannerDataList:[
-        {
-        id:10005,
-        image_url_mobile:'https://hzstatic.hzinsights.com/banner/yb_research/ai_detail.png',
-        reportId:13313
-        }
-      ],
+      bannerDataList:[],
 
       headImgStyle:null,//版头style
       endImgStyle:null,//版尾style
@@ -291,7 +285,7 @@ export default {
     this.fromPage=this.$route.query.fromPage||''
     this.getDetail()
     this.getConfig()
-    // this.getBannerList()
+    this.getBannerList()
   },
   mounted(){
         $(document).on('click', '.rich-content img',function(event) {
@@ -314,10 +308,32 @@ export default {
   methods: {
     // banner 获取列表
     async getBannerList(){
-      const res = await apiPublicBannerList()
+          const res = await apiPublicBannerList({
+            banner_type: 1
+          })
           if(res.code ==200){
-            this.bannerDataList = res.data
-          }
+              let isBo = res.data.some(item => {
+                  try {
+                      // 安全解析JSON并处理空值
+                      const ignoreReport = JSON.parse(item.ignore_report || "{}") || {}
+                      
+                      // 获取目标ID并统一类型为数字
+                      const targetId = Number(this.chapterId)
+                      
+                      // 获取忽略列表并统一元素类型
+                      const ignoreList = (ignoreReport.report_id_list || [])
+                      .map(Number)  // 确保数组元素为数字类型
+                      
+                      // 返回是否包含目标ID
+                      return ignoreList.includes(targetId)
+                  } catch (error) {
+                      // 错误处理(根据需求选择处理方式)
+                      console.error('JSON解析失败:', error)
+                      return false  // 解析失败时视为不包含
+                  }
+              })
+              this.bannerDataList = isBo ? [] :  res.data
+            }
     },
     getConfig() {
       apiBaseConfig().then(res => {
@@ -335,7 +351,7 @@ export default {
          })
          if(res.code===200){
            wx.miniProgram.navigateTo({
-             url:"/pages-report/reportDetail?reportId=" + item.reportId
+             url: item.jump_url_mobile
            })
          }
     },

+ 28 - 7
src/views/hzyb/report/Detail.vue

@@ -1,12 +1,12 @@
 <template>
 <van-pull-refresh v-model="loading" disabled style="min-height:100vh">
-    <!-- <div class="content-swipe" v-if="bannerDataList.length > 0">
+    <div class="content-swipe" v-if="bannerDataList.length > 0">
         <van-swipe class="my-swipe" :autoplay="4000" :show-indicators="false">
             <van-swipe-item v-for="item in bannerDataList" :key="item.id" @click="bannerSwiperHandler(item)">
                 <img :src="item.image_url_mobile" />
             </van-swipe-item>
         </van-swipe>
-    </div> -->
+    </div>
     <div class="report-detail-page" @click="closeAttention" v-if="info" :style="{paddingBottom:$store.state.hzyb.audioData.url&&'80px'}">
         <!-- 晨报、周报章节 -->
         <div class="chapter-list-wrap" v-if="info.report_info.has_chapter&&info.report_detail_show_type===2">
@@ -336,7 +336,7 @@ export default {
         this.getDetail()
         this.getUserInfo()
         this.getConfig()
-        // this.getBannerList()
+        this.getBannerList()
     },
     mounted(){
         $(document).on('click', '.rich-content img',function(event) {
@@ -359,10 +359,31 @@ export default {
     methods: {
         // banner 获取列表
         async getBannerList(){
-            console.log(112233333);
-            const res = await apiPublicBannerList()
+            const res = await apiPublicBannerList({
+                 banner_type: 1
+            })
             if(res.code ===200){
-                this.bannerDataList = res.data
+                let isBo = res.data.some(item => {
+                  try {
+                      // 安全解析JSON并处理空值
+                      const ignoreReport = JSON.parse(item.ignore_report || "{}") || {}
+                      
+                      // 获取目标ID并统一类型为数字
+                      const targetId = Number(this.reportId)
+                      
+                      // 获取忽略列表并统一元素类型
+                      const ignoreList = (ignoreReport.report_id_list || [])
+                      .map(Number)  // 确保数组元素为数字类型
+                      
+                      // 返回是否包含目标ID
+                      return ignoreList.includes(targetId)
+                  } catch (error) {
+                      // 错误处理(根据需求选择处理方式)
+                      console.error('JSON解析失败:', error)
+                      return false  // 解析失败时视为不包含
+                  }
+                })
+                this.bannerDataList = isBo ? [] :  res.data
             }
         },
 
@@ -382,7 +403,7 @@ export default {
             })
             if(res.code===200){
               wx.miniProgram.navigateTo({
-                url:"/pages-report/disseminatePage/disseminatePage?imgHb="+item.jump_url_mobile+'&title='+item.remark
+                url: item.jump_url_mobile
               })
             }
         },