├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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