full-screen.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import {
  2. apple
  3. } from '../../config/config'
  4. const novelPlugin = requirePlugin('novel-plugin')
  5. let interstitialAd = null
  6. Component({
  7. properties: {
  8. novelManagerId: {
  9. type: Number,
  10. value: -1,
  11. },
  12. chapterId: {
  13. type: String,
  14. value: '',
  15. }
  16. },
  17. data: {
  18. posterUrl: {
  19. type: String,
  20. value: ''
  21. }
  22. },
  23. ready() {
  24. const novelManager = novelPlugin.getNovelManager(this.properties.novelManagerId)
  25. this.interstitalLoad()
  26. setTimeout(() => {
  27. this.interstitalPlayFn()
  28. }, 500)
  29. if (getApp().globalData.isShowDialog) {
  30. setTimeout(() => {
  31. getApp().globalData.isShowDialog = false
  32. novelManager.navigateBack()
  33. }, 4000)
  34. }
  35. },
  36. methods: {
  37. // 插屏广告加载
  38. interstitalLoad() {
  39. let adId = apple.ads.insertAdId
  40. interstitialAd = wx.createInterstitialAd({
  41. adUnitId: adId
  42. })
  43. interstitialAd.onLoad(() => {
  44. console.log('视频页插屏广告onLoad')
  45. })
  46. interstitialAd.onError((err) => {
  47. console.log('视频页插屏广告onError', err)
  48. })
  49. interstitialAd.onClose(() => {
  50. console.log('视频页插屏广告onClose')
  51. })
  52. },
  53. // 插屏广告展示
  54. interstitalPlayFn() {
  55. if (interstitialAd) {
  56. interstitialAd.show().catch((err) => {
  57. console.error(err)
  58. })
  59. }
  60. },
  61. },
  62. })