BuySellAds.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div class="buy-sell-ads">
  3. <div class="bsa-cpc" />
  4. </div>
  5. </template>
  6. <script setup lang="ts">
  7. import { defineProps, onMounted } from 'vue'
  8. // global _bsa
  9. const ID = 'bsa-cpc-script'
  10. declare global {
  11. var _bsa: BSA | undefined
  12. interface BSA {
  13. init(
  14. name: string,
  15. code: string,
  16. placement: string,
  17. options: {
  18. target: string
  19. align: string
  20. disable_css?: 'true' | 'false'
  21. }
  22. ): void
  23. }
  24. }
  25. const { code, placement } = defineProps<{
  26. code: string
  27. placement: string
  28. }>()
  29. onMounted(() => {
  30. if (!document.getElementById(ID)) {
  31. const s = document.createElement('script')
  32. s.id = ID
  33. s.src = '//m.servedby-buysellads.com/monetization.js'
  34. document.head.appendChild(s)
  35. s.onload = () => {
  36. load()
  37. }
  38. } else {
  39. load()
  40. }
  41. })
  42. function load() {
  43. if (typeof _bsa !== 'undefined' && _bsa) {
  44. _bsa.init('default', code, `placement:${placement}`, {
  45. target: '.bsa-cpc',
  46. align: 'horizontal',
  47. disable_css: 'true'
  48. })
  49. }
  50. }
  51. </script>
  52. <style scoped>
  53. .buy-sell-ads {
  54. margin: 0 auto;
  55. padding-top: 2rem;
  56. font-size: 0.85rem;
  57. }
  58. .bsa-cpc {
  59. border-radius: 6px;
  60. background-color: var(--c-bg-accent);
  61. }
  62. .bsa-cpc ::v-deep(a._default_) {
  63. display: flex;
  64. flex-wrap: wrap;
  65. align-items: flex-start;
  66. margin-bottom: 20px;
  67. padding: 12px;
  68. text-decoration: none;
  69. line-height: 1.4;
  70. font-weight: 400;
  71. color: var(--c-text-light);
  72. }
  73. @media (min-width: 512px) {
  74. .bsa-cpc ::v-deep(a._default_) {
  75. flex-wrap: nowrap;
  76. }
  77. }
  78. .bsa-cpc ::v-deep(.default-ad) {
  79. display: none;
  80. }
  81. .bsa-cpc ::v-deep(a._default_ .default-image) {
  82. flex-shrink: 0;
  83. margin-right: 12px;
  84. width: 24px;
  85. }
  86. .bsa-cpc ::v-deep(a._default_ .default-image img) {
  87. border-radius: 4px;
  88. height: 24px;
  89. vertical-align: middle;
  90. }
  91. .bsa-cpc ::v-deep(._default_::after) {
  92. border: 1px solid #1c90f3;
  93. border-radius: 4px;
  94. margin-top: 8px;
  95. margin-left: 36px;
  96. padding: 0 8px;
  97. line-height: 22px;
  98. font-size: 0.85em;
  99. font-weight: 500;
  100. color: #1c90f3;
  101. content: 'Sponsored';
  102. }
  103. @media (min-width: 512px) {
  104. .bsa-cpc ::v-deep(._default_::after) {
  105. margin-top: 0px;
  106. margin-left: 12px;
  107. }
  108. }
  109. .bsa-cpc ::v-deep(.default-text) {
  110. flex-grow: 1;
  111. align-self: center;
  112. width: calc(100% - 36px);
  113. }
  114. @media (min-width: 512px) {
  115. .bsa-cpc ::v-deep(.default-text) {
  116. width: auto;
  117. }
  118. }
  119. .bsa-cpc ::v-deep(.default-title) {
  120. font-weight: 600;
  121. }
  122. .bsa-cpc ::v-deep(.default-description) {
  123. padding-left: 8px;
  124. }
  125. </style>