hjr 2 bulan lalu
induk
melakukan
5006297ba7

+ 1 - 1
src/components/addDesktop.ux

@@ -15,7 +15,7 @@ export default {
   props: {
     bottom:{
         type: [String,Number],
-        default: 200
+        default: 220
     }
  },
   data: {

+ 25 - 2
src/components/my/index.ux

@@ -36,7 +36,6 @@
         <text>></text> 
      </div>
      <div class="item_tab" if="{{ showTool }}" @click="toPage('components/tools-mall')">
-     <!-- <div class="item_tab" if="{{ showTool }}" @click="toPage('pages/tools-mall')"> -->
        <div>
         <text class="iconfont">&#xe648;</text>
         <text style="margin-left: 10px;">工具</text> 
@@ -53,6 +52,7 @@ export default {
   data: {
     page: 1,
     showTool:false,
+    ad:null,
   },
   onReady() {
     var that = this
@@ -60,7 +60,30 @@ export default {
         if(value !='vivo'){
           that.showTool = true
         }
-      })
+      })   
+      this.initAd();
+      setTimeout(()=>{
+        if(this.ad) {        
+        this.ad.show();
+        } else {        
+          this.initAd();
+        }
+      },500)
+  },
+  initAd(){
+    try {        
+        this.ad = require('@service.ad').createBannerAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+          adUnitId: '9bcd5671a506459c9e6ef9c642468dc9',          
+          style:{            
+            left: 0,       
+            top: 1240,
+            height:100,        
+            width: 1080
+          }
+        })
+      } catch (e) {        
+        console.log(e)
+      }
   },
   toPage(path) {
     router.push({

+ 1 - 1
src/components/tools-mall/index.ux

@@ -1,6 +1,6 @@
 <template>
   <div class="page-column">
-      <image class="w h-350" src="https://ytnovels.oss-cn-shanghai.aliyuncs.com/appStatic/images/index_banner.jpg"></image>
+      <!-- <image class="w h-350" src="https://ytnovels.oss-cn-shanghai.aliyuncs.com/appStatic/images/index_banner.jpg"></image> -->
     <div class="search-hot">
       <div class="box" for="(index, item) in hotList">
           <text class="title_"> {{ item.title }}</text>

+ 154 - 98
src/helper/ad-manager.js

@@ -4,6 +4,7 @@
  */
 
 import ad from '@service.ad'
+import prompt from '@system.prompt'
 
 class AdManager {
   constructor() {
@@ -15,22 +16,31 @@ class AdManager {
     // 广告位ID配置 - 请替换为您的实际广告位ID
     this.adConfig = {
       banner: {
-        posId: 'your_banner_pos_id', // Banner广告位ID
+        posId: '9bcd5671a506459c9e6ef9c642468dc9', // Banner广告位ID
         style: {
           width: 750,
           height: 100
         }
       },
       interstitial: {
-        posId: 'your_interstitial_pos_id' // 插屏广告位ID
+        posId: '6bd7f72fb64249bda8770adc0619d0cc' // 插屏广告位ID
       },
       native: {
-        posId: 'your_native_pos_id' // 原生广告位ID
+        // posId: '805a483bc3b14205a1d160cb97d0eca0'
+        posId: '6f2e50489ff74bae800ce65c992bfec0' // 原生广告位ID
       },
       rewarded: {
-        posId: 'your_rewarded_pos_id' // 激励视频广告位ID
+        posId: 'd3d0539a806145ebabf502d29d0d1b43' // 激励视频广告位ID
       }
     }
+    
+    // 广告状态
+    this.adStatus = {
+      banner: { loaded: false, showing: false },
+      interstitial: { loaded: false },
+      native: { loaded: false, data: null },
+      rewarded: { loaded: false }
+    }
   }
 
   /**
@@ -39,28 +49,28 @@ class AdManager {
   initBannerAd() {
     try {
       this.bannerAd = ad.createBannerAd({
-        posId: this.adConfig.banner.posId,
+        adUnitId: this.adConfig.banner.posId,
         style: this.adConfig.banner.style
       })
-
-      // 监听广告加载完成
+      
       this.bannerAd.onLoad(() => {
-        console.log('Banner广告加载完成')
+        console.log('Banner广告加载成功')
+        this.adStatus.banner.loaded = true
       })
-
-      // 监听广告加载失败
+      
       this.bannerAd.onError((err) => {
-        console.error('Banner广告加载失败:', err)
+        console.log('Banner广告加载失败:', err)
+        this.adStatus.banner.loaded = false
       })
-
-      // 监听广告点击
-      this.bannerAd.onClose(() => {
-        console.log('Banner广告被关闭')
+      
+      this.bannerAd.onClose((res) => {
+        console.log('Banner广告关闭:', res)
+        this.adStatus.banner.showing = false
       })
-
+      
       return this.bannerAd
-    } catch (error) {
-      console.error('初始化Banner广告失败:', error)
+    } catch (e) {
+      console.log('初始化Banner广告失败:', e)
       return null
     }
   }
@@ -69,10 +79,13 @@ class AdManager {
    * 显示Banner广告
    */
   showBannerAd() {
-    if (this.bannerAd) {
+    if (this.bannerAd && this.adStatus.banner.loaded) {
       this.bannerAd.show()
+      this.adStatus.banner.showing = true
+      return true
     } else {
-      console.warn('Banner广告未初始化')
+      console.log('Banner广告未加载或不可用')
+      return false
     }
   }
 
@@ -80,8 +93,9 @@ class AdManager {
    * 隐藏Banner广告
    */
   hideBannerAd() {
-    if (this.bannerAd) {
+    if (this.bannerAd && this.adStatus.banner.showing) {
       this.bannerAd.hide()
+      this.adStatus.banner.showing = false
     }
   }
 
@@ -91,27 +105,27 @@ class AdManager {
   initInterstitialAd() {
     try {
       this.interstitialAd = ad.createInterstitialAd({
-        posId: this.adConfig.interstitial.posId
+        adUnitId: this.adConfig.interstitial.posId
       })
-
-      // 监听广告加载完成
+      
       this.interstitialAd.onLoad(() => {
-        console.log('插屏广告加载完成')
+        console.log('插屏广告加载成功')
+        this.adStatus.interstitial.loaded = true
       })
-
-      // 监听广告加载失败
+      
       this.interstitialAd.onError((err) => {
-        console.error('插屏广告加载失败:', err)
+        console.log('插屏广告加载失败:', err)
+        this.adStatus.interstitial.loaded = false
       })
-
-      // 监听广告关闭
-      this.interstitialAd.onClose(() => {
-        console.log('插屏广告被关闭')
+      
+      this.interstitialAd.onClose((res) => {
+        console.log('插屏广告关闭:', res)
+        this.adStatus.interstitial.loaded = false
       })
-
+      
       return this.interstitialAd
-    } catch (error) {
-      console.error('初始化插屏广告失败:', error)
+    } catch (e) {
+      console.log('初始化插屏广告失败:', e)
       return null
     }
   }
@@ -120,53 +134,60 @@ class AdManager {
    * 显示插屏广告
    */
   showInterstitialAd() {
-    if (this.interstitialAd) {
+    if (this.interstitialAd && this.adStatus.interstitial.loaded) {
       this.interstitialAd.show()
+      return true
     } else {
-      console.warn('插屏广告未初始化')
+      console.log('插屏广告未加载或不可用')
+      return false
     }
   }
 
   /**
-   * 初始化原生广告
+   * 预加载原生广告2.0
    */
-  initNativeAd() {
-    try {
-      this.nativeAd = ad.createNativeAd({
-        posId: this.adConfig.native.posId
-      })
-
-      // 监听广告加载完成
-      this.nativeAd.onLoad((res) => {
-        console.log('原生广告加载完成:', res)
-      })
-
-      // 监听广告加载失败
-      this.nativeAd.onError((err) => {
-        console.error('原生广告加载失败:', err)
-      })
-
-      // 监听广告点击
-      this.nativeAd.onClick(() => {
-        console.log('原生广告被点击')
-      })
-
-      return this.nativeAd
-    } catch (error) {
-      console.error('初始化原生广告失败:', error)
-      return null
+  preloadNativeAd(callback) {
+    const adParams = {
+      adUnitId: this.adConfig.native.posId,
+      type: 'native',
+      adCount: 1
     }
+    
+    ad.preloadAd({
+      ...adParams,
+      success: (data) => {
+        console.log('原生广告预加载成功:', data)
+        if (data && data.adList && data.adList.length > 0) {
+          this.adStatus.native.loaded = true
+          this.adStatus.native.data = data.adList[0]
+          if (callback) callback(true, data.adList[0])
+        } else {
+          this.adStatus.native.loaded = false
+          this.adStatus.native.data = null
+          if (callback) callback(false, null)
+        }
+      },
+      fail: (data, code) => {
+        console.log('原生广告预加载失败:', data, code)
+        this.adStatus.native.loaded = false
+        this.adStatus.native.data = null
+        if (callback) callback(false, null)
+      }
+    })
   }
 
   /**
-   * 显示原生广告
+   * 获取原生广告数据
    */
-  showNativeAd() {
-    if (this.nativeAd) {
-      this.nativeAd.show()
-    } else {
-      console.warn('原生广告未初始化')
-    }
+  getNativeAdData() {
+    return this.adStatus.native.data
+  }
+
+  /**
+   * 检查原生广告是否已加载
+   */
+  isNativeAdLoaded() {
+    return this.adStatus.native.loaded
   }
 
   /**
@@ -175,35 +196,35 @@ class AdManager {
   initRewardedVideoAd() {
     try {
       this.rewardedVideoAd = ad.createRewardedVideoAd({
-        posId: this.adConfig.rewarded.posId
+        adUnitId: this.adConfig.rewarded.posId
       })
-
-      // 监听广告加载完成
+      
       this.rewardedVideoAd.onLoad(() => {
-        console.log('激励视频广告加载完成')
+        console.log('激励视频广告加载成功')
+        this.adStatus.rewarded.loaded = true
       })
-
-      // 监听广告加载失败
+      
       this.rewardedVideoAd.onError((err) => {
-        console.error('激励视频广告加载失败:', err)
+        console.log('激励视频广告加载失败:', err)
+        this.adStatus.rewarded.loaded = false
       })
-
-      // 监听广告关闭
+      
       this.rewardedVideoAd.onClose((res) => {
-        console.log('激励视频广告被关闭:', res)
+        console.log('激励视频广告关闭:', res)
+        this.adStatus.rewarded.loaded = false
         if (res && res.isEnded) {
-          // 正常播放结束,可以下发游戏奖励
-          console.log('激励视频播放完成,可以发放奖励')
-          this.onRewardedVideoComplete && this.onRewardedVideoComplete()
+          console.log('激励视频正常播放结束,可以发放奖励')
+          if (this.onRewardedVideoComplete) {
+            this.onRewardedVideoComplete()
+          }
         } else {
-          // 播放中途退出,不下发游戏奖励
-          console.log('激励视频播放中途退出')
+          console.log('激励视频播放中途退出,不发放奖励')
         }
       })
-
+      
       return this.rewardedVideoAd
-    } catch (error) {
-      console.error('初始化激励视频广告失败:', error)
+    } catch (e) {
+      console.log('初始化激励视频广告失败:', e)
       return null
     }
   }
@@ -212,10 +233,12 @@ class AdManager {
    * 显示激励视频广告
    */
   showRewardedVideoAd() {
-    if (this.rewardedVideoAd) {
+    if (this.rewardedVideoAd && this.adStatus.rewarded.loaded) {
       this.rewardedVideoAd.show()
+      return true
     } else {
-      console.warn('激励视频广告未初始化')
+      console.log('激励视频广告未加载或不可用')
+      return false
     }
   }
 
@@ -223,10 +246,23 @@ class AdManager {
    * 预加载所有广告
    */
   preloadAllAds() {
-    this.initBannerAd()
-    this.initInterstitialAd()
-    this.initNativeAd()
-    this.initRewardedVideoAd()
+    // 预加载Banner广告
+    if (this.bannerAd) {
+      this.bannerAd.load()
+    }
+    
+    // 预加载插屏广告
+    if (this.interstitialAd) {
+      this.interstitialAd.load()
+    }
+    
+    // 预加载原生广告
+    this.preloadNativeAd()
+    
+    // 预加载激励视频广告
+    if (this.rewardedVideoAd) {
+      this.rewardedVideoAd.load()
+    }
   }
 
   /**
@@ -237,18 +273,38 @@ class AdManager {
       this.bannerAd.destroy()
       this.bannerAd = null
     }
+    
     if (this.interstitialAd) {
       this.interstitialAd.destroy()
       this.interstitialAd = null
     }
-    if (this.nativeAd) {
-      this.nativeAd.destroy()
-      this.nativeAd = null
-    }
+    
     if (this.rewardedVideoAd) {
       this.rewardedVideoAd.destroy()
       this.rewardedVideoAd = null
     }
+    
+    // 重置状态
+    this.adStatus = {
+      banner: { loaded: false, showing: false },
+      interstitial: { loaded: false },
+      native: { loaded: false, data: null },
+      rewarded: { loaded: false }
+    }
+  }
+
+  /**
+   * 获取广告状态
+   */
+  getAdStatus() {
+    return this.adStatus
+  }
+
+  /**
+   * 检查广告是否可用
+   */
+  isAdAvailable(adType) {
+    return this.adStatus[adType] && this.adStatus[adType].loaded
   }
 }
 

+ 16 - 4
src/manifest.json

@@ -3,7 +3,7 @@
   "name": "柚趣屋",
   "versionName": "1.0.2",
   "versionCode": 7,
-  "minPlatformVersion": 1080,
+  "minPlatformVersion": 1100,
   "icon": "/assets/logo.png",
   "features": [
     {
@@ -54,9 +54,15 @@
     {
       "name": "system.geolocation"
     },
-    {"name":"service.ad"},
-    { "name": "service.health" },
-    { "name": "system.shortcut" }
+    {
+      "name": "service.ad"
+    },
+    {
+      "name": "service.health"
+    },
+    {
+      "name": "system.shortcut"
+    }
   ],
   "permissions": [
     {
@@ -71,6 +77,9 @@
   "router": {
     "entry": "pages/main",
     "pages": {
+      "pages/first": {
+        "component": "index"
+      },
       "pages/main": {
         "component": "index"
       },
@@ -304,6 +313,9 @@
       },
       "pages/commonModule/exchangeList": {
         "titleBarText": "兑换列表"
+      },
+      "pages/first": {
+        "titleBarText": ""
       }
     }
   }

+ 38 - 9
src/pages/book-content/index.ux

@@ -167,7 +167,7 @@ export default {
     },
     colors: ['#EAEAEF', '#FAF9DE', '#E3EDCD', '#DCE2F1', '#FFF2E2'],
     bannerAd: null,
-
+    ad: null,
     fonts: [
       {
         name: '系统字体',
@@ -342,14 +342,43 @@ export default {
     }
     if (!!this.showPop) this.showPop = false
     // 调用接口,用bookId和chapterId查询下一页的内容,更新content和title。以下代码为模拟翻页。
-    this.chapterId = type === 'next' ? this.chapterId + 1 : this.chapterId - 1
-    const res = await $apis.common.novelChapterPage({chapter: this.chapterId, novelId: this.bookId})
-    let infos = res.data.result.list[0]
-    this.chapterTitle = infos.chapterName
-    this.getTxtContent(infos.content)
-    this.$element('list').scrollTo({ index: 0 })
-    this.currentPage = 1
-    this.editChapterId()
+    if(type === 'last'){
+        this.chapterId = this.chapterId - 1
+        const res = await $apis.common.novelChapterPage({chapter: this.chapterId, novelId: this.bookId})
+        let infos = res.data.result.list[0]
+        this.chapterTitle = infos.chapterName
+        this.getTxtContent(infos.content)
+        this.$element('list').scrollTo({ index: 0 })
+        this.currentPage = 1
+        this.editChapterId()
+    }else{
+      try {        
+        this.ad = require('@service.ad').createRewardedVideoAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+          adUnitId: 'd3d0539a806145ebabf502d29d0d1b43',
+        })        
+        this.ad.onLoad(() => {          
+          this.ad.show();
+        })        
+        this.ad.onClose(async(res) => {           
+           if (res && res.isEnded) {             
+             console.log("正常播放结束,可以下发奖励");
+            this.chapterId =  this.chapterId + 1
+            const res = await $apis.common.novelChapterPage({chapter: this.chapterId, novelId: this.bookId})
+            let infos = res.data.result.list[0]
+            this.chapterTitle = infos.chapterName
+            this.getTxtContent(infos.content)
+            this.$element('list').scrollTo({ index: 0 })
+            this.currentPage = 1
+            this.editChapterId()
+           } else {             
+             console.log("播放中途退出,不下发奖励");
+           }
+        })        
+        this.ad.load();
+      } catch (e) {        
+        console.log(e)
+      }
+    }
   },
   // 修改书架中当前阅读的章节
   editChapterId (){

+ 37 - 4
src/pages/book-detail/index.ux

@@ -65,6 +65,8 @@
 <script>
 import { bookListData } from '../../assets/data/book-list.js'
 import { commentData } from '../../assets/data/comment.js'
+import device from '@system.device'
+
 export default {
   public: {
     info: '',
@@ -79,7 +81,8 @@ export default {
     shelfInfo:{},//书架信息
     linkInfo:{},
     adList:[],
-
+    ad:null,
+    screenHeight:0,
   },
   async onInit() {
     // 此处直接将图书内容传进来,实际开发中也可以传入id查询图书信息
@@ -106,11 +109,41 @@ export default {
       const res = await $apis.common.novelDetail({id:this.bookInfo.novelId})
       this.bookInfo = res.data.ytNovel
     }
+    this.initAd();
+      setTimeout(()=>{
+        if(this.ad) {        
+        this.ad.show();
+        } else {        
+          this.initAd();
+        }
+      },500)
     this.indexNativeAd()  // 原生退出广告弹窗
   },
+  initAd(){
+    try {
+      var that = this
+      device.getInfo({
+      success: function(ret) {
+        that.screenHeight = ret.screenHeight
+        console.log('ret',ret)
+         that.ad = require('@service.ad').createBannerAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+          adUnitId: '9bcd5671a506459c9e6ef9c642468dc9',          
+          style:{            
+            left: 0,       
+            top: that.screenHeight + 50,
+            height:100,        
+            width: 1080
+          }
+        })
+        }
+      })
+      } catch (e) {        
+        console.log(e)
+      }
+  },
   indexNativeAd(){
     // 原生广告 1.0
-    let nativeAd = ad.createNativeAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+    let nativeAd = require('@service.ad').createNativeAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
         adUnitId:  'e2528e5d2baf4cef9a359f3074ca193c',
     })
     nativeAd.onLoad((data) => {          
@@ -123,7 +156,7 @@ export default {
       type: 'native',          // 原生广告2.0广告类型 
       adCount: 2,              // 原生广告2.0广告预期返回广告条数   
     }
-    ad.preloadAd({
+    require('@service.ad').preloadAd({
       ...adParams,
       success: (data) => {
         this.adList = data.adList
@@ -242,7 +275,7 @@ export default {
 }
 
 .detail-bottom-bar {
-  padding: @gap-3 @gap-4;
+  padding: @gap-3 @gap-4 115px;
   background-color: @bg-grey;
   .border-top-mixins();
   .flex-box-mixins(row, space-between, center);

+ 103 - 8
src/pages/commonModule/redPacket/index.ux

@@ -33,6 +33,43 @@
             <text>{{getStatus?'已领取':'立即领取'}}</text>
           </div>
         </div>
+        <div style="height: 300px;width: 100%;">
+           <ad
+            adId="{{adList.adId}}"
+            class="ad-native"
+            style="height: 100%;width: 100%;"
+            if="{{adList && adList.adId}}"
+          >
+            <div class="container">
+              <block>
+                <div class="vertical-content big-img">
+                  <ad-clickable-area type="click" class="ad-image"  if="{{ adList.creativeType===2}}">
+                    <image src="{{adList.imgUrlList[0]}}" style="width: 100%;"></image>
+                  </ad-clickable-area>
+                  <!-- <div class="ad-text">
+                    <ad-clickable-area type="click">
+                      <text>{{ adList.desc }}</text>
+                    </ad-clickable-area>
+                  </div> -->
+                </div>
+              </block>
+              <div class="footer">
+                <ad-clickable-area type="click" class="footer-info">
+                  <image class="tag" src="{{adList.icon}}"></image>
+                  <text class="title">{{ adList.title  }}</text>
+                </ad-clickable-area>
+                <div class="click-item">
+                  <ad-clickable-area
+                    type="button"
+                    class="click-txt"
+                    value="{{ adList.clickBtnTxt }}"
+                  >
+                  </ad-clickable-area>
+                </div>
+              </div>
+            </div>
+          </ad>
+        </div>
         <div class="bottom_item" style="border-bottom: 1px solid #ddd;">
           <div class="fd_c">
             <text class="text-32 text-000">柚趣屋</text>
@@ -55,8 +92,45 @@ export default {
     coinNum:0,//金币数量
     signStatus:false, // 是否已经签到
     getStatus:false,// 是否已领取
+    adUnitId: "d3d0539a806145ebabf502d29d0d1b43", // 这个id是vivo的com.quickapp.center创建的,需要修改manifest的package才能预览出效果
+    ad: null,
+    adList:{},
+  },
+  onInit() {
+      // this.initAd()
+      this.indexNativeAd()
+  },
+  indexNativeAd(){
+    // 原生广告 1.0
+    // let nativeAd = ad.createNativeAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+    //     adUnitId:  '805a483bc3b14205a1d160cb97d0eca0',
+    // })
+    // nativeAd.onLoad((data) => {          
+    //   console.log('Native ad resources!', data); // 广告加载成功,返回原生广告资源,根据但是资源自行渲染展现
+    // })        
+    // nativeAd.load();
+    // 原生广告2.0
+    let adParams = {
+      adUnitId: '805a483bc3b14205a1d160cb97d0eca0', // 原生广告2.0广告位id
+      type: 'native',          // 原生广告2.0广告类型 
+      adCount: 1,              // 原生广告2.0广告预期返回广告条数   
+    }
+    require('@service.ad').preloadAd({
+      ...adParams,
+      success: (data) => {
+        this.adList = data.adList[0]
+        console.log('data',data)
+        // prompt.showToast({
+        //   message: `success! data=${JSON.stringify(data)}`
+        // })
+      }, fail: (data, code) => {
+        console.log(data, code)
+        // prompt.showToast({
+        //   message: `fail! data=${JSON.stringify(data)}, code=${code}`
+        // })
+      }
+    })
   },
-  onInit() {},
   backIndex() {
     router.replace({
       uri: 'pages/main',
@@ -71,14 +145,35 @@ export default {
     })
   },
   getCoin(){
-      if(!this.getStatus){
-        $utils.showToast('领取成功')
-        this.coinNum += 10
-        this.getStatus = true
-      }else{
-        $utils.showToast('已领取')
-      }
+      this.initAd()
   },
+   initAd() {      
+      try {        
+        this.ad = require('@service.ad').createRewardedVideoAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+          adUnitId: this.adUnitId,
+        })        
+        this.ad.onLoad(() => {          
+          this.ad.show();
+        })        
+        this.ad.onClose((res) => {           
+           if (res && res.isEnded) {             
+             console.log("正常播放结束,可以下发奖励");
+             if(!this.getStatus){
+                $utils.showToast('领取成功')
+                this.coinNum += 10
+                this.getStatus = true
+              }else{
+                $utils.showToast('已领取')
+              }
+           } else {             
+             console.log("播放中途退出,不下发奖励");
+           }
+        })        
+        this.ad.load();
+      } catch (e) {        
+        console.log(e)
+      }
+    },
   signIn(){
       if(!this.signStatus){
         $utils.showToast('签到成功')

+ 186 - 0
src/pages/first/index.ux

@@ -0,0 +1,186 @@
+<template>
+  <div class="wrapper">
+    <ad
+        adId="{{adList.adId}}"
+        style="height: 250px;width: 100%;"
+        if="{{adList && adList.adId}}"
+      >
+      <div class="container">
+        <block>
+          <div class="vertical-content big-img">
+            <ad-clickable-area type="click" class="ad-image"  if="{{ adList.imgUrlList}}">
+              <image src="{{adList.imgUrlList[0]}}" style="width: 100%;height:100%;"></image>
+            </ad-clickable-area>
+            <div class="ad-text">
+              <ad-clickable-area type="click" if="{{ adList.desc}}">
+                <text>{{ adList.desc }}</text>
+              </ad-clickable-area>
+            </div>
+          </div>
+        </block>
+        <div>
+          <ad-clickable-area type="click" class="footer-info">
+            <text class="title">{{ adList.title  }}</text>
+          </ad-clickable-area>
+        </div>
+      </div>
+    </ad>
+    <ad
+        adId="{{adList2.adId}}"
+        style="height: 250px;width: 100%;"
+        if="{{adList2 && adList2.adId}}"
+      >
+      <div class="container">
+        <block>
+          <div class="vertical-content big-img">
+            <ad-clickable-area type="click" class="ad-image"  if="{{ adList2.imgUrlList}}">
+              <image src="{{adList2.imgUrlList[0]}}" style="width: 100%;height:100%;"></image>
+            </ad-clickable-area>
+            <div class="ad-text">
+              <ad-clickable-area type="click" if="{{ adList2.desc}}">
+                <text>{{ adList2.desc }}</text>
+              </ad-clickable-area>
+            </div>
+          </div>
+        </block>
+        <div>
+          <ad-clickable-area type="click" class="footer-info">
+            <text class="title">{{ adList2.title  }}</text>
+          </ad-clickable-area>
+        </div>
+      </div>
+    </ad>
+    <text @click="initRewardAd">打开激励视频</text>
+  </div>
+</template>
+
+<script>
+import ad from '@service.ad'
+import prompt from '@system.prompt'
+export default {
+  private: {
+    adUnitId: "9bcd5671a506459c9e6ef9c642468dc9",// banner 广告
+    adList: {},
+    adList2: {},
+    adBanner: null,
+    adReward: null,
+    adInsert:null,
+  },
+  // 广告
+  onInit() {
+     this.initNativeAd()
+     this.initNativeAd2()
+     this.initAd()
+    this.initBanner()
+  },
+  initNativeAd(){   
+    // 原生广告2.0
+    let adParams = {
+      adUnitId: '805a483bc3b14205a1d160cb97d0eca0', // 原生广告2.0广告位id
+      type: 'native',          // 原生广告2.0广告类型 
+      adCount: 1,              // 原生广告2.0广告预期返回广告条数   
+    }
+    var native = require('@service.ad').preloadAd({
+      ...adParams,
+      success: (data) => {
+        this.adList = data.adList[0]
+        console.log('data',data)
+      }, fail: (data, code) => {
+        console.log(data, code)
+      }
+    })
+  },
+  initNativeAd2(){
+    let adParams = {
+      adUnitId: '6f2e50489ff74bae800ce65c992bfec0', // 原生广告2.0广告位id
+      type: 'native',          // 原生广告2.0广告类型 
+      adCount: 1,              // 原生广告2.0广告预期返回广告条数   
+    }
+    require('@service.ad').preloadAd({
+      ...adParams,
+      success: (data) => {
+        this.adList2 = data.adList[0]
+        console.log('data',data)
+        // prompt.showToast({
+        //   message: `success! data=${JSON.stringify(data)}`
+        // })
+      }, fail: (data, code) => {
+        console.log(data, code)
+        // prompt.showToast({
+        //   message: `fail! data=${JSON.stringify(data)}, code=${code}`
+        // })
+      }
+    })
+  },
+  initBanner(){
+     try {        
+        this.adBanner = require('@service.ad').createBannerAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+          adUnitId: '9bcd5671a506459c9e6ef9c642468dc9',          
+          style:{            
+            left: 0,
+            top: 1250,
+            height:150,
+            width: 1080
+          }
+        })
+         this.adBanner.show();
+        this.adBanner.onClose((e)=>{
+          this.initBanner()
+        })
+      } catch (e) {        
+        console.log(e)
+      }
+  },
+  initAd() {
+       try {        
+        this.adInsert = require('@service.ad').createInterstitialAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+          adUnitId: '6bd7f72fb64249bda8770adc0619d0cc',
+        })        
+        this.adInsert.onLoad(() => {          
+          this.adInsert.show();
+        })
+        this.adInsert.onClose((e)=>{
+          console.log('关闭')
+          // setTimeout(()=>{
+          //  this.initAd()
+          // },500)
+          // this.initRewardAd()
+        })
+      } catch (e) {        
+        console.log(e)
+      }
+    },
+  initRewardAd() {      
+      try {        
+        this.adReward = require('@service.ad').createRewardedVideoAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+          adUnitId: 'd3d0539a806145ebabf502d29d0d1b43',
+        })        
+        this.adReward.onLoad(() => {          
+          this.adReward.show();
+        })        
+        this.adReward.onClose((res) => {           
+           if (res && res.isEnded) {             
+             console.log("正常播放结束,可以下发奖励");
+              // this.initAd()
+           } else {             
+             console.log("播放中途退出,不下发奖励");
+            // this.initAd()
+           }
+        })        
+        this.adReward.load();
+      } catch (e) {        
+        console.log(e)
+      }
+    },
+}
+</script>
+
+<style>
+.wrapper {
+  flex-direction: column;
+}
+.title {
+  text-align: center;
+  color: #212121;
+}
+</style>

+ 69 - 46
src/pages/main/index.ux

@@ -12,6 +12,40 @@
 
 <template>
   <div class="page-wrapper">
+    <ad
+        adId="{{adList.adId}}"
+        style="height: 250px;width: 100%;"
+        if="{{adList && adList.adId}}"
+      >
+      <div class="container">
+        <block>
+          <div class="vertical-content big-img">
+            <ad-clickable-area type="click" class="ad-image"  if="{{ adList.imgUrlList}}">
+              <image src="{{adList.imgUrlList[0]}}" style="width: 100%;height:100%;"></image>
+            </ad-clickable-area>
+            <div class="ad-text">
+              <ad-clickable-area type="click" if="{{ adList.desc}}">
+                <text>{{ adList.desc }}</text>
+              </ad-clickable-area>
+            </div>
+          </div>
+        </block>
+        <div>
+          <ad-clickable-area type="click" class="footer-info">
+            <!-- <image class="tag" src="{{adList.icon}}"></image> -->
+            <text class="title">{{ adList.title  }}</text>
+          </ad-clickable-area>
+          <!-- <div class="click-item">
+            <ad-clickable-area
+              type="button"
+              class="click-txt"
+              value="{{ adList.clickBtnTxt }}"
+            >
+            </ad-clickable-area>
+          </div> -->
+        </div>
+      </div>
+    </ad>
     <tabs index="{{selectedTab}}" onchange="changeTab">
       <tab-content scrollable="{{false}}">
         <bookshelf
@@ -22,7 +56,7 @@
         <!-- <search-book></search-book> -->
         <weather></weather>
         <calendar></calendar>
-        <!--  if="{{ brand == 'vivo' }}" -->
+        <!-- if="{{ brand == 'vivo' }}" -->
         <tools-mall></tools-mall>
         <my></my>
       </tab-content>
@@ -69,6 +103,8 @@ import { bookListData } from '../../assets/data/book-list.js'
 import device from '@system.device'
 import ad from '@service.ad'
 import prompt from '@system.prompt'
+import adManager from '../../helper/ad-manager.js'
+import router from '@system.router'
 
 export default {
   public: {
@@ -119,14 +155,17 @@ export default {
     showModal:false,
     bannerAd: null,
     adUnitId: "9bcd5671a506459c9e6ef9c642468dc9",// banner 广告
-    adList:[],
+    adList: {},
+    ad: null,
   },
   async onInit() {
     // this.selectedTab = this.tab // || 0 // 带参数则跳转对应页面
+    // router.push({
+    //   uri: 'pages/first'
+    // })
     console.log(ad.getProvider())
-    this.initAd()
-    this.indexNativeAd(); // 
-    this.splashswitch(true)
+    // this.initAd()
+    this.initNativeAd(); // 
     const data = await $utils.getStorage('agreePrivacy')
     if(!data){
       this.showModal = true
@@ -145,57 +184,40 @@ export default {
       }
     })
   },
-  indexNativeAd(){
-    // 原生广告 1.0
-    let nativeAd = ad.createNativeAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
-        adUnitId:  '805a483bc3b14205a1d160cb97d0eca0',
-    })
-    nativeAd.onLoad((data) => {          
-      console.log('Native ad resources!', data); // 广告加载成功,返回原生广告资源,根据但是资源自行渲染展现
-    })        
-    nativeAd.load();
+  initNativeAd(){   
     // 原生广告2.0
     let adParams = {
       adUnitId: '805a483bc3b14205a1d160cb97d0eca0', // 原生广告2.0广告位id
       type: 'native',          // 原生广告2.0广告类型 
-      adCount: 2,              // 原生广告2.0广告预期返回广告条数   
+      adCount: 1,              // 原生广告2.0广告预期返回广告条数   
     }
-    ad.preloadAd({
+    var native = require('@service.ad').preloadAd({
       ...adParams,
       success: (data) => {
-        this.adList = data.adList
+        this.adList = data.adList[0]
         console.log('data',data)
-        // prompt.showToast({
-        //   message: `success! data=${JSON.stringify(data)}`
-        // })
       }, fail: (data, code) => {
         console.log(data, code)
-        // prompt.showToast({
-        //   message: `fail! data=${JSON.stringify(data)}, code=${code}`
-        // })
       }
     })
-  },
-  splashswitch(isOpen) {
-    	let result = ad.setSplashedSwitch({switch: isOpen})
-      setTimeout(()=>{
-        prompt.showToast({ message: result });
-      },5000)
-      // 获取开屏广告信息
-      this.getsplashAdInfo()
-  	},
-  	getsplashswitch() {
-    	// let switch = ad.splashAdSwitch()
-  	},
-  getsplashAdInfo() {
-    ad.getSplashAdInfo({
-      	success: function (data) {
-        	prompt.showToast({message: 'splashAd :' + JSON.stringify(data)})
-      	},
-      	fail: function (data, code) {
-        	prompt.showToast({message: 'splashAd :' + JSON.stringify(data)})
-      	}
-    })
+    // 使用广告管理器预加载原生广告
+    // adManager.preloadNativeAd((success, adData) => {
+    //   if (success && adData) {
+    //     this.adList = adData
+    //     console.log('原生广告数据设置成功:', this.adList)
+    //   } else {
+    //     console.log('原生广告加载失败,使用默认数据')
+    //     // 可以设置一些默认的广告数据用于测试
+    //     this.adList = {
+    //       adId: 'test_ad_id',
+    //       title: '测试广告标题',
+    //       desc: '这是一个测试广告描述',
+    //       clickBtnTxt: '点击查看',
+    //       creativeType: 2,
+    //       imgUrlList: ['https://via.placeholder.com/300x200']
+    //     }
+    //   }
+    // })
   },
   initAd() {
     try {
@@ -260,8 +282,8 @@ export default {
 .tab-bar {
   background-color: @white;
   .border-top-mixins();
-  padding: 15px 0;
-  height: 110px;
+  padding: 15px 0 115px;
+  /* height: 110px; */
   .tab-item {
     flex: 1;
     .flex-box-mixins(column, center, center);
@@ -284,4 +306,5 @@ export default {
     }
   }
 }
+
 </style>

+ 17 - 2
src/pages/tools/shengBoChuChen/index.ux

@@ -42,13 +42,28 @@ export default {
       open: false,
       statusNum: 0,
       firstClick: true,
-      timer: null
+      timer: null,
+      adUnitId: "6f2e50489ff74bae800ce65c992bfec0", // 这个id是vivo的com.quickapp.center创建的,需要修改manifest的package才能预览出效果
+      ad: null
     }
   },
 
   onInit() {
+    this.initAd()
   },
-
+   initAd() {      
+      try {        
+        this.ad = require('@service.ad').createNativeAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+          adUnitId: this.adUnitId,
+        })        
+        this.ad.onLoad((data) => {          
+          console.log('Native ad resources!', data); // 广告加载成功,返回原生广告资源,根据但是资源自行渲染展现
+        })        
+        this.ad.load();
+      } catch (e) {        
+        console.log(e);
+      }
+    },
   onDestroy() {
     // 组件销毁时清除定时器
     if (this.timer) {

+ 3 - 1
src/pages/tools/wangLuoXinXi/index.ux

@@ -47,6 +47,8 @@ import device from '@system.device'
 import telecom from '@system.telecom'
 import geolocation from '@system.geolocation'
 import fetch from '@system.fetch'
+import prompt from '@system.prompt'
+import ad from '@service.ad'
 export default {
   private: {
     title: '欢迎体验快应用开发',
@@ -95,7 +97,7 @@ export default {
         console.log(`handling fail, code = ${code}, errorMsg=${data}`)
       }
     })
-  }
+  },
 }
 </script>
 

+ 19 - 9
src/pages/tools/yiJianShengDian/index.ux

@@ -49,25 +49,35 @@ export default {
       powerNum: 90,
       chartCategories: ["待机", "上网", "导航", "影片", "音乐", "打电话", "游戏"],
       chartData: [66, 36, 31, 33, 13, 34, 10],
-       adUnitId: "6f2e50489ff74bae800ce65c992bfec0", // 这个id是vivo的com.quickapp.center创建的,需要修改manifest的package才能预览出效果
+       adUnitId: "6bd7f72fb64249bda8770adc0619d0cc", // 这个id是vivo的com.quickapp.center创建的,需要修改manifest的package才能预览出效果
         ad: null
     }
   },
 
   onInit() {
-     
+     this.initAd()
   },
    initAd() {      
-      try {        
-        this.ad = require('@service.ad').createNativeAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+      // try {        
+      //   this.ad = require('@service.ad').createNativeAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+      //     adUnitId: this.adUnitId,
+      //   })        
+      //   this.ad.onLoad((data) => {          
+      //     console.log('Native ad resources!', data); // 广告加载成功,返回原生广告资源,根据但是资源自行渲染展现
+      //   })        
+      //   this.ad.load();
+      // } catch (e) {        
+      //   console.log(e);
+      // }
+       try {        
+        this.ad = require('@service.ad').createInterstitialAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
           adUnitId: this.adUnitId,
         })        
-        this.ad.onLoad((data) => {          
-          console.log('Native ad resources!', data); // 广告加载成功,返回原生广告资源,根据但是资源自行渲染展现
-        })        
-        this.ad.load();
+        this.ad.onLoad(() => {          
+          this.ad.show();
+        })
       } catch (e) {        
-        console.log(e);
+        console.log(e)
       }
     },
   onShow() {