Explorar o código

fix 视频列表广告

erekook hai 1 ano
pai
achega
13f6046ce3
Modificáronse 3 ficheiros con 60 adicións e 55 borrados
  1. 1 1
      config/config.js
  2. 16 11
      pages/video/video.js
  3. 43 43
      project.config.json

+ 1 - 1
config/config.js

@@ -471,7 +471,7 @@ const appInfoObj = {
 };
 
 // @config 确定使用的小程序appid
-const current_appid = 'wx1eb74c589da1731f';
+const current_appid = 'wxa721f4474e3d548a';
 export const apple = {
     ...appInfoObj[current_appid],
     appKey: '49TBR8Z1rA7PyqD30FV0v48AU',

+ 16 - 11
pages/video/video.js

@@ -20,6 +20,7 @@ let interstitialAd = null
 Page({
     data: {
         videoList: [],
+        originVideoList: [],
         loading: false,
         hasMore: true,
         page: 1,
@@ -185,7 +186,7 @@ Page({
         }
         console.log('入口:', options)
         try {
-            let {type, jump, shared_video_id, tag_id} = options
+            let { type, jump, shared_video_id, tag_id } = options
             const scene = wx.getStorageSync('scene');
             console.log('入口:', type, jump, scene, shared_video_id)
             if ((type === 'share' || type === 'tuiguang') && shared_video_id) {
@@ -223,7 +224,7 @@ Page({
         }, 1000)
     },
 
-    // 插屏广告加载 
+    // 插屏广告加载
     interstitalLoad() {
         let adId = apple.ads.insertAdId
         interstitialAd = wx.createInterstitialAd({
@@ -296,7 +297,7 @@ Page({
                         // })
                         console.log('登录后的openid:', uuidres.open_id)
                         console.log('登录成功:', app.globalData)
-                        SendEvent('login_shanhu', {"uuid": uuidres.uuid});
+                        SendEvent('login_shanhu', { "uuid": uuidres.uuid });
                         resolve(res.uuid)
                     }).catch((err) => {
                         reject(err)
@@ -354,6 +355,7 @@ Page({
             currentCategoryId: categoryId,
             page: 1,
             videoList: [],
+            originVideoList: [],
             hasMore: true
         })
         this.loadVideoList()
@@ -380,6 +382,7 @@ Page({
 
             let videoList = []
             try {
+
                 videoList = await getVideoList(params)
 
                 if (!Array.isArray(videoList)) {
@@ -393,8 +396,8 @@ Page({
                     adType: "video",
                     lock: false
                 }))
-                videoList = this.formatVideoAdList(videoList);
-                console.log("format videoList", videoList)
+                this.data.originVideoList = this.data.originVideoList.concat(videoList)
+                this.data.videoList = this.formatVideoAdList(deepCopy(this.data.originVideoList))
             } catch (apiError) {
                 console.error('API调用失败:', apiError)
                 throw apiError
@@ -402,14 +405,16 @@ Page({
             // 如果是第一页,直接替换数据
             if (this.data.page === 1) {
                 this.setData({
-                    videoList: videoList,
+                    videoList: this.data.videoList,
+                    originVideoList: this.data.originVideoList,
                     loading: false,
                     hasMore: videoList.length >= this.data.size
                 })
             } else {
                 // 否则追加数据
                 this.setData({
-                    videoList: [...this.data.videoList, ...videoList],
+                    videoList: this.data.videoList,
+                    originVideoList: this.data.originVideoList,
                     loading: false,
                     hasMore: videoList.length >= this.data.size
                 })
@@ -544,7 +549,7 @@ Page({
 
     // 点击视频
     onVideoTap(e) {
-        const {id, info, index} = e.currentTarget.dataset;
+        const { id, info, index } = e.currentTarget.dataset;
         console.log(id, info, index, '视频详情')
         if (!info) {
             wx.hideLoading();
@@ -554,7 +559,7 @@ Page({
             });
             return;
         }
-        SendEvent('click_video_tab_video', {"video_id": id, "tag_id": info.tag_ids[0], "uuid": app.globalData.uuid})
+        SendEvent('click_video_tab_video', { "video_id": id, "tag_id": info.tag_ids[0], "uuid": app.globalData.uuid })
         const encodedTitle = encodeURIComponent(info.title || '');
         this.unlockUrl = `/pages/video/detail?id=${id}&title=${encodedTitle}&tag_id=${info.tag_ids[0]}`
         if (!info.lock) {
@@ -613,7 +618,7 @@ Page({
         if (jump === 1) {
             url += '&jump=1';
         }
-        SendEvent('click_list_share', {"video_id": video.id, "tag_id": video.tag_ids[0], "uuid": app.globalData.uuid});
+        SendEvent('click_list_share', { "video_id": video.id, "tag_id": video.tag_ids[0], "uuid": app.globalData.uuid });
         return {
             title: video.title,
             path: url,
@@ -642,7 +647,7 @@ Page({
         const jump = wx.getStorageSync('jump');// 是否跳转阅读器
         let url = '';
         url = `shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`;
-        SendEvent('click_list_share', {"video_id": video.id, "tag_id": video.tag_ids[0], "uuid": app.globalData.uuid});
+        SendEvent('click_list_share', { "video_id": video.id, "tag_id": video.tag_ids[0], "uuid": app.globalData.uuid });
         if (jump === 1) {
             url += '&jump=1';
         }

+ 43 - 43
project.config.json

@@ -1,46 +1,46 @@
 {
-    "compileType": "miniprogram",
-    "packOptions": {
-        "ignore": [
-            {
-                "value": "/minitest",
-                "type": "folder"
-            }
-        ],
-        "include": []
+  "compileType": "miniprogram",
+  "packOptions": {
+    "ignore": [
+      {
+        "value": "/minitest",
+        "type": "folder"
+      }
+    ],
+    "include": []
+  },
+  "setting": {
+    "coverView": true,
+    "es6": true,
+    "postcss": true,
+    "minified": true,
+    "enhance": true,
+    "showShadowRootInWxmlPanel": true,
+    "packNpmRelationList": [],
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
     },
-    "setting": {
-        "coverView": true,
-        "es6": true,
-        "postcss": true,
-        "minified": true,
-        "enhance": true,
-        "showShadowRootInWxmlPanel": true,
-        "packNpmRelationList": [],
-        "babelSetting": {
-            "ignore": [],
-            "disablePlugins": [],
-            "outputPath": ""
-        },
-        "compileWorklet": false,
-        "uglifyFileName": false,
-        "uploadWithSourceMap": true,
-        "packNpmManually": false,
-        "minifyWXSS": true,
-        "minifyWXML": true,
-        "localPlugins": false,
-        "disableUseStrict": false,
-        "useCompilerPlugins": false,
-        "condition": false,
-        "swc": false,
-        "disableSWC": true
-    },
-    "editorSetting": {
-        "tabIndent": "auto",
-        "tabSize": 2
-    },
-    "appid": "wx1eb74c589da1731f",
-    "testRoot": "minitest/",
-    "libVersion": "trial",
-    "simulatorPluginLibVersion": {}
+    "compileWorklet": false,
+    "uglifyFileName": false,
+    "uploadWithSourceMap": true,
+    "packNpmManually": false,
+    "minifyWXSS": true,
+    "minifyWXML": true,
+    "localPlugins": false,
+    "disableUseStrict": false,
+    "useCompilerPlugins": false,
+    "condition": false,
+    "swc": false,
+    "disableSWC": true
+  },
+  "editorSetting": {
+    "tabIndent": "auto",
+    "tabSize": 2
+  },
+  "appid": "wxa721f4474e3d548a",
+  "testRoot": "minitest/",
+  "libVersion": "trial",
+  "simulatorPluginLibVersion": {}
 }