Ver código fonte

原生广告ID

hank 1 ano atrás
pai
commit
76f393af43
4 arquivos alterados com 462 adições e 457 exclusões
  1. 1 1
      components/charge-dialog/charge-dialog.js
  2. 15 14
      config/config.js
  3. 443 439
      pages/video/video.js
  4. 3 3
      pages/video/video.wxml

+ 1 - 1
components/charge-dialog/charge-dialog.js

@@ -83,7 +83,7 @@ Component({
             unlockChapter(params).then(res => {
               console.log(res)
               novelManager.paymentCompleted()
-              console.log('章节解锁成功')
+              console.log('章节解锁成功',this.properties.chapterIndex)
             })
           } else {
             novelManager.closeChargeDialog()

+ 15 - 14
config/config.js

@@ -4,24 +4,25 @@ const appInfoObj = {
         ghid: 'gh_4e55f615d5dc',
         appName: '试读空间',
         ads: {
-          insertAdId: 'adunit-37ee342a8fc046b7',
-          rewardAdId: 'adunit-7df7b95b78f624f8',
-          bookmarkAdId: 'adunit-343af082b8c8ea18'
-      },
+            insertAdId: 'adunit-37ee342a8fc046b7',
+            rewardAdId: 'adunit-7df7b95b78f624f8',
+            bookmarkAdId: 'adunit-343af082b8c8ea18',
+            templateAdId: 'adunit-80f6ec7a264f968b'
+        },
     },
-  };
-  
-  // @config 确定使用的小程序appid
-  const appid = 'wxa7a33088566e1292';
-  export const apple = {
+};
+
+// @config 确定使用的小程序appid
+const appid = 'wxa7a33088566e1292';
+export const apple = {
     ...appInfoObj[appid],
     appKey: '8ZCND8Zkjs6JEPpzTUJd2sOg1',
-  };
-  
-  // 线上域名信息
-  export const https = {
+};
+
+// 线上域名信息
+export const https = {
     dev_apiHttps: 'https://hyperion-novel-qa-app.mokamrp.com',
     test_apiHttps: 'https://hyperion-novel-qa-app.mokamrp.com',
     apiHttps: 'https://hyperion-novel-qa-app.mokamrp.com'
-  };
+};
   

+ 443 - 439
pages/video/video.js

@@ -1,16 +1,16 @@
 // pages/video/video.js
 import {
-  getVideoList,
-  getTemplateConfig,
-  getUuid
+    getVideoList,
+    getTemplateConfig,
+    getUuid
 } from '../../api/api'
 import {
-  rnd,
-  deepCopy,
-  goToBookDetail
+    rnd,
+    deepCopy,
+    goToBookDetail
 } from '../../utils/util'
 import {
-  apple
+    apple
 } from '../../config/config'
 
 const app = getApp()
