Blame view

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