Ver Fonte

首页顶部banner添加跳转

Xiao_123 há 2 meses atrás
pai
commit
abf6e38a17
1 ficheiros alterados com 9 adições e 3 exclusões
  1. 9 3
      src/views/recruit/personal/home/index.vue

+ 9 - 3
src/views/recruit/personal/home/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div>
     <!-- 顶部广告图 -->
-    <div v-if="topAdvertise" class="banner" :style="{'background-image': 'url('+topAdvertise+')'}"></div>
+    <div v-if="topAdvertise?.img" class="banner" :style="{'background-image': 'url('+topAdvertise?.img+')'}" :class="{'cursor-pointer': topAdvertise?.link}" @click="handleAdvertise"></div>
     <div class="stickyBox py-5">
       <headSearch @handleSearch="handleSearch"></headSearch>
     </div>
@@ -65,7 +65,7 @@ import { getRewardEventList } from '@/utils/eventList'
 if (!getToken()) getRewardEventList()
 
 // 获取广告图
-const topAdvertise = ref('')
+const topAdvertise = ref({})
 const leftAdvertise = ref([])
 const dialogAdvertise = ref({})
 const preferred = ref([])
@@ -80,7 +80,7 @@ const getSystemWebContent = async () => {
   }) : []
   preferredContent.value = data.appPreferredGroup
   // 顶部广告
-  topAdvertise.value = data.pcTop && data.pcTop.length ? data.pcTop[0].img : ''
+  topAdvertise.value = data.pcTop && data.pcTop.length ? data.pcTop[0] : {}
   // 弹窗广告
   dialogAdvertise.value = data.pcAdvertisement ? data.pcAdvertisement[0] : {}
   // 左侧广告
@@ -104,6 +104,12 @@ const handleLeftClick = (val) => {
   } else window.open(val.link)
 }
 
+// 顶部banner跳转
+const handleAdvertise = () => {
+  if (!topAdvertise.value?.link) return
+  window.open(topAdvertise.value.link)
+}
+
 
 const router = useRouter()
 const handleSearch = (val) => {