qiansailong 1 год назад
Родитель
Сommit
0c4090a2aa

+ 4 - 7
app.js

@@ -101,11 +101,9 @@ async function onNovelPluginLoad(data) {
   const novelManager = novelPlugin.getNovelManager(data.id)
   getApp().globalData.novelManager = novelManager
 
-  if (getApp().globalData.isShowDialog) {
-    novelManager.setFullScreenComponentStatus({
-      show: true,
-    })
-  }
+  novelManager.setFullScreenComponentStatus({
+    show: true,
+  })
 
   let pluginInfo = novelManager.getPluginInfo();
   let innerBookId = pluginInfo.query?.innerBookId;
@@ -140,14 +138,13 @@ async function onNovelPluginLoad(data) {
     
     let chapterConfigs = []
     for (let index = 0; index < bookDetail.latestChapterNo; index++) {
-      console.log(index + 1)
       if ((index + 1) % getApp().globalData.bookmarkAdNum === 0) {
         chapterConfigs.push({
           chapterIndex: index,
           blocks: [
             {
               type: 3,
-              unitId: 'adunit-343af082b8c8ea18'
+              unitId: apple.ads.bookmarkAdId
             }
           ]
         })

+ 16 - 6
components/charge-dialog/charge-dialog.js

@@ -2,6 +2,10 @@ import {
   unlockChapter
 } from '../../api/api.js'
 
+import {
+  apple
+} from '../../config/config'
+
 const novelPlugin = requirePlugin('novel-plugin')
 Component({
   properties: {
@@ -32,27 +36,30 @@ Component({
     isCounting: false
   },
 
-  ready() {
+  created() {
     this.rewardVideoLoad()
+  },
+
+  ready() {
     setTimeout(() => {
       this.startCountdown()
     }, 500)
   },
 
-  onUnload() {
+  detached() {
     this.stopCountdown(); // 页面卸载时清除定时器
   },
 
   methods: {
     unlock() {
+      this.stopCountdown();
       this.rewardVideoPlayFn()
     },
 
     // 激励视频加载
     rewardVideoLoad() {
       if (wx.createRewardedVideoAd) {
-        // let adId = apple.ads.rewardAdId
-        let adId = 'adunit-7df7b95b78f624f8'
+        let adId = apple.ads.rewardAdId
         this.videoAd = wx.createRewardedVideoAd({
           adUnitId: adId
         })
@@ -65,7 +72,9 @@ Component({
         this.videoAd.onClose((res) => {
           const novelManager = novelPlugin.getNovelManager(this.properties.novelManagerId)
           if (res && res.isEnded) {
-            novelManager.paymentCompleted()
+            // for (let index = 0; index < getApp().globalData.unlockChapterNum; index++) {
+
+            // }
             let params = {
               chapterNo: this.properties.chapterIndex,
               novelId: getApp().globalData.novelId,
@@ -73,8 +82,9 @@ Component({
             }
             unlockChapter(params).then(res => {
               console.log(res)
+              novelManager.paymentCompleted()
+              console.log('章节解锁成功')
             })
-            console.log('解锁章节')
           } else {
             novelManager.closeChargeDialog()
             console.log('关闭解锁组件')

+ 5 - 2
components/full-screen/full-screen.js

@@ -1,3 +1,7 @@
+import {
+  apple
+} from '../../config/config'
+
 const novelPlugin = requirePlugin('novel-plugin')
 let interstitialAd = null
 
@@ -39,8 +43,7 @@ Component({
   methods: {
     // 插屏广告加载
     interstitalLoad() {
-      const _this = this
-      let adId = 'adunit-37ee342a8fc046b7'
+      let adId = apple.ads.insertAdId
       interstitialAd = wx.createInterstitialAd({
         adUnitId: adId
       })

+ 5 - 0
config/config.js

@@ -3,6 +3,11 @@ const appInfoObj = {
         appid: 'wxa7a33088566e1292',
         ghid: 'gh_4e55f615d5dc',
         appName: '试读空间',
+        ads: {
+          insertAdId: 'adunit-37ee342a8fc046b7',
+          rewardAdId: 'adunit-7df7b95b78f624f8',
+          bookmarkAdId: 'adunit-343af082b8c8ea18'
+      },
     },
   };
   

+ 7 - 6
pages/bookshelf/bookshelf.js

@@ -5,6 +5,9 @@ import {
 import {
   goToBookDetail
 } from '../../utils/util'
+import {
+  apple
+} from '../../config/config'
 
 let interstitialAd = null
 
@@ -30,20 +33,18 @@ Page({
       bookList: []
     })
     this.loadBookList()
-
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
   },
 
   onTabItemTap(item) {
     console.log(item.index)
+    setTimeout(() => {
+      this.interstitalPlayFn()
+    }, 1000)
   },
 
   // 插屏广告加载
   interstitalLoad() {
-    const _this = this
-    let adId = 'adunit-37ee342a8fc046b7'
+    let adId = apple.ads.insertAdId
     interstitialAd = wx.createInterstitialAd({
       adUnitId: adId
     })

+ 7 - 7
pages/category/category.js

@@ -5,6 +5,9 @@ import {
 import {
   goToBookDetail
 } from '../../utils/util'
+import {
+  apple
+} from '../../config/config'
 
 let interstitialAd = null
 
@@ -30,23 +33,20 @@ Page({
   onShow: function () {
     // 每次页面显示时同步性别状态
     this.syncGenderState();
-
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
   },
 
   onTabItemTap: function (item) {
     console.log(item.index)
-
+    setTimeout(() => {
+      this.interstitalPlayFn()
+    }, 1000)
     // tabBar 点击时同步性别状态
     this.syncGenderState();
   },
 
   // 插屏广告加载
   interstitalLoad() {
-    const _this = this
-    let adId = 'adunit-37ee342a8fc046b7'
+    let adId = apple.ads.insertAdId
     interstitialAd = wx.createInterstitialAd({
       adUnitId: adId
     })

+ 2 - 1
pages/index/index.js

@@ -10,6 +10,7 @@ import {
 import {
   goToBookDetail
 } from '../../utils/util'
+import { apple } from '../../config/config'
 
 const app = getApp()
 let interstitialAd = null
@@ -110,7 +111,7 @@ Page({
 
   // 插屏广告加载
   interstitalLoad() {
-    let adId = 'adunit-37ee342a8fc046b7'
+    let adId = apple.ads.insertAdId
     interstitialAd = wx.createInterstitialAd({
       adUnitId: adId
     })

+ 8 - 5
pages/mine/mine.js

@@ -1,4 +1,8 @@
 // pages/mine/mine.js
+import {
+  apple
+} from '../../config/config'
+
 let interstitialAd = null
 
 Page({
@@ -11,19 +15,18 @@ Page({
   },
 
   onShow() {
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
   },
 
   onTabItemTap(item) {
+    setTimeout(() => {
+      this.interstitalPlayFn()
+    }, 1000)
     console.log(item.index)
   },
 
   // 插屏广告加载
   interstitalLoad() {
-    const _this = this
-    let adId = 'adunit-37ee342a8fc046b7'
+    let adId = apple.ads.insertAdId
     interstitialAd = wx.createInterstitialAd({
       adUnitId: adId
     })

+ 7 - 5
pages/video/video.js

@@ -9,6 +9,9 @@ import {
   deepCopy,
   goToBookDetail
 } from '../../utils/util'
+import {
+  apple
+} from '../../config/config'
 
 const app = getApp()
 let interstitialAd = null
@@ -63,9 +66,6 @@ Page({
 
   onShow() {
     console.log('页面显示--------------------------')
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
 
     // 每次显示页面时刷新列表
     if (this.data.videoList.length === 0) {
@@ -110,12 +110,14 @@ Page({
 
   onTabItemTap(item) {
     console.log(item.index)
+    setTimeout(() => {
+      this.interstitalPlayFn()
+    }, 1000)
   },
 
   // 插屏广告加载
   interstitalLoad() {
-    const _this = this
-    let adId = 'adunit-37ee342a8fc046b7'
+    let adId = apple.ads.insertAdId
     interstitialAd = wx.createInterstitialAd({
       adUnitId: adId
     })

+ 1 - 1
utils/util.js

@@ -33,7 +33,7 @@ export const goToBookDetail = (options) => {
   // 根据不同参数构建不同的URL
   if (options.wxBookId) {
     // 微信书籍ID跳转
-    url = `plugin-private://wx293c4b6097a8a4d0/pages/novel/index?bookId=${options.wxBookId}`;
+    url = `plugin-private://wx293c4b6097a8a4d0/pages/novel/index?share=1&bookId=${options.wxBookId}`;
     
     // 如果有章节ID,添加到URL
     if (options.chapterId) {