├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

AdSystem.vue 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <script>
  2. export default {
  3. data() {
  4. return {
  5. // 多平台广告配置
  6. adConfig: {
  7. h5: {
  8. adpid: 'AYDZ_H5_MAIN',
  9. widescreen: 'AYDZ_H5_WIDE'
  10. },
  11. wechat: {
  12. unitId: 'WECHAT_AD_UNIT_ID'
  13. },
  14. douyin: {
  15. codeId: 'DOUYIN_AD_CODE_ID'
  16. }
  17. }
  18. }
  19. },
  20. computed: {
  21. currentAdConfig() {
  22. // #ifdef H5
  23. return this.adConfig.h5
  24. // #endif
  25. // #ifdef MP-WEIXIN
  26. return this.adConfig.wechat
  27. // #endif
  28. // #ifdef MP-TOUTIAO
  29. return this.adConfig.douyin
  30. // #endif
  31. return {}
  32. }
  33. },
  34. methods: {
  35. showAd(adType) {
  36. // #ifdef H5
  37. if(adType === 'feed') {
  38. this.showH5FeedAd()
  39. } else {
  40. this.showH5RewardAd()
  41. }
  42. // #endif
  43. // #ifdef MP-WEIXIN
  44. if(adType === 'feed') {
  45. this.showWechatBannerAd()
  46. } else {
  47. this.showWechatRewardAd()
  48. }
  49. // #endif
  50. // #ifdef MP-TOUTIAO
  51. if(adType === 'feed') {
  52. this.showDouyinBannerAd()
  53. } else {
  54. this.showDouyinRewardAd()
  55. }
  56. // #endif
  57. },
  58. showH5FeedAd() {
  59. // 获取DCloud广告实例
  60. const ad = plus.ad.createAd({
  61. adpid: this.currentAdConfig.adpid,
  62. adType: 'feed'
  63. })
  64. ad.show()
  65. // 广告事件监听
  66. ad.onLoad(() => console.log('H5广告加载成功'))
  67. ad.onClose(res => {
  68. if(res && res.isEnded) {
  69. this.$emit('ad-completed')
  70. }
  71. })
  72. }
  73. }
  74. }
  75. </script>
  76. <template>
  77. <!-- H5广告组件 -->
  78. <view v-if="platform === 'h5'">
  79. <ad
  80. v-if="showAd"
  81. :adpid="currentAdConfig.adpid"
  82. :adpid-widescreen="currentAdConfig.widescreen"
  83. @close="onAdClose"
  84. ></ad>
  85. </view>
  86. </template>
  87. <style>
  88. </style>