Forráskód Böngészése

商品靠左对其 banner路由跳转

linwei 1 éve
szülő
commit
3a3b9f0b4f

+ 6 - 2
src/components/ProductServices/ProductServicesMain.vue

@@ -86,7 +86,11 @@ onMounted(async() => {
         let List = []
         res2.data.rows.forEach(item =>{
             if (item?.carouselUrlList && item?.carouselUrlList[0]) {
-                List.push(item?.carouselUrlList[0])
+                let data = {
+                    ...item,
+                    ...item?.carouselUrlList[0]
+                }
+                List.push(data)
             }
         })
 
@@ -267,7 +271,7 @@ function openDetail (e){
     display: flex;
     align-items: center;
     flex-wrap: wrap;
-    justify-content: space-evenly;
+    justify-content: flex-start;
 }
 .right_meun_item{
     display: flex;

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

@@ -12,7 +12,7 @@
                 </div>
             </template>
             <div v-for="item in imglist" :key="item.name">
-                <img  :style="carouselImgstyle" :src="item.fileUrl" alt="">
+                <img @click="openDetail(item)"  :style="carouselImgstyle" :src="item.fileUrl" alt="">
             </div>
         </a-carousel>
         
@@ -22,7 +22,10 @@
 <script setup>
 import {onMounted,ref,watch} from 'vue'
 import { LeftCircleOutlined, RightCircleOutlined } from '@ant-design/icons-vue';
-
+//定义路由
+import {useRouter,useRoute} from 'vue-router'
+const router=useRouter()
+const route=useRoute()
 const imglist = ref([])
 
 const carouselImgstyle = ref({
@@ -73,7 +76,22 @@ watch(()=>props.carouselList ,(val,oldval)=>{
     deep:true
 })
 
+function openDetail (e){
+    //回到顶部
+    const targetElement = document.getElementById('top');
+    if (targetElement) {
+        targetElement.scrollIntoView();
+    }
 
+    //1=文章,2=外链,空为无跳转
+    if (e?.targetType == '1') {
+        window.open(e?.url, "_blank");
+    }else if (e?.targetType == '2') {
+        //富文本
+        router.push('/CompanyNews?openType=1&id='+e?.articleId + '&bodyType=1&title='+e?.title)
+    }
+
+}
 
 </script>
 

+ 5 - 1
src/views/components/indexComponent.vue

@@ -40,7 +40,11 @@ onMounted(async() => {
         let List = []
         res.data.rows.forEach(item =>{
             if (item?.carouselUrlList && item?.carouselUrlList[0]) {
-                List.push(item?.carouselUrlList[0])
+                let data = {
+                    ...item,
+                    ...item?.carouselUrlList[0]
+                }
+                List.push(data)
             }
         })
         carouselList.value = List