85 lines
2.2 KiB
Vue
85 lines
2.2 KiB
Vue
<template>
|
|
<div class="fiveGridAdv">
|
|
<div class="fiveGrid" v-if="advList.length > 0" ref="advRef">
|
|
<div class="rectAdvBox" @click="handleJumpAdv(item)" v-for="item in advList" :key="item.id">
|
|
<lazyImg class="rectAdvIcon" :src="item.cover" />
|
|
<div class="rectName">{{ item.title }}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { nextTick, ref, watch } from 'vue';
|
|
import { jumpAdv } from '@/utils/index';
|
|
import { AdImpressionType, setAdImpression } from '@/utils/eventReporter/adImpression';
|
|
import { useRoute } from 'vue-router';
|
|
import { reportAdClickEvent } from '@/utils/eventReporter/adClick';
|
|
|
|
const route = useRoute();
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
advList: any;
|
|
adImpression?: AdImpressionType;
|
|
}>(),
|
|
{
|
|
advList: [],
|
|
},
|
|
);
|
|
// 广告展示埋点
|
|
const advRef = ref();
|
|
watch(
|
|
() => props.advList,
|
|
() => {
|
|
if (props.advList.length) {
|
|
nextTick(() => {
|
|
setAdImpression(advRef.value, props.advList, {
|
|
page_key: props.adImpression?.page_key || (route.meta.pageKey as string) || '',
|
|
page_name: props.adImpression?.page_name || (route.meta.pageName as string) || '',
|
|
ad_type: props.adImpression?.ad_type || 'small_grid',
|
|
}).setupObserver();
|
|
});
|
|
}
|
|
},
|
|
{ immediate: true },
|
|
);
|
|
const handleJumpAdv = (item: Types.App.AdsInfoListItem) => {
|
|
let params = {
|
|
...item,
|
|
page_key: props.adImpression?.page_key || (route.meta.pageKey as string) || '',
|
|
page_name: props.adImpression?.page_name || (route.meta.pageName as string) || '',
|
|
ad_type: props.adImpression?.ad_type || 'small_grid',
|
|
};
|
|
reportAdClickEvent(params);
|
|
jumpAdv(item);
|
|
};
|
|
</script>
|
|
<style scoped lang="scss">
|
|
.fiveGridAdv {
|
|
.fiveGrid {
|
|
display: flex;
|
|
overflow-x: auto;
|
|
margin: 18px 0;
|
|
.rectAdvBox {
|
|
width: 60px;
|
|
margin-right: 12px;
|
|
.rectAdvIcon {
|
|
height: 60px;
|
|
width: 60px;
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
}
|
|
.rectName {
|
|
font-size: 12px;
|
|
margin-top: 4px;
|
|
overflow: hidden;
|
|
white-space: nowrap;
|
|
text-align: center;
|
|
}
|
|
}
|
|
.rectAdvBox:last-child {
|
|
margin-right: 9px;
|
|
}
|
|
}
|
|
}
|
|
</style>
|