Kaynağa Gözat

广告

master
fzzj 10 ay önce
ebeveyn
işleme
e7eb22b283

+ 19
- 0
RuoYi-App/components/ad-platform.vue Dosyayı Görüntüle

@@ -0,0 +1,19 @@
1
+<!-- 组件:/components/ad-platform.vue -->
2
+<template>
3
+  <!-- 微信小程序广告 -->
4
+  <ad v-if="platform==='wechat' && !isVIP" ad-type="video" unit-id="..."></ad>
5
+  
6
+  <!-- 抖音小程序广告 -->
7
+  <ad-douyin v-else-if="platform==='douyin' && !isVIP" :unit-id="..."></ad-douyin>
8
+  
9
+  <!-- H5广告 -->
10
+  <div v-else-if="platform==='h5' && !isVIP">
11
+    <iframe :src="dcloudAdUrl"></iframe>
12
+  </div>
13
+</template>
14
+
15
+<script>
16
+</script>
17
+
18
+<style>
19
+</style>

+ 64
- 0
RuoYi-App/pages/reader/AdTrigger.vue Dosyayı Görüntüle

@@ -0,0 +1,64 @@
1
+<template>
2
+  <!-- 底部信息流广告 -->
3
+  <ad v-if="showBottomAd" :unit-id="adConfig.adUnitId" ad-type="feed"></ad>
4
+  
5
+  <!-- 激励视频弹窗 -->
6
+  <view v-if="showRewardAd">
7
+    <video-ad :unit-id="adConfig.adUnitId" @close="onAdClose"></video-ad>
8
+  </view>
9
+</template>
10
+
11
+<script>
12
+export default {
13
+  props: {
14
+    chapterId: Number,
15
+    isVip: Boolean
16
+  },
17
+  data() {
18
+    return {
19
+      adConfig: {},
20
+      showBottomAd: false,
21
+      showRewardAd: false,
22
+      chapterCount: 0
23
+    }
24
+  },
25
+  watch: {
26
+    chapterId() {
27
+      this.loadAdConfig();
28
+      this.chapterCount++;
29
+      
30
+      // 每5章触发激励广告
31
+      if (!this.isVip && this.chapterCount % 5 === 0) {
32
+        this.triggerRewardAd();
33
+      }
34
+    }
35
+  },
36
+  methods: {
37
+    async loadAdConfig() {
38
+      // 获取广告配置
39
+      const res = await this.$http.get(`/ad/config/${this.chapterId}`);
40
+      this.adConfig = res.data;
41
+      
42
+      // 展示底部广告(非VIP)
43
+      this.showBottomAd = !this.isVip && this.adConfig.bottomAdEnabled;
44
+    },
45
+    
46
+    triggerRewardAd() {
47
+      if (!this.isVip && this.adConfig.rewardAdEnabled) {
48
+        this.showRewardAd = true;
49
+        
50
+        // 发送广告计数
51
+        this.$http.post('/ad/count', {
52
+          userId: this.$store.state.user.id,
53
+          chapterId: this.chapterId,
54
+          platform: this.$platform
55
+        });
56
+      }
57
+    },
58
+    
59
+    onAdClose() {
60
+      this.showRewardAd = false;
61
+    }
62
+  }
63
+}
64
+</script>

+ 40
- 0
RuoYi-App/pages/reader/reader.vue Dosyayı Görüntüle

@@ -0,0 +1,40 @@
1
+<template>
2
+</template>
3
+
4
+<script>
5
+// 文件:/pages/reader/reader.vue
6
+export default {
7
+  data() {
8
+    return {
9
+      isVIP: false,
10
+      chapterCount: 0
11
+    }
12
+  },
13
+  methods: {
14
+    // 翻页触发广告
15
+    onPageTurn() {
16
+      this.chapterCount++;
17
+      if (!this.isVIP && this.chapterCount % 5 === 0) {
18
+        this.showRewardAd(); // 每5章触发激励视频
19
+      }
20
+    },
21
+    // 平台广告过滤
22
+    showRewardAd() {
23
+      // #ifdef MP-WEIXIN
24
+      wx.createRewardedVideoAd({ adUnitId: '微信广告ID' }).show()
25
+      // #endif
26
+      
27
+      // #ifdef MP-DOUYIN
28
+      tt.showRewardedVideoAd({ adUnitId: '抖音广告ID' })
29
+      // #endif
30
+      
31
+      // #ifdef H5
32
+      this.$refs.h5Ad.show() // H5专用广告组件
33
+      // #endif
34
+    }
35
+  }
36
+}
37
+</script>
38
+
39
+<style>
40
+</style>

Loading…
İptal
Kaydet