Commit d9720f654f3c1d5e91b476b34ad97a58cf91dc94

Authored by yvan.ni
1 parent c84026a4

全屏广告的优化

components/full_screen/full_screen.js
1 // components/userqy_pop_up/userqy_pop_up.js 1 // components/userqy_pop_up/userqy_pop_up.js
  2 +var o = getApp().globalData.setting
2 Component({ 3 Component({
3 /** 4 /**
4 * 页面的初始数据 5 * 页面的初始数据
@@ -8,27 +9,53 @@ Component({ @@ -8,27 +9,53 @@ Component({
8 is_full_screen_show:0, //全屏显示 9 is_full_screen_show:0, //全屏显示
9 sec_show:3, //倒计时的秒数 10 sec_show:3, //倒计时的秒数
10 full_ad:null, //全屏广告 11 full_ad:null, //全屏广告
  12 + url:o.imghost,
  13 + full_screen:0,
11 }, 14 },
12 15
  16 + pageLifetimes:{
  17 + //要处理一下,游客登录后的界面的变化,主要还该是改变会员
  18 + show: function () {
  19 + var th=this;
  20 + th.setData({sec_show:3});
  21 + //--如果有全屏广告的时候--
  22 + if(this.data.is_full_screen_show){
  23 + //--定时关闭--
  24 + th.data.full_screen=setInterval(function(){
  25 + if(!th.data.sec_show) {
  26 + clearInterval(th.data.full_screen);
  27 + th.close_full_screen();
  28 + return false;
  29 + }
  30 + th.data.sec_show--;
  31 + th.setData({sec_show:th.data.sec_show});
  32 + },1000)
  33 + }
  34 + },
  35 + hide: function() {
  36 + // 页面被隐藏
  37 + clearInterval(this.data.full_screen);
  38 + },
  39 + },
  40 +
13 properties: { 41 properties: {
14 42
15 }, 43 },
16 ready: function () { 44 ready: function () {
17 - 45 + this.get_the_full_screen();
18 }, 46 },
19 -  
20 methods: { 47 methods: {
21 close_full_screen(){ 48 close_full_screen(){
22 - this.setData({is_full_screen_show:0}); 49 + this.setData({is_full_screen_show:0,sec_show:0});
23 }, 50 },
24 - //跳转到满屏广告的链接 51 + //-- 跳转到满屏广告的链接 --
25 go_full_ad(){ 52 go_full_ad(){
26 - if(!full_ad) return false;  
27 - if(!full_ad.ad_weapplink) return false;  
28 - getApp().goto(full_ad.ad_weapplink);  
29 - },  
30 -  
31 - get_the_full_screen(){ 53 + if(!this.data.full_ad) return false;
  54 + if(!this.data.full_ad.ad_weapplink) return false;
  55 + getApp().goto(this.data.full_ad.ad_weapplink);
  56 + this.setData({is_full_screen_show:0});
  57 + },
  58 + get_the_full_screen(){
32 var th=this; 59 var th=this;
33 //获取全屏的广告 60 //获取全屏的广告
34 getApp().request.promiseGet("/api/weshop/ad/page?pid=1001&store_id=" + o.stoid,{ 61 getApp().request.promiseGet("/api/weshop/ad/page?pid=1001&store_id=" + o.stoid,{
@@ -40,14 +67,20 @@ Component({ @@ -40,14 +67,20 @@ Component({
40 is_full_screen_show:1, 67 is_full_screen_show:1,
41 full_ad:res.data.data.pageData[0] 68 full_ad:res.data.data.pageData[0]
42 }) 69 })
  70 +
  71 + //--定时关闭--
  72 + th.data.full_screen=setInterval(function(){
  73 + if(!th.data.sec_show) {
  74 + clearInterval(th.data.full_screen);
  75 + th.close_full_screen();
  76 + return false;
  77 + }
  78 + th.data.sec_show--;
  79 + th.setData({sec_show:th.data.sec_show});
  80 + },1000)
43 } 81 }
44 }) 82 })
45 } 83 }
46 -  
47 }, 84 },
48 -  
49 -  
50 85
51 -  
52 -  
53 }) 86 })
54 \ No newline at end of file 87 \ No newline at end of file
components/full_screen/full_screen.wxml
1 <!-- 全屏控制 --> 1 <!-- 全屏控制 -->
2 -<view wx:if="{{is_full_screen_show}}" class="full_screen" bindtap="go_full_ad" style="background-image: url('{{url+full_ad.code}}');">  
3 - <view catchtap="close_full_screen" class="full_show_box">跳过 <text>{{sec_show}}</text></view> 2 +<view wx:if="{{is_full_screen_show}}" class="full_screen" bindtap="go_full_ad" style="background-image: url('{{url+full_ad.ad_code}}');">
  3 + <view catchtap="close_full_screen" class="skip_box">跳过 <text>{{sec_show}}</text></view>
4 </view> 4 </view>
5 5
6 6
components/full_screen/full_screen.wxss
@@ -14,5 +14,5 @@ @@ -14,5 +14,5 @@
14 float: right; margin-top: 10rpx; margin-right: 10rpx; 14 float: right; margin-top: 10rpx; margin-right: 10rpx;
15 background-color: gainsboro; width: 120rpx; 15 background-color: gainsboro; width: 120rpx;
16 height: 48rpx; font-size: 28rpx; line-height: 48rpx; 16 height: 48rpx; font-size: 28rpx; line-height: 48rpx;
17 - text-align: center; border-radius: 10rpx; 17 + text-align: center; border-radius: 20rpx;
18 } 18 }
19 \ No newline at end of file 19 \ No newline at end of file
pages/index/index/index.json
@@ -17,7 +17,8 @@ @@ -17,7 +17,8 @@
17 "picMax": "/components/diy_picMax/diy_picMax", 17 "picMax": "/components/diy_picMax/diy_picMax",
18 "mvideo": "/components/diy_video/diy_video", 18 "mvideo": "/components/diy_video/diy_video",
19 "service": "/components/diy_service/diy_service", 19 "service": "/components/diy_service/diy_service",
20 - "scan": "/components/diy_scan/diy_scan" 20 + "scan": "/components/diy_scan/diy_scan",
  21 + "full_screen": "/components/full_screen/full_screen"
21 }, 22 },
22 "enablePullDownRefresh": false 23 "enablePullDownRefresh": false
23 } 24 }
24 \ No newline at end of file 25 \ No newline at end of file