hjr пре 1 месец
родитељ
комит
aebd0f65e4

+ 7 - 1
package-lock.json

@@ -8,7 +8,8 @@
       "name": "quickapp-code-books",
       "version": "1.0.0",
       "dependencies": {
-        "apex-ui": "latest"
+        "apex-ui": "latest",
+        "ylh-quick-app-ad-sdk": "^1.7.1070"
       },
       "devDependencies": {
         "@types/quickapp": "npm:quickapp-interface@^1.0.0",
@@ -7690,6 +7691,11 @@
         "node": ">= 6"
       }
     },
+    "node_modules/ylh-quick-app-ad-sdk": {
+      "version": "1.7.1070",
+      "resolved": "https://registry.npmmirror.com/ylh-quick-app-ad-sdk/-/ylh-quick-app-ad-sdk-1.7.1070.tgz",
+      "integrity": "sha512-aygRuMbdif2BTC86LXy+7fWw1t6oXlt5lDZHIlEtTZNjOLCBruJStSOyzbb3Jx3q9n9knbNEAYNDC+zzicoHVA=="
+    },
     "node_modules/yocto-queue": {
       "version": "0.1.0",
       "resolved": "https://registry.npmmirror.com/yocto-queue/-/yocto-queue-0.1.0.tgz",

+ 2 - 1
package.json

@@ -15,7 +15,8 @@
     "prettier-watch": "onchange '**/*.md' \"src/**/**/*.{js,ux,less,scss,css}\" -- prettier --write {{changed}}"
   },
   "dependencies": {
-    "apex-ui": "latest"
+    "apex-ui": "latest",
+    "ylh-quick-app-ad-sdk": "^1.7.1070"
   },
   "devDependencies": {
     "@types/quickapp": "npm:quickapp-interface@^1.0.0",

+ 16 - 2
src/components/addDesktop.ux

@@ -1,7 +1,7 @@
 <template>
   <div class="fab-btn" style="bottom: {{ bottom }}px;" @click="onTap">
     <slot>
-      <text style="color: #fff;font-size: 34px;">添加至桌面,天天领签到红包</text>
+      <text style="color: #fff;font-size: 30px;">添加至桌面,天天领签到红包</text>
           <!-- <text style="font-size: 32px;color: #fff;">+</text>
           <text style="font-size: 18px;color: #fff;">添加桌面</text> -->
     </slot>
@@ -11,6 +11,7 @@
 <script>
 import router from '@system.router'
 import shortcut from '@system.shortcut'
+import device from '@system.device'
 export default {
   props: {
     bottom:{
@@ -27,6 +28,19 @@ export default {
       success: function(e) {
         console.log('handling success',e)
         $utils.showToast('添加成功')
+         device.getDeviceId({
+            success: function(data) {
+              console.log(`handling success: ${data.deviceId}`)
+              //设备唯一标识。在 Android 上返回 IMEI 或 MEID; 在 Android Q 之后,除了华为手机返回 aaid(应用匿名设备标识符),
+              // 其他厂商手机如果支持 oaid(匿名设备标识符)则返回 oaid,否则返回空值。
+              $apis.common.vivoUpload({sign: data.deviceId, type: 2}).then(res=>{
+                console.log('res',res)
+              })
+            },
+            fail: function(data, code) {
+              console.log(`handling fail, code = ${code}`)
+            }
+          })
       },
       fail: function(data, code) {
         console.log(`handling fail, code = ${code}, errorMsg=${data}`)
@@ -53,7 +67,7 @@ export default {
   bottom: 50px;
   left: 120px;
   width: 600px;
-  height: 90px;
+  height: 80px;
   flex-direction: column;
   background-color: #db3f3f;
   /* background-color: #399bfc; */

+ 8 - 0
src/helper/apis/common.js

@@ -3,6 +3,10 @@ export default {
   // getPositionByLocation(data) {
   //   return $ajax.get('https://apis.map.qq.com/ws/geocoder/v1/', data)
   // },
+  // 上报用户行为给vivo官方
+  vivoUpload(data) {
+    return $ajax.post('vivoAd/vivoUpload', data)
+  },
   // 首页轮播图
   novelBanner(data) {
     return $ajax.post('novelBanner/page', data)
@@ -35,4 +39,8 @@ export default {
   ytNovelLinkDetail(data) {
     return $ajax.get('ytNovelLink/detail', data)
   },
+  /** 是否屏蔽书架页 / 现在后台是境外IOS广告设置 */
+  getConfig(data) {
+    return $ajax.post('sysConfig/getConfig', data)
+  },
 }

+ 66 - 2
src/pages/book-content/index.ux

@@ -157,6 +157,7 @@ export default {
     screenWidth: 720,
     pages: [], // 分页后的内容数组
     currentPage: 1, // 当前页码
+    adPage:0,// 广告页码 每两页一次
     content: '',// 完整小说内容
     chapterTitle: '',
     showPop: false,
@@ -169,6 +170,9 @@ export default {
     },
     colors: ['#EAEAEF', '#FAF9DE', '#E3EDCD', '#DCE2F1', '#FFF2E2'],
     bannerAd: null,
+    adInsert:null,
+    adReward:null,
+    isCloseReward:false,
     ad: null,
     fonts: [
       {
@@ -217,10 +221,22 @@ export default {
   async onInit() {
     var that = this
     const deviceInfo = await device.getInfo()
-      console.log('deviceInfo',deviceInfo)
+    console.log('deviceInfo',deviceInfo)
     this.screenHeight = (deviceInfo.data.screenHeight * 1) || 1100
     this.screenWidth = deviceInfo.data.screenWidth * 1
-
+    device.getDeviceId({
+      success: function(data) {
+        console.log(`handling success: ${data.deviceId}`)
+        //设备唯一标识。在 Android 上返回 IMEI 或 MEID; 在 Android Q 之后,除了华为手机返回 aaid(应用匿名设备标识符),
+        // 其他厂商手机如果支持 oaid(匿名设备标识符)则返回 oaid,否则返回空值。
+        $apis.common.vivoUpload({sign: data.deviceId, type: 1}).then(res=>{
+          console.log('res',res)
+        })
+      },
+      fail: function(data, code) {
+        console.log(`handling fail, code = ${code}`)
+      }
+    })
     this.initAd()
     setTimeout(()=>{
         if(this.bannerAd) {        
@@ -271,6 +287,44 @@ export default {
       console.log('initAd',e)
     }
   },
+  initInsertAd() {
+       try {        
+        this.adInsert = require('@service.ad').createInterstitialAd({  // 使用require方式避免在不支持的广告接口的厂商运行是报错
+          adUnitId: '6bd7f72fb64249bda8770adc0619d0cc',
+        })        
+        this.adInsert.onLoad(() => {          
+          this.adInsert.show();
+        })
+        this.adInsert.onClose((e)=>{
+          console.log('关闭')
+        })
+      } 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("正常播放结束,可以下发奖励");
+           } else {             
+             console.log("播放中途退出,不下发奖励");
+             this.isCloseReward = true
+             this.initInsertAd()
+           }
+        })        
+        this.adReward.load();
+      } catch (e) {        
+        console.log(e)
+        this.initInsertAd()
+      }
+    },
   // 解析TXT文件的主方法
   getTxtContent(url) {
     console.log('url',url)
@@ -493,6 +547,16 @@ export default {
   },
   onSwiperChange(evt) {
     this.currentPage = evt.index + 1;
+    if(this.currentPage % 2 == 0){
+      console.log('this.currentPage % 2 == 0')
+      // 激励广告
+      // if(!this.isCloseReward){
+        this.initRewardAd()
+      // }else{
+      //   this.adInsert = null
+      //   this.initInsertAd()
+      // }
+    }
   }
 }
 </script>

+ 109 - 108
src/pages/first/index.ux

@@ -1,32 +1,5 @@
 <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}}"
-        class="c_ad close_ad2"
-        if="{{adList && adList.adId}}"
-      >
-      <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;"
@@ -34,54 +7,15 @@
         @adclick="adclick"
       >
       <div class="container" style="height: 100%;width: 100%;">
-        <!-- <block> -->
-          <div class="vertical-content big-img">
-            <!--  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">
-              <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 type="click" class="ad-image" >
+              <image src="{{ adList.imgUrlList&&adList.imgUrlList[0] || adImageList[roundNum] }}" style="{{ imageStyles }}"></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" class="jl_text">打开激励视频</text>
-    <text @click="initAd" class="jl_text">打开插屏广告</text> -->
   </div>
 </template>
 
@@ -95,7 +29,6 @@ export default {
   private: {
     adUnitId: "9bcd5671a506459c9e6ef9c642468dc9",// banner 广告
     adList: {},
-    adList2: {},
     adBanner: null,
     adReward: null,
     adInsert:null,
@@ -108,56 +41,144 @@ export default {
     screenWidth:1080,
     roundNum:Math.floor(Math.random() * 3),
     adClickNum:0,//被点击的次数
+    clickEvent:"11",
+    onloadEvent:'14',
+    clickid:'',
+    isBlockIp:true,// 是否屏蔽iP地址
+    isBlockDev:true,//是否屏蔽调试器
   },
   // 广告
   async onInit() {
+    // console.log('global.__env__',global)
+    // console.log('global.__env__',JSON.stringify(this.$page.query))
+    // 自归因 上报监测 clickId 
+    // this.clickid = this.$page.query.CLICK_ID || this.$page.query.CLICKID
+    // 获取设备唯一标识。需要用户授权
+    // device.getSerial({
+    //   success: function(data) {
+    //     console.log(`handling success: ${data.serial}`)
+    //     prompt.showToast({
+    //       message: `serial${ data.serial }`
+    //     })
+    //   },
+    //   fail: function(data, code) {
+    //     console.log(`handling fail, code = ${code}`)
+    //     device.getOAID({
+    //       success: function(data) {
+    //         console.log(`handling success: ${data.oaid}`)
+    //         prompt.showToast({
+    //           message: `oaid${ data.oaid }`
+    //         })
+    //       },
+    //       fail: function(data, code) {
+    //         console.log(`handling fail, code = ${code}`)
+    //       }
+    //     })
+    //   }
+    // })
+    device.getDeviceId({
+      success: function(data) {
+        console.log(`handling success: ${data.deviceId}`)
+        // prompt.showToast({
+        //   message: `deviceId${ data.deviceId }`
+        // })
+        //设备唯一标识。在 Android 上返回 IMEI 或 MEID; 在 Android Q 之后,除了华为手机返回 aaid(应用匿名设备标识符),
+        // 其他厂商手机如果支持 oaid(匿名设备标识符)则返回 oaid,否则返回空值。
+        $apis.common.vivoUpload({sign: data.deviceId, type: 1}).then(res=>{
+          console.log('res',res)
+        })
+      },
+      fail: function(data, code) {
+        console.log(`handling fail, code = ${code}`)
+      }
+    })
     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({
+  },
+  // 检测用户是否在特定区域中 如果在则不显示广告页内容
+  async areaJudge(){
+     var that = this
+     const isSpecialArea = await $utils.getStorage('isSpecialArea')
+      // prompt.showToast({
+      //     message: `isSpecialArea - ${ isSpecialArea } -isBlockIp ${this.isBlockIp} `
+      //   })
+     // 第一次进未请求判断地区的  且 后台配置是需要屏蔽对应Ip地址
+     if(isSpecialArea === '' && this.isBlockIp){
+       fetch.fetch({
           url: `https://ipapi.co/json/`,
           header:{
             'Content-Type':'application/json',
           },
           success: function(response) {
-            let list = ['Xiamen','Beijing','Shanghai','Shenzhen','Guangzhou'] // 北上广深厦门 不显示广告弹窗
+            console.log('response',JSON.parse(response.data).city)
+            // prompt.showToast({
+            //   message: `${ JSON.parse(response.data).city }`
+            // })
+            let list = ['Xiamen','Beijing','Shanghai','Shenzhen','Guangzhou'] // 北上广深厦门 不显示广告弹窗 
             if(list.includes(JSON.parse(response.data).city)){
+                $utils.setStorage('isSpecialArea',true)
                 router.replace({
                   uri: 'pages/main'
                 })
             }else{
-              this.initNativeAd()
-              this.initNativeAd2()
-              this.initAd()
-              this.initBanner()
+              $utils.setStorage('isSpecialArea',false)
+              that.initNativeAd()
+              that.initAd()
+              that.initBanner()
             }
           },
           fail: function(data, code) {
             console.log(`handling fail, errMsg = ${data}`)
+            $utils.setStorage('isSpecialArea',true)
             router.replace({
               uri: 'pages/main'
             })
           }
         })
+     }else if(isSpecialArea === 'false' || !this.isBlockIp){ // 不属于禁用IP地址 或者是接口中不屏蔽IP地址 展示广告
+        that.initNativeAd()
+        that.initAd()
+        that.initBanner()
+     }else{  // isSpecialArea === 'true'
+       router.replace({
+          uri: 'pages/main'
+        })
+     }
   },
   jumpMain(){
-     if(this.adClickNum >= 3){
-      router.replace({
-        uri: 'pages/main'
+      $apis.common.getConfig().then(res=>{
+        console.log('res',res)
+        if(res.data.status == 0){ // 屏蔽IP地址
+          this.isBlockIp = false
+        }
+        if(res.data.status == 0){ // 屏蔽调试器
+          this.isBlockDev = false
+        }
+        let devList = ['log','debug'] // 
+        if(this.adClickNum >= 3 || (devList.includes(global.Env.logLevel) && this.isBlockDev)){ // 点击广告次数 >= 3 次 或者是调试器登录时直接跳过广告
+          router.replace({
+            uri: 'pages/main'
+          })
+          return
+        }else{
+          this.areaJudge()
+        }
       })
-      return
-    }
   },
   // 广告被点击
   adclick(e){
     console.log('adclick',e)
+    this.clickEvent = JSON.stringify(e)
+    // setTimeout(()=>{
+    //     prompt.showToast({
+    //       // message: `adclick! ${ JSON.stringify(e) }`
+    //       message: `adclick! ${ JSON.stringify(this.$page.query) }`
+    //     })
+    // },3000)
     this.adClickNum += 1
     $utils.setStorage('adClickNum',this.adClickNum)
     this.jumpMain()
@@ -170,8 +191,9 @@ export default {
   computed: {
     imageStyles(){
       return{
-        height:this.screenHeight + 100 + 'px',
-        width:this.screenWidth + 200 + 'px',
+        height:this.screenHeight  + 'px',
+        width:this.screenWidth+ 'px',
+        objectFit:'fill'
       }
     },
   },
@@ -186,34 +208,13 @@ export default {
       ...adParams,
       success: (data) => {
         this.adList = data.adList[0]
+        this.onloadEvent = JSON.stringify(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方式避免在不支持的广告接口的厂商运行是报错

+ 54 - 22
src/pages/main/index.ux

@@ -35,14 +35,6 @@
             <!-- <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>
@@ -51,13 +43,14 @@
         <bookshelf
           shelf-list="{{shelfList}}"
           onupdate-shelf="updateShelf"
+          if="{{ !isBlock }}"
         ></bookshelf>
-        <library></library>
+        <library if="{{ !isBlock }}"></library>
         <!-- <search-book></search-book> -->
         <weather></weather>
         <calendar></calendar>
         <!-- if="{{ brand == 'vivo' }}" -->
-        <tools-mall></tools-mall>
+        <tools-mall  if="{{ !isBlock }}"></tools-mall>
         <my></my>
       </tab-content>
       <tab-bar mode="fixed" class="tab-bar">
@@ -148,6 +141,7 @@ export default {
         activatedIcon: '\ue602'
       }
     ],
+    isBlock:false, // 是否屏蔽书架书城
     selectedTab: 0,
     defaultShelfList: [],//bookListData.slice(0, 2),
     shelfList: [],
@@ -157,25 +151,63 @@ export default {
     adUnitId: "9bcd5671a506459c9e6ef9c642468dc9",// banner 广告
     adList: {},
     ad: null,
+    clickid:'',
   },
   async onInit() {
     // this.selectedTab = this.tab // || 0 // 带参数则跳转对应页面
-    // 判断是否在调试器中打开
-      // const isDebug = system.env.debug
-
-      // if (isDebug) {
-      //   console.log('当前在调试模式下运行')
-      //   // 调试模式下的逻辑
-      // } else {
-      //   console.log('当前在正式环境下运行')
-      //   // 正式环境下的逻辑
-      // }
-    // router.push({
-    //   uri: 'pages/first'
+    // 获取后台配置 判断是否屏蔽小说/工具页面
+    $apis.common.getConfig().then(res=>{
+      console.log('res',res)
+      if(res.data.status == 1){ // 屏蔽书架/书城
+        this.isBlock = true
+        this.tabList.splice(0,2)
+        this.tabList.splice(2,1)
+      }
+    })
+    // 获取设备唯一标识。需要用户授权
+    device.getDeviceId({
+      success: function(data) {
+        console.log(`handling success: ${data.deviceId}`)
+          // prompt.showToast({
+          //   message: `deviceId :${ data.deviceId }`
+          // })
+        //设备唯一标识。在 Android 上返回 IMEI 或 MEID; 在 Android Q 之后,除了华为手机返回 aaid(应用匿名设备标识符),
+        // 其他厂商手机如果支持 oaid(匿名设备标识符)则返回 oaid,否则返回空值。
+        // $apis.common.vivoUpload({sign: data.deviceId, type: 1}).then(res=>{
+        //   console.log('res',res)
+        // })
+      },
+      fail: function(data, code) {
+        console.log(`handling fail, code = ${code}`)
+      }
+    })
+    // device.getSerial({
+    //   success: function(data) {
+    //     console.log(`handling success: ${data.serial}`)
+    //     prompt.showToast({
+    //       message: `serial :${ data.serial }`
+    //     })
+    //   },
+    //   fail: function(data, code) {
+    //     console.log(`handling fail, code = ${code}`)
+    //     device.getOAID({
+    //       success: function(data) {
+    //         console.log(`handling success: ${data.oaid}`)
+    //         prompt.showToast({
+    //           message: `oaid :${ data.oaid }`
+    //         })
+    //       },
+    //       fail: function(data, code) {
+    //         console.log(`handling fail, code = ${code}`)
+    //       }
+    //     })
+    //   }
     // })
     console.log(ad.getProvider())
     // this.initAd()
     // this.initNativeAd(); 
+    // 自归因 上报监测 clickId 
+    this.clickid = this.$page.query.CLICK_ID || this.$page.query.CLICKID
     const data = await $utils.getStorage('agreePrivacy')
     if(!data){
       this.showModal = true