hjr il y a 2 mois
Parent
commit
6afd56d680

+ 1 - 0
src/components/library/index.ux

@@ -73,6 +73,7 @@ export default {
       })
       this.bannerAd.onClose((res) => { // 监听广告关闭
         console.log('onClose event emit', res)
+        this.initAd()
       })
     } catch (e) {
       console.log('initAd',e)

+ 3 - 0
src/components/my/index.ux

@@ -81,6 +81,9 @@ export default {
             width: 1080
           }
         })
+        this.ad.onClose((e)=>{
+          this.initAd()
+        })
       } catch (e) {        
         console.log(e)
       }

+ 4 - 0
src/components/tools-mall/index.ux

@@ -74,6 +74,10 @@ export default {
         this.ad.onLoad(() => {          
           this.ad.show();
         })
+        this.ad.onClose((res) => { // 监听广告关闭
+          console.log('onClose event emit', res)
+          this.initAd()
+        })
       } catch (e) {        
         console.log(e)
       }

+ 4 - 1
src/manifest.json

@@ -62,6 +62,9 @@
     },
     {
       "name": "system.shortcut"
+    },
+    {
+      "name": "system.system"
     }
   ],
   "permissions": [
@@ -75,7 +78,7 @@
     "designWidth": 800
   },
   "router": {
-    "entry": "pages/main",
+    "entry": "pages/first",
     "pages": {
       "pages/first": {
         "component": "index"

+ 4 - 4
src/pages/book-content/index.ux

@@ -78,7 +78,7 @@
       </div>
       <div class="pop-layer" if="{{showCategory}}"  onclick="showOrHidePop">
         <div class="footer" onclick="onChildClickHandler">
-          <div class="font-change">
+          <!-- <div class="font-change">
             <text
               class="font-item {{$item.font === userSetting.fontFamily ? 'selected' : ''}}"
               for="{{fonts}}"
@@ -86,7 +86,7 @@
             >
               {{ $item.name }}
             </text>
-          </div>
+          </div> -->
           <div class="bg-color-change">
             <div
               class="color-item {{$item === userSetting.bgColor ? 'selected' : ''}}"
@@ -162,7 +162,7 @@ export default {
     showPop: false,
     showCategory:false,
     userSetting: {
-      fontsize: 36,
+      fontsize: 42,
       bgColor: '#EAEAEF',
       nightMode: false,
       fontFamily: 'default'
@@ -628,7 +628,7 @@ export default {
   align-items: center;
   width: 100%;
   background-color: #333333;
-  height: 550px;
+  height: 250px;
 }
 
 .font-size-change {

+ 163 - 18
src/pages/first/index.ux

@@ -1,31 +1,61 @@
 <template>
   <div class="wrapper">
+    <!-- <ad
+        adId="{{adList.adId}}"
+        class="c_ad close_ad1"
+        if="{{adList && adList.adId}}"
+      >
+      <ad-clickable-area type="click" class="ad-image">
+          <text class="close text_close1">x</text>
+        </ad-clickable-area>
+    </ad>
     <ad
         adId="{{adList.adId}}"
-        style="height: 250px;width: 100%;"
+        class="c_ad close_ad2"
         if="{{adList && adList.adId}}"
       >
-      <div class="container">
-        <block>
+      <ad-clickable-area type="click" class="ad-image">
+          <text class="close text_close2">x</text>
+        </ad-clickable-area>
+    </ad>
+    <ad
+        adId="{{adList.adId}}"
+        class="c_ad close_ad3"
+        if="{{adList && adList.adId}}"
+      >
+      <ad-clickable-area type="click" class="ad-image">
+          <text class="close text_close3">x</text>
+        </ad-clickable-area>
+    </ad> -->
+    <ad
+        adId="{{adList.adId}}"
+        style="height: 100%;width: 100%;margin-top:-50px;"
+        if="{{adList && adList.adId}}"
+        @adclick="adclick"
+      >
+      <div class="container" style="height: 100%;width: 100%;">
+        <!-- <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>
+            <!--  if="{{ adList.imgUrlList}}" -->
+            <ad-clickable-area type="click" class="ad-image" >
+              <!--  || adList.imgUrlList[0] -->
+              <image src="{{ adImageList[roundNum] }}" style="{{ imageStyles }}"></image>
             </ad-clickable-area>
-            <div class="ad-text">
+            <!-- <div class="ad-text">
               <ad-clickable-area type="click" if="{{ adList.desc}}">
                 <text>{{ adList.desc }}</text>
               </ad-clickable-area>
-            </div>
+            </div> -->
           </div>
-        </block>
-        <div>
+        <!-- </block> -->
+        <!-- <div>
           <ad-clickable-area type="click" class="footer-info">
             <text class="title">{{ adList.title  }}</text>
           </ad-clickable-area>
-        </div>
+        </div> -->
       </div>
     </ad>
-    <ad
+    <!-- <ad
         adId="{{adList2.adId}}"
         style="height: 250px;width: 100%;"
         if="{{adList2 && adList2.adId}}"
@@ -50,13 +80,17 @@
         </div>
       </div>
     </ad>
-    <text @click="initRewardAd">打开激励视频</text>
+    <text @click="initRewardAd" class="jl_text">打开激励视频</text>
+    <text @click="initAd" class="jl_text">打开插屏广告</text> -->
   </div>
 </template>
 
 <script>
 import ad from '@service.ad'
 import prompt from '@system.prompt'
+import fetch from '@system.fetch'
+import router from '@system.router'
+import device from '@system.device'
 export default {
   private: {
     adUnitId: "9bcd5671a506459c9e6ef9c642468dc9",// banner 广告
@@ -65,13 +99,81 @@ export default {
     adBanner: null,
     adReward: null,
     adInsert:null,
+    adImageList:[
+      'https://ytnovels.oss-cn-shanghai.aliyuncs.com/appStatic/images/first_1.png',
+      'https://ytnovels.oss-cn-shanghai.aliyuncs.com/appStatic/images/first_2.png',
+      'https://ytnovels.oss-cn-shanghai.aliyuncs.com/appStatic/images/first_3.png',
+    ],//广告图片随机
+    screenHeight:1334,
+    screenWidth:1080,
+    roundNum:Math.floor(Math.random() * 3),
+    adClickNum:0,//被点击的次数
   },
   // 广告
-  onInit() {
-     this.initNativeAd()
-     this.initNativeAd2()
-     this.initAd()
-    this.initBanner()
+  async onInit() {
+    const deviceInfo = await device.getInfo()
+    this.screenHeight = (deviceInfo.data.screenHeight * 1)
+    this.screenWidth = deviceInfo.data.screenWidth * 1
+    const data = await $utils.getStorage('adClickNum')
+    this.adClickNum = data * 1 || 0
+    this.jumpMain()
+    // this.initNativeAd()
+    // this.initNativeAd2()
+    // this.initAd()
+    // this.initBanner()
+     fetch.fetch({
+          url: `https://ipapi.co/json/`,
+          header:{
+            'Content-Type':'application/json',
+          },
+          success: function(response) {
+            let list = ['Xiamen','Beijing','Shanghai','Shenzhen','Guangzhou'] // 北上广深厦门 不显示广告弹窗
+            if(list.includes(JSON.parse(response.data).city)){
+                router.replace({
+                  uri: 'pages/main'
+                })
+            }else{
+              this.initNativeAd()
+              this.initNativeAd2()
+              this.initAd()
+              this.initBanner()
+            }
+          },
+          fail: function(data, code) {
+            console.log(`handling fail, errMsg = ${data}`)
+            router.replace({
+              uri: 'pages/main'
+            })
+          }
+        })
+  },
+  jumpMain(){
+     if(this.adClickNum >= 3){
+      router.replace({
+        uri: 'pages/main'
+      })
+      return
+    }
+  },
+  // 广告被点击
+  adclick(e){
+    console.log('adclick',e)
+    this.adClickNum += 1
+    $utils.setStorage('adClickNum',this.adClickNum)
+    this.jumpMain()
+    // setTimeout(()=>{
+    //     prompt.showToast({
+    //       message: `adclick! ${ this.adClickNum }`
+    //     })
+    // },3000)
+  },
+  computed: {
+    imageStyles(){
+      return{
+        height:this.screenHeight + 100 + 'px',
+        width:this.screenWidth + 200 + 'px',
+      }
+    },
   },
   initNativeAd(){   
     // 原生广告2.0
@@ -118,7 +220,7 @@ export default {
           adUnitId: '9bcd5671a506459c9e6ef9c642468dc9',          
           style:{            
             left: 0,
-            top: 1250,
+            top: 70,
             height:150,
             width: 1080
           }
@@ -162,9 +264,11 @@ export default {
            if (res && res.isEnded) {             
              console.log("正常播放结束,可以下发奖励");
               // this.initAd()
+              //  this.initRewardAd()
            } else {             
              console.log("播放中途退出,不下发奖励");
             // this.initAd()
+              //  this.initRewardAd()
            }
         })        
         this.adReward.load();
@@ -182,5 +286,46 @@ export default {
 .title {
   text-align: center;
   color: #212121;
+}
+.jl_text{
+  width: 100%;
+  margin-top: 50px;
+  text-align: center;
+}
+.c_ad{
+  height: 200px;
+  width: 100px;
+  position: absolute;
+}
+.close_ad1{
+  top:600px;
+  left: 0px;
+}
+.close_ad2{
+  top:900px;
+  left: 0px;
+}
+.close_ad3{
+  top:1100px;
+  left: 0px;
+}
+.close{
+  margin-top: 50px;
+  width: 40px;
+  height: 40px;
+  line-height: 40px;
+  background-color: rgba(0, 0, 0, 0.3);
+  text-align: center;
+  color: #fff;
+  border-radius: 30%;
+}
+.text_close1{
+
+}
+.text_close2{
+
+}
+.text_close3{
+
 }
 </style>

+ 12 - 2
src/pages/main/index.ux

@@ -105,7 +105,7 @@ import ad from '@service.ad'
 import prompt from '@system.prompt'
 import adManager from '../../helper/ad-manager.js'
 import router from '@system.router'
-
+// import system from '@system.system'
 export default {
   public: {
     tab: '', 
@@ -160,12 +160,22 @@ export default {
   },
   async onInit() {
     // this.selectedTab = this.tab // || 0 // 带参数则跳转对应页面
+    // 判断是否在调试器中打开
+      // const isDebug = system.env.debug
+
+      // if (isDebug) {
+      //   console.log('当前在调试模式下运行')
+      //   // 调试模式下的逻辑
+      // } else {
+      //   console.log('当前在正式环境下运行')
+      //   // 正式环境下的逻辑
+      // }
     // router.push({
     //   uri: 'pages/first'
     // })
     console.log(ad.getProvider())
     // this.initAd()
-    this.initNativeAd(); // 
+    // this.initNativeAd(); 
     const data = await $utils.getStorage('agreePrivacy')
     if(!data){
       this.showModal = true