ad.vue 2.2 KB

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