ad.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <div class="ad-container" v-if="list.length > 0">
  3. <a class="ad-list-item" v-for="(item, index) in list" :key="index" @click="tj" :href="item.url" target="view_window">
  4. <img :src="item.image">
  5. </a>
  6. </div>
  7. </template>
  8. <script>
  9. export default {
  10. props: ['location'],
  11. data() {
  12. return {
  13. list: []
  14. }
  15. },
  16. mounted() {
  17. this.fetchData()
  18. },
  19. methods: {
  20. getPagePath() {
  21. const link = location.href
  22. },
  23. tj()
  24. {
  25. this.$axios.$get("https://proginn-click.cn-hangzhou.log.aliyuncs.com/logstores/click/track_ua.gif?APIVersion=0.6.0&type=开发者首页广告");
  26. },
  27. async fetchData() {
  28. let res = await this.$axios.post('/uapi/pub/adInfo', {
  29. position: this.location
  30. })
  31. if (Number(res.data.status) === 1) {
  32. this.list = [...res.data.data.list]
  33. } else {
  34. this.$message.error(res.data.info);
  35. }
  36. }
  37. }
  38. }
  39. </script>
  40. <style lang="scss" scoped>
  41. .ad-container {
  42. // margin: 0 16px;
  43. }
  44. .ad-list-item {
  45. cursor: pointer;
  46. width: 100%;
  47. &:first-child {
  48. margin-top: 0
  49. }
  50. &:last-child {
  51. margin-bottom: 0;
  52. }
  53. img{
  54. width: 100%;
  55. height: 100%;
  56. }
  57. }
  58. .ad-tips {
  59. padding: 16px 0;
  60. font-size: 12px;
  61. text-align: center;
  62. color: #999;
  63. }
  64. </style>