uni-list-ad.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <!-- #ifdef APP-NVUE -->
  3. <cell>
  4. <!-- #endif -->
  5. <view class="uni-list-ad">
  6. <view v-if="borderShow" :class="{'uni-list--border':border,'uni-list-item--first':isFirstChild}"></view>
  7. <ad style="width: 200px;height: 300px;border-width: 1px;border-color: red;border-style: solid;" adpid="1111111111" unit-id="" appid="" apid="" type="feed" @error="aderror" @close="closeAd"></ad>
  8. </view>
  9. <!-- #ifdef APP-NVUE -->
  10. </cell>
  11. <!-- #endif -->
  12. </template>
  13. <script>
  14. // #ifdef APP-NVUE
  15. const dom = uni.requireNativePlugin('dom');
  16. // #endif
  17. export default {
  18. name: 'UniListAd',
  19. props: {
  20. title: {
  21. type: String,
  22. default: '',
  23. }
  24. },
  25. inject: ['list'],
  26. data() {
  27. return {
  28. isFirstChild: false,
  29. border: false,
  30. borderShow: true,
  31. }
  32. },
  33. mounted() {
  34. if (!this.list.firstChildAppend) {
  35. this.list.firstChildAppend = true
  36. this.isFirstChild = true
  37. }
  38. this.border = this.list.border
  39. },
  40. methods: {
  41. aderror(e) {
  42. console.log("aderror: " + JSON.stringify(e.detail));
  43. },
  44. closeAd(e) {
  45. this.borderShow = false
  46. }
  47. }
  48. }
  49. </script>
  50. <style scoped>
  51. .uni-list-ad {
  52. position: relative;
  53. border: 1px red solid;
  54. }
  55. .uni-list--border {
  56. position: relative;
  57. padding-bottom: 1px;
  58. /* #ifdef APP-PLUS */
  59. border-top-color: #e5e5e5;
  60. border-top-style: solid;
  61. border-top-width: 0.5px;
  62. /* #endif */
  63. margin-left: 15px;
  64. }
  65. /* #ifndef APP-NVUE */
  66. .uni-list--border:after {
  67. position: absolute;
  68. top: 0;
  69. right: 0;
  70. left: 0;
  71. height: 1px;
  72. content: '';
  73. -webkit-transform: scaleY(0.5);
  74. transform: scaleY(0.5);
  75. background-color: #e5e5e5;
  76. }
  77. .uni-list-item--first:after {
  78. height: 0px;
  79. }
  80. /* #endif */
  81. </style>