full-screen.js 1.4 KB

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