@@ -37,464 +37,468 @@ Page({
         // 当前选中的分类ID
         currentCategoryId: null,
 
-        share_count: 1
+        share_count: 1,
+        templateAdId: '',
     },
 
-  async onLoad() {
-    console.log('打开视频页面--------------------------')
-    if (!getApp().globalData.uuid) {
-      await this.getUUID().then(uuid => {
-        getApp().globalData.uuid = uuid
-      })
-    }
-
-    this.interstitalLoad()
-    getTemplateConfig({
-      box_type: 67,
-      uuid: getApp().globalData.uuid
-    }).then(res => {
-      this.setData({
-        globalConfig: res.globalConfig
-      })
-      // 获取视频分类
-      this.getVideoCategories()
-    })
-
-    // 获取状态栏高度
-    this.getSystemInfo()
-  },
-
-  onShow() {
-    console.log('页面显示--------------------------')
-
-    // 每次显示页面时刷新列表
-    if (this.data.videoList.length === 0) {
-      this.setData({
-        page: 1
-      })
-      // this.loadVideoList()
-    }
-
-    // 获取当前页面的参数
-    const pages = getCurrentPages();
-    const currentPage = pages[pages.length - 1];
-    const options = currentPage.options;
+    async onLoad() {
+        console.log('打开视频页面--------------------------')
+        if (!getApp().globalData.uuid) {
+            await this.getUUID().then(uuid => {
+                getApp().globalData.uuid = uuid
+            })
+        }
 
-    // 处理分享进入的情况
-    if (options.shared_video_id) {
-      if (+options.share_count === 1 && this.data.share_count === 1) {
-        this.setData({
-          share_count: 2
+        this.interstitalLoad()
+        getTemplateConfig({
+            box_type: 67,
+            uuid: getApp().globalData.uuid
+        }).then(res => {
+            this.setData({
+                globalConfig: res.globalConfig
+            })
+            // 获取视频分类
+            this.getVideoCategories()
         })
-        this.goToBookDetail()
-      } else if (+options.share_count === 1 && this.data.share_count === 2) {
+
+        // 获取状态栏高度
+        this.getSystemInfo()
         this.setData({
-          share_count: 3
+            templateAdId: apple.ads.templateAdId
         })
-        // 延迟跳转,确保列表页已经加载完成
-        setTimeout(() => {
-          wx.navigateTo({
-            url: `/pages/video/detail?id=${options.shared_video_id}&title=${options.title || ''}&tag_id=${options.tag_id || ''}`,
-            fail: (err) => {
-              console.error('跳转到视频详情页失败:', err);
-              wx.showToast({
-                title: '打开视频失败',
-                icon: 'none'
-              });
+    },
+
+    onShow() {
+        console.log('页面显示--------------------------')
+
+        // 每次显示页面时刷新列表
+        if (this.data.videoList.length === 0) {
+            this.setData({
+                page: 1
+            })
+            // this.loadVideoList()
+        }
+
+        // 获取当前页面的参数
+        const pages = getCurrentPages();
+        const currentPage = pages[pages.length - 1];
+        const options = currentPage.options;
+
+        // 处理分享进入的情况
+        if (options.shared_video_id) {
+            if (+options.share_count === 1 && this.data.share_count === 1) {
+                this.setData({
+                    share_count: 2
+                })
+                this.goToBookDetail()
+            } else if (+options.share_count === 1 && this.data.share_count === 2) {
+                this.setData({
+                    share_count: 3
+                })
+                // 延迟跳转,确保列表页已经加载完成
+                setTimeout(() => {
+                    wx.navigateTo({
+                        url: `/pages/video/detail?id=${options.shared_video_id}&title=${options.title || ''}&tag_id=${options.tag_id || ''}`,
+                        fail: (err) => {
+                            console.error('跳转到视频详情页失败:', err);
+                            wx.showToast({
+                                title: '打开视频失败',
+                                icon: 'none'
+                            });
+                        }
+                    });
+                }, 500);
             }
-          });
-        }, 500);
-      }
-    }
-  },
-
-  onTabItemTap(item) {
-    console.log(item.index)
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
-  },
-
-  // 插屏广告加载
-  interstitalLoad() {
-    let adId = apple.ads.insertAdId
-    interstitialAd = wx.createInterstitialAd({
-      adUnitId: adId
-    })
-    interstitialAd.onLoad(() => {
-      console.log('视频页插屏广告onLoad')
-    })
-    interstitialAd.onError((err) => {
-      console.log('视频页插屏广告onError', err)
-    })
-    interstitialAd.onClose(() => {
-      console.log('视频页插屏广告onClose')
-    })
-  },
-
-  // 插屏广告展示
-  interstitalPlayFn() {
-    if (interstitialAd) {
-      interstitialAd.show().catch((err) => {
-        console.error(err)
-      })
-    }
-  },
-
-  /**
-   * 获取uuid
-   */
-  getUUID() {
-    return new Promise((resolve, reject) => {
-      wx.login({
-        success: res => {
-          let body = {
-            code: res.code,
-            source_type: 1,
-            source_id: ''
-          }
-          getUuid(body).then(async res => {
-
-            resolve(res.uuid)
-          }).catch((err) => {
-            reject(err)
-          })
         }
-      })
-    })
-  },
-
-  // 获取系统信息
-  getSystemInfo() {
-    const systemInfo = wx.getSystemInfoSync()
-    const statusBarHeight = systemInfo.statusBarHeight
-    const navHeight = statusBarHeight + 44
-
-    this.setData({
-      statusBarHeight: statusBarHeight,
-      navHeight: navHeight,
-      navStyle: `height:${navHeight}px`,
-      listStyle: `top:${navHeight}px`
-    })
-  },
-
-  // 获取视频分类
-  getVideoCategories() {
-    console.log('getVideoCategories', this.data.globalConfig)
-    // 筛选出type=1的视频分类
-    const videoCategories = this.data.globalConfig.categoryList.filter(item => item.type === 1)
-
-    console.log('videoCategories', videoCategories)
-
-    if (videoCategories.length > 0) {
-      // 设置分类列表和默认选中的分类
-      this.setData({
-        categoryList: videoCategories,
-        currentCategoryId: videoCategories[0].id
-      })
-      // 加载第一个分类的视频列表
-      this.loadVideoList()
-    } else {
-      console.error('未找到视频分类')
-      wx.showToast({
-        title: '未找到视频分类',
-        icon: 'none'
-      })
-    }
-  },
-
-  // 切换分类
-  switchCategory(e) {
-    const categoryId = e.currentTarget.dataset.id
-    if (categoryId === this.data.currentCategoryId) return
-
-    this.setData({
-      currentCategoryId: categoryId,
-      page: 1,
-      videoList: [],
-      hasMore: true
-    })
-    this.loadVideoList()
-  },
-
-  // 加载视频列表
-  async loadVideoList() {
-    if (this.data.loading) return
-
-    this.setData({
-      loading: true
-    })
-
-    try {
-      const params = {
-        page: this.data.page,
-        size: this.data.size,
-        tag_id: this.data.currentCategoryId,
-        // 如果不是第一页,传递最后一个视频的ID作为next_id
-        next_id: this.data.page > 1 && this.data.videoList.length > 0 ?
-          this.data.videoList[this.data.videoList.length - 1].id :
-          ""
-      }
-
-      let videoList = []
-      try {
-        videoList = await getVideoList(params)
-
-        if (!Array.isArray(videoList)) {
-          throw new Error('返回数据格式错误')
+    },
+
+    onTabItemTap(item) {
+        console.log(item.index)
+        setTimeout(() => {
+            this.interstitalPlayFn()
+        }, 1000)
+    },
+
+    // 插屏广告加载
+    interstitalLoad() {
+        let adId = apple.ads.insertAdId
+        interstitialAd = wx.createInterstitialAd({
+            adUnitId: adId
+        })
+        interstitialAd.onLoad(() => {
+            console.log('视频页插屏广告onLoad')
+        })
+        interstitialAd.onError((err) => {
+            console.log('视频页插屏广告onError', err)
+        })
+        interstitialAd.onClose(() => {
+            console.log('视频页插屏广告onClose')
+        })
+    },
+
+    // 插屏广告展示
+    interstitalPlayFn() {
+        if (interstitialAd) {
+            interstitialAd.show().catch((err) => {
+                console.error(err)
+            })
         }
+    },
 
-        videoList = videoList.map(item => ({
-          ...item,
-          views: rnd(1, 10),
-          favors: rnd(5000, 10000),
-          adType: "video"
-        }))
+    /**
+     * 获取uuid
+     */
+    getUUID() {
+        return new Promise((resolve, reject) => {
+            wx.login({
+                success: res => {
+                    let body = {
+                        code: res.code,
+                        source_type: 1,
+                        source_id: ''
+                    }
+                    getUuid(body).then(async res => {
+
+                        resolve(res.uuid)
+                    }).catch((err) => {
+                        reject(err)
+                    })
+                }
+            })
+        })
+    },
 
-        videoList = this.formatVideoAdList(videoList);
+    // 获取系统信息
+    getSystemInfo() {
+        const systemInfo = wx.getSystemInfoSync()
+        const statusBarHeight = systemInfo.statusBarHeight
+        const navHeight = statusBarHeight + 44
 
-        console.log("format videoList", videoList)
+        this.setData({
+            statusBarHeight: statusBarHeight,
+            navHeight: navHeight,
+            navStyle: `height:${navHeight}px`,
+            listStyle: `top:${navHeight}px`
+        })
+    },
 
-      } catch (apiError) {
-        console.error('API调用失败:', apiError)
-        throw apiError
-      }
+    // 获取视频分类
+    getVideoCategories() {
+        console.log('getVideoCategories', this.data.globalConfig)
+        // 筛选出type=1的视频分类
+        const videoCategories = this.data.globalConfig.categoryList.filter(item => item.type === 1)
+
+        console.log('videoCategories', videoCategories)
+
+        if (videoCategories.length > 0) {
+            // 设置分类列表和默认选中的分类
+            this.setData({
+                categoryList: videoCategories,
+                currentCategoryId: videoCategories[0].id
+            })
+            // 加载第一个分类的视频列表
+            this.loadVideoList()
+        } else {
+            console.error('未找到视频分类')
+            wx.showToast({
+                title: '未找到视频分类',
+                icon: 'none'
+            })
+        }
+    },
+
+    // 切换分类
+    switchCategory(e) {
+        const categoryId = e.currentTarget.dataset.id
+        if (categoryId === this.data.currentCategoryId) return
 
-      // 如果是第一页,直接替换数据
-      if (this.data.page === 1) {
         this.setData({
-          videoList: videoList,
-          loading: false,
-          hasMore: videoList.length >= this.data.size
+            currentCategoryId: categoryId,
+            page: 1,
+            videoList: [],
+            hasMore: true
         })
-      } else {
-        // 否则追加数据
+        this.loadVideoList()
+    },
+
+    // 加载视频列表
+    async loadVideoList() {
+        if (this.data.loading) return
+
         this.setData({
-          videoList: [...this.data.videoList, ...videoList],
-          loading: false,
-          hasMore: videoList.length >= this.data.size
+            loading: true
         })
-      }
-    } catch (error) {
-      console.error('加载视频列表失败:', error)
-    }
-  },
-  /* ------------------ 广告相关 ----------------- */
-  /**
-   * 标记广告位置
-   * @param {} arr
-   * @returns
-   */
-  formatVideoAdList(arr) {
-    // 原生广告间隔,激励广告间隔
-    let templateGap = 0,
-      rewardGap = 0
-
-    // 第二个固定是原生广告
-    let result = [arr.shift(), {
-      adType: 'templateAd'
-    }]
-    // 辅助计算间隔变量
-    let markIndex = 0
-    let templateAdFlag = true
-    let rewardAdFlag = true
-
-    do {
-      markIndex += 1
-      if (templateGap > 0) {
-        if (templateAdFlag && markIndex - 1 === templateGap) {
-          markIndex = 0
-          result.push({
-            adType: "templateAd"
-          })
-          templateAdFlag = false
-          rewardAdFlag = true
-          continue
+
+        try {
+            const params = {
+                page: this.data.page,
+                size: this.data.size,
+                tag_id: this.data.currentCategoryId,
+                // 如果不是第一页,传递最后一个视频的ID作为next_id
+                next_id: this.data.page > 1 && this.data.videoList.length > 0 ?
+                    this.data.videoList[this.data.videoList.length - 1].id :
+                    ""
+            }
+
+            let videoList = []
+            try {
+                videoList = await getVideoList(params)
+
+                if (!Array.isArray(videoList)) {
+                    throw new Error('返回数据格式错误')
+                }
+
+                videoList = videoList.map(item => ({
+                    ...item,
+                    views: rnd(1, 10),
+                    favors: rnd(5000, 10000),
+                    adType: "video"
+                }))
+
+                videoList = this.formatVideoAdList(videoList);
+
+                console.log("format videoList", videoList)
+
+            } catch (apiError) {
+                console.error('API调用失败:', apiError)
+                throw apiError
+            }
+
+            // 如果是第一页,直接替换数据
+            if (this.data.page === 1) {
+                this.setData({
+                    videoList: videoList,
+                    loading: false,
+                    hasMore: videoList.length >= this.data.size
+                })
+            } else {
+                // 否则追加数据
+                this.setData({
+                    videoList: [...this.data.videoList, ...videoList],
+                    loading: false,
+                    hasMore: videoList.length >= this.data.size
+                })
+            }
+        } catch (error) {
+            console.error('加载视频列表失败:', error)
         }
-      } else {
-        rewardAdFlag = true
-      }
-      if (rewardGap > 0) {
-        if (rewardAdFlag && markIndex - 1 === rewardGap) {
-          markIndex = 0
-          templateAdFlag = true
-          rewardAdFlag = false
-          let rewardItem = arr.shift()
-          rewardItem.lock = true
-          result.push(rewardItem)
-          continue
+    },
+    /* ------------------ 广告相关 ----------------- */
+    /**
+     * 标记广告位置
+     * @param {} arr
+     * @returns
+     */
+    formatVideoAdList(arr) {
+        // 原生广告间隔,激励广告间隔
+        let templateGap = 0,
+            rewardGap = 0
+
+        // 第二个固定是原生广告
+        let result = [arr.shift(), {
+            adType: 'templateAd'
+        }]
+        // 辅助计算间隔变量
+        let markIndex = 0
+        let templateAdFlag = true
+        let rewardAdFlag = true
+
+        do {
+            markIndex += 1
+            if (templateGap > 0) {
+                if (templateAdFlag && markIndex - 1 === templateGap) {
+                    markIndex = 0
+                    result.push({
+                        adType: "templateAd"
+                    })
+                    templateAdFlag = false
+                    rewardAdFlag = true
+                    continue
+                }
+            } else {
+                rewardAdFlag = true
+            }
+            if (rewardGap > 0) {
+                if (rewardAdFlag && markIndex - 1 === rewardGap) {
+                    markIndex = 0
+                    templateAdFlag = true
+                    rewardAdFlag = false
+                    let rewardItem = arr.shift()
+                    rewardItem.lock = true
+                    result.push(rewardItem)
+                    continue
+                }
+            } else {
+                templateAdFlag = true
+            }
+
+            result.push(arr.shift())
+        } while (arr.length > 0);
+
+        return result;
+    },
+    // 加载更多
+    loadMore() {
+        console.log("触发loadMore")
+        console.log("当前状态:", {
+            loading: this.data.loading,
+            hasMore: this.data.hasMore,
+            page: this.data.page,
+            videoListLength: this.data.videoList.length
+        })
+
+        // 添加防抖,避免频繁触发
+        const now = Date.now()
+        if (now - this.data.lastLoadTime < 500) {
+            console.log("防抖触发,跳过本次加载")
+            return
         }
-      } else {
-        templateAdFlag = true
-      }
-
-      result.push(arr.shift())
-    } while (arr.length > 0);
-
-    return result;
-  },
-  // 加载更多
-  loadMore() {
-    console.log("触发loadMore")
-    console.log("当前状态:", {
-      loading: this.data.loading,
-      hasMore: this.data.hasMore,
-      page: this.data.page,
-      videoListLength: this.data.videoList.length
-    })
-
-    // 添加防抖,避免频繁触发
-    const now = Date.now()
-    if (now - this.data.lastLoadTime < 500) {
-      console.log("防抖触发,跳过本次加载")
-      return
-    }
 
-    if (this.data.hasMore && !this.data.loading) {
-      console.log("开始加载更多数据")
-      this.setData({
-        page: this.data.page + 1,
-        lastLoadTime: now
-      })
-      this.loadVideoList()
-    } else {
-      console.log("不满足加载条件:", {
-        hasMore: this.data.hasMore,
-        loading: this.data.loading
-      })
-    }
-  },
-
-  // 刷新列表
-  refreshList() {
-    wx.showLoading({
-      title: '刷新中...',
-    })
-
-    this.setData({
-      page: 1,
-      videoList: [],
-      hasMore: true
-    })
-
-    this.loadVideoList().then(() => {
-      wx.hideLoading()
-      wx.showToast({
-        title: '刷新成功',
-        icon: 'success',
-        duration: 1500
-      })
-    }).catch(() => {
-      wx.hideLoading()
-    })
-  },
-
-  // 点击视频
-  onVideoTap(e) {
-    const videoId = e.currentTarget.dataset.id;
-
-    // 显示加载中提示
-    wx.showLoading({
-      title: '加载中...',
-      mask: true
-    });
-
-    // 获取当前点击的视频项
-    const video = this.data.videoList.find(item => item.id === videoId);
-
-    // 确保视频对象存在
-    if (!video) {
-      wx.hideLoading();
-      wx.showToast({
-        title: '视频数据错误',
-        icon: 'none'
-      });
-      return;
-    }
+        if (this.data.hasMore && !this.data.loading) {
+            console.log("开始加载更多数据")
+            this.setData({
+                page: this.data.page + 1,
+                lastLoadTime: now
+            })
+            this.loadVideoList()
+        } else {
+            console.log("不满足加载条件:", {
+                hasMore: this.data.hasMore,
+                loading: this.data.loading
+            })
+        }
+    },
+
+    // 刷新列表
+    refreshList() {
+        wx.showLoading({
+            title: '刷新中...',
+        })
+
+        this.setData({
+            page: 1,
+            videoList: [],
+            hasMore: true
+        })
+
+        this.loadVideoList().then(() => {
+            wx.hideLoading()
+            wx.showToast({
+                title: '刷新成功',
+                icon: 'success',
+                duration: 1500
+            })
+        }).catch(() => {
+            wx.hideLoading()
+        })
+    },
 
-    // 将标题进行URI编码处理(避免特殊字符导致的问题)
-    const encodedTitle = encodeURIComponent(video.title || '');
-
-    // 跳转到视频详情页
-    wx.navigateTo({
-      url: `/pages/video/detail?id=${videoId}&title=${encodedTitle}&tag_id=${e.currentTarget.dataset.info.tag_ids[0]}`,
-      success: () => {
-        wx.hideLoading();
-      },
-      fail: (err) => {
-        console.error('跳转失败:', err);
-        wx.hideLoading();
-        wx.showToast({
-          title: '跳转失败',
-          icon: 'none'
+    // 点击视频
+    onVideoTap(e) {
+        const videoId = e.currentTarget.dataset.id;
+
+        // 显示加载中提示
+        wx.showLoading({
+            title: '加载中...',
+            mask: true
         });
-      }
-    });
-  },
-
-  // 下拉刷新
-  onPullDownRefresh() {
-    this.setData({
-      page: 1,
-      videoList: []
-    })
-    this.loadVideoList().then(() => {
-      wx.stopPullDownRefresh()
-    })
-  },
-
-  // 分享按钮点击事件
-  onShareTap(e) {
-    // 阻止事件冒泡
-    e.stopPropagation();
-  },
-
-  // 分享给朋友
-  onShareAppMessage(e) {
-    const video = e.target.dataset.video
-    if (!video) return {}
-
-    return {
-      title: video.title,
-      path: `/pages/video/video?shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`,
-      imageUrl: video.cover_image,
-      success: function (res) {
-        wx.showToast({
-          title: '分享成功',
-          icon: 'success',
-          duration: 1500
+
+        // 获取当前点击的视频项
+        const video = this.data.videoList.find(item => item.id === videoId);
+
+        // 确保视频对象存在
+        if (!video) {
+            wx.hideLoading();
+            wx.showToast({
+                title: '视频数据错误',
+                icon: 'none'
+            });
+            return;
+        }
+
+        // 将标题进行URI编码处理(避免特殊字符导致的问题)
+        const encodedTitle = encodeURIComponent(video.title || '');
+
+        // 跳转到视频详情页
+        wx.navigateTo({
+            url: `/pages/video/detail?id=${videoId}&title=${encodedTitle}&tag_id=${e.currentTarget.dataset.info.tag_ids[0]}`,
+            success: () => {
+                wx.hideLoading();
+            },
+            fail: (err) => {
+                console.error('跳转失败:', err);
+                wx.hideLoading();
+                wx.showToast({
+                    title: '跳转失败',
+                    icon: 'none'
+                });
+            }
+        });
+    },
+
+    // 下拉刷新
+    onPullDownRefresh() {
+        this.setData({
+            page: 1,
+            videoList: []
         })
-      },
-      fail: function (res) {
-        wx.showToast({
-          title: '分享失败',
-          icon: 'none',
-          duration: 1500
+        this.loadVideoList().then(() => {
+            wx.stopPullDownRefresh()
         })
-      }
-    }
-  },
+    },
+
+    // 分享按钮点击事件
+    onShareTap(e) {
+        // 阻止事件冒泡
+        e.stopPropagation();
+    },
+
+    // 分享给朋友
+    onShareAppMessage(e) {
+        const video = e.target.dataset.video
+        if (!video) return {}
+
+        return {
+            title: video.title,
+            path: `/pages/video/video?shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`,
+            imageUrl: video.cover_image,
+            success: function (res) {
+                wx.showToast({
+                    title: '分享成功',
+                    icon: 'success',
+                    duration: 1500
+                })
+            },
+            fail: function (res) {
+                wx.showToast({
+                    title: '分享失败',
+                    icon: 'none',
+                    duration: 1500
+                })
+            }
+        }
+    },
+
+    // 分享到朋友圈
+    onShareTimeline(e) {
+        const video = e.target.dataset.video
+        if (!video) return {}
 
-  // 分享到朋友圈
-  onShareTimeline(e) {
-    const video = e.target.dataset.video
-    if (!video) return {}
+        return {
+            title: video.title,
+            query: `shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`,
+            imageUrl: video.cover_image
+        }
+    },
 
-    return {
-      title: video.title,
-      query: `shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`,
-      imageUrl: video.cover_image
+    // 跳转到书籍详情
+    goToBookDetail() {
+        getApp().globalData.isShowDialog = true
+        // 使用公共的goToBookDetail函数
+        goToBookDetail({
+            bookId: 7266,
+            wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
+            chapterId: null
+        });
     }
-  },
-
-  // 跳转到书籍详情
-  goToBookDetail() {
-    getApp().globalData.isShowDialog = true
-    // 使用公共的goToBookDetail函数
-    goToBookDetail({
-      bookId: 7266,
-      wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
-      chapterId: null
-    });
-  }
 })

+ 3 - 3
pages/video/video.wxml

@@ -63,9 +63,9 @@
           </view>
         </view>
          <!-- 卡片原生广告 -->
-         <view wx:if="{{hasLoadAdConfig && itm.adType === 'templateAd' }}" class="ad-custom-card-1">
-            <ad-custom unit-id="{{ads.template_card_ads}}" data-field="templateError" data-name="首页页-卡片原生"
-              data-adId="{{ads.template_card_ads}}" capture-bind:tap="appletsAdClick" bindload="appletsAdLoad"
+         <view wx:if="{{itm.adType === 'templateAd' }}" class="ad-custom-card-1">
+            <ad-custom unit-id="{{templateAdId}}" data-field="templateError" data-name="首页页-卡片原生"
+              data-adId="{{templateAdId}}" capture-bind:tap="appletsAdClick" bindload="appletsAdLoad"
               binderror="appletsAdError"></ad-custom>
           </view>