Commit 4bbe2fb92895250ad002f965a6e4a800488c6f86

Authored by yvan.ni
1 parent d855bea0

全屏广告的控制

pages/index/index/full_screen.js 0 → 100644
  1 + module.exports = {
  2 + //判断要不要显示全屏广告
  3 + get_the_full_screen(th){
  4 + var stoid=getApp().globalData.setting.stoid;
  5 + if(th.data.full_ad) {
  6 + return false;
  7 + }
  8 + //获取全屏的广告
  9 + getApp().promiseGet("/api/weshop/ad/page?pid=1001&store_id=" + stoid,{
  10 + data: { enabled: 1 }
  11 + }).then(res=>{
  12 + //判断是不是有全屏广告
  13 + if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){
  14 + th.setData({
  15 + is_full_screen_show:1,
  16 + full_ad:res.data.data.pageData[0],
  17 + })
  18 + //--定时关闭--
  19 + th.data.full_screen=setInterval(function(){
  20 + if(!th.data.sec_show) {
  21 + clearInterval(th.data.full_screen);
  22 + th.close_full_screen();
  23 + return false;
  24 + }
  25 + th.data.sec_show--;
  26 + th.setData({sec_show:th.data.sec_show});
  27 + },1000)
  28 + }
  29 + })
  30 + }
  31 +}
0 32 \ No newline at end of file
... ...
pages/index/index/index.js
... ... @@ -15,6 +15,7 @@ var regeneratorRuntime = require('../../../utils/runtime.js');
15 15 var api = require('../../../api/api.js');
16 16 var d = getApp().globalData;
17 17  
  18 +var full_screen = require('full_screen.js');
18 19  
19 20 Page({
20 21 data: {
... ... @@ -75,13 +76,17 @@ Page({
75 76  
76 77 showHongbao: false,
77 78 showHongbaoSmall: false,
78   -
  79 +
  80 + is_full_screen_show:0, //全屏显示
  81 + sec_show:3, //倒计时的秒数
  82 + full_ad:null, //全屏广告
  83 + full_screen:0, //全屏广告
  84 +
79 85 },
80 86  
81 87 onLoad: async function(tt) {
82 88 console.log("进入首页-------------");
83   - console.log(tt);
84   -
  89 + console.log(tt);
85 90 var th = this;
86 91 var first_leader=tt.first_leader;
87 92 if(!first_leader && tt.scene){
... ... @@ -97,7 +102,7 @@ Page({
97 102 getApp().globalData.guide_id=res.data.data.id;
98 103 }
99 104 })
100   - }
  105 + }
101 106  
102 107 // 判断是否有红包活动
103 108 getApp().request.promiseGet('/api/weshop/redmoney/redConfig/get/'+getApp().globalData.setting.stoid, {
... ... @@ -146,7 +151,6 @@ Page({
146 151  
147 152 await this.init_load();
148 153  
149   -
150 154 //显示的时候要开启计时器
151 155 this.data.is_timer = 1;
152 156 //如果是自定义模板
... ... @@ -255,9 +259,8 @@ Page({
255 259 if(!userInfo || !userInfo.user_id) userInfo=null;
256 260 //有加载过一次首页,就显示
257 261 if(show || userInfo || getApp().globalData.user_id){
258   - setTimeout(function(){
259   - var full_screen = th.selectComponent("#full_screen"); //组件的id
260   - full_screen.get_the_full_screen();
  262 + setTimeout(function(){
  263 + full_screen.get_the_full_screen(th);
261 264 },800)
262 265 //动画效果
263 266 if(!th.data.f_hidden){
... ... @@ -282,6 +285,8 @@ Page({
282 285 this.data.is_timer = 0;
283 286 clearInterval(this.data.pt_timer);
284 287 clearInterval(this.data.w_holiday_pop);
  288 + clearInterval(this.data.full_screen);
  289 +
285 290 this.data.w_holiday_pop=0;
286 291 for(var i = 1; i < 100; i++) {
287 292 clearInterval(i);
... ... @@ -1005,5 +1010,17 @@ Page({
1005 1010 showHongbaoSmall: true, //显示抢红包小图标
1006 1011 });
1007 1012 },
  1013 +
  1014 + /*-- 全屏广告 --*/
  1015 + close_full_screen(){
  1016 + this.setData({is_full_screen_show:0,sec_show:0});
  1017 + },
  1018 + //-- 跳转到满屏广告的链接 --
  1019 + go_full_ad(){
  1020 + if(!this.data.full_ad) return false;
  1021 + if(!this.data.full_ad.ad_weapplink) return false;
  1022 + getApp().goto(this.data.full_ad.ad_weapplink);
  1023 + this.close_full_screen();
  1024 + },
1008 1025  
1009 1026 });
1010 1027 \ No newline at end of file
... ...
pages/index/index/index.wxml
1 1 <!-- <view hidden="{{f_hidden}}" class="full_screen" style="background-color: #fff;"></view> -->
2   -<full_screen id="full_screen"></full_screen>
  2 +<!-- <full_screen id="full_screen"></full_screen> -->
  3 +
  4 +<!-- 全屏控制 -->
  5 +<view wx:if="{{is_full_screen_show}}" class="full_screen" bindtap="go_full_ad" style="background-image: url('{{url+full_ad.ad_code}}');">
  6 + <view catchtap="close_full_screen" class="skip_box">跳过 <text>{{sec_show}}</text></view>
  7 +</view>
  8 +
3 9 <!--普通界面-->
4 10 <wxs module="filter" src="../../../utils/filter.wxs"></wxs>
5 11  
... ...
pages/index/index/index.wxss
... ... @@ -977,3 +977,9 @@ page {
977 977 background-size: 100% 100%;
978 978 background-repeat: no-repeat;
979 979 }
  980 +.skip_box{
  981 + float: right; margin-top: 10rpx; margin-right: 10rpx;
  982 + background-color: gainsboro; width: 120rpx;
  983 + height: 48rpx; font-size: 28rpx; line-height: 48rpx;
  984 + text-align: center; border-radius: 20rpx;
  985 + }
... ...