<template>
<div class="ad-container" v-if="list.length > 0">

    <a class="ad-list-item" v-for="(item, index) in list" :key="index" @click="tj" :href="item.url" target="view_window">
      <img :src="item.image">
    </a>

</div>
</template>

<script>
export default {
    props: ['location'],
    data() {
        return {
            list: []
        }
    },
    mounted() {
        this.fetchData()
    },
    methods: {
        getPagePath() {
            const link = location.href
        },
        tj()
        {
          this.$axios.$get("https://proginn-click.cn-hangzhou.log.aliyuncs.com/logstores/click/track_ua.gif?APIVersion=0.6.0&type=开发者首页广告");
        },
        async fetchData() {
            let res = await this.$axios.post('/uapi/pub/adInfo', {
                position: this.location
            })
            if (Number(res.data.status) === 1) {
                this.list = [...res.data.data.list]
            } else {
                this.$message.error(res.data.info);
            }

        }
    }
}
</script>

<style lang="scss" scoped>
.ad-container {
    // margin: 0 16px;
}

.ad-list-item {
    cursor: pointer;
    width: 100%;
    &:first-child {
        margin-top: 0
    }

    &:last-child {
        margin-bottom: 0;
    }

    img{
        width: 100%;
        height: 100%;
    }
}

.ad-tips {
    padding: 16px 0;
    font-size: 12px;
    text-align: center;
    color: #999;
}
</style>
