ad.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view>
  3. <page-head :title="title"></page-head>
  4. <view class="ad-view">
  5. <!-- TODO 请更换为自己的广告位ID -->
  6. <ad adpid="1111111111" :unit-id="unitId" type="feed" @load="adload" @error="aderror"></ad>
  7. <!-- #ifdef APP-PLUS -->
  8. <view class="ad-tips" v-if="!isLoad">
  9. <text>{{adMessage}}</text>
  10. </view>
  11. <!-- #endif -->
  12. <!-- #ifndef APP-PLUS -->
  13. <view class="ad-tips">
  14. <text>小程序端的广告ID由小程序平台提供</text>
  15. </view>
  16. <!-- #endif -->
  17. </view>
  18. <view class="tips">
  19. <text class="tips-text">本示例页面仅演示ad组件。另点此可体验</text><text class="tips-hl" @click="gotoapi">激励视频API</text><text class="tips-text">。</text>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. title: 'AD组件',
  28. unitId: '',
  29. isLoad: false,
  30. adMessage: "广告加载中..."
  31. }
  32. },
  33. onLoad() {
  34. // #ifdef MP-WEIXIN
  35. this.unitId = '';
  36. // #endif
  37. // #ifdef MP-TOUTIAO
  38. this.unitId = ''
  39. // #endif
  40. // #ifdef MP-QQ
  41. this.unitId = ''
  42. // #endif
  43. },
  44. methods: {
  45. adload() {
  46. this.isLoad = true;
  47. },
  48. aderror(e) {
  49. this.adMessage = e.detail.errMsg;
  50. },
  51. gotoapi() {
  52. uni.navigateTo({
  53. url: "/pages/API/rewarded-video-ad/rewarded-video-ad"
  54. })
  55. }
  56. }
  57. }
  58. </script>
  59. <style>
  60. .content {
  61. background-color: #DBDBDB;
  62. padding: 10px;
  63. }
  64. .ad-view {
  65. background-color: #FFFFFF;
  66. margin-bottom: 10px;
  67. }
  68. .ad-tips {
  69. color: #999;
  70. padding: 30px 0;
  71. text-align: center;
  72. }
  73. .tips {
  74. margin-top: 30px;
  75. text-align: center;
  76. line-height: 42px;
  77. }
  78. .tips-text {
  79. color: #444;
  80. }
  81. .tips-hl {
  82. color: #007AFF;
  83. margin-left: 1px;
  84. }
  85. </style>