Browse Source

跳文章前先去获取文章类型之后再做跳转

linwei 1 year ago
parent
commit
7cb0390485
1 changed files with 9 additions and 2 deletions
  1. 9 2
      src/components/index/custom-carousel.vue

+ 9 - 2
src/components/index/custom-carousel.vue

@@ -21,6 +21,7 @@
 
 
 <script setup>
 <script setup>
 import {onMounted,ref,watch} from 'vue'
 import {onMounted,ref,watch} from 'vue'
+import {getArticleDetailByOpen} from '@/http/api/common.js' 
 import { LeftCircleOutlined, RightCircleOutlined } from '@ant-design/icons-vue';
 import { LeftCircleOutlined, RightCircleOutlined } from '@ant-design/icons-vue';
 //定义路由
 //定义路由
 import {useRouter,useRoute} from 'vue-router'
 import {useRouter,useRoute} from 'vue-router'
@@ -76,7 +77,7 @@ watch(()=>props.carouselList ,(val,oldval)=>{
     deep:true
     deep:true
 })
 })
 
 
-function openDetail (e){
+async function openDetail (e){
     //回到顶部
     //回到顶部
     const targetElement = document.getElementById('top');
     const targetElement = document.getElementById('top');
     if (targetElement) {
     if (targetElement) {
@@ -87,8 +88,14 @@ function openDetail (e){
     if (e?.targetType == '2') {
     if (e?.targetType == '2') {
         window.open(e?.url, "_blank");
         window.open(e?.url, "_blank");
     }else if (e?.targetType == '1') {
     }else if (e?.targetType == '1') {
+        //获取文章详情
+        let res = await getArticleDetailByOpen({
+            id:e?.articleId
+        })
+        let bodyType = res.data?.bodyType || '1'
         //富文本
         //富文本
-        router.push('/CompanyNews?openType=1&id='+e?.articleId + '&bodyType=1&title='+e?.title)
+        router.push('/CompanyNews?openType=1&id='+e?.articleId 
+        + '&bodyType='+bodyType+'&title='+e?.title)
     }
     }
 
 
 }
 }