full_screen.js
2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// components/userqy_pop_up/userqy_pop_up.js
var o = getApp().globalData.setting
Component({
/**
* 页面的初始数据
*/
data: {
control: 1,
is_full_screen_show:0, //全屏显示
sec_show:3, //倒计时的秒数
full_ad:null, //全屏广告
url:o.imghost,
full_screen:0,
},
pageLifetimes:{
//要处理一下,游客登录后的界面的变化,主要还该是改变会员
show: function () {
var th=this;
th.setData({sec_show:3});
//--如果有全屏广告的时候--
if(this.data.is_full_screen_show){
//--定时关闭--
th.data.full_screen=setInterval(function(){
if(!th.data.sec_show) {
clearInterval(th.data.full_screen);
th.close_full_screen();
return false;
}
th.data.sec_show--;
th.setData({sec_show:th.data.sec_show});
},1000)
}
},
hide: function() {
// 页面被隐藏
clearInterval(this.data.full_screen);
},
},
properties: {
},
ready: function () {
this.get_the_full_screen();
},
methods: {
close_full_screen(){
this.setData({is_full_screen_show:0,sec_show:0});
},
//-- 跳转到满屏广告的链接 --
go_full_ad(){
if(!this.data.full_ad) return false;
if(!this.data.full_ad.ad_weapplink) return false;
getApp().goto(this.data.full_ad.ad_weapplink);
this.setData({is_full_screen_show:0});
},
get_the_full_screen(){
var th=this;
//获取全屏的广告
getApp().request.promiseGet("/api/weshop/ad/page?pid=1001&store_id=" + o.stoid,{
data: { enabled: 1 }
}).then(res=>{
//判断是不是有全屏广告
if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){
th.setData({
is_full_screen_show:1,
full_ad:res.data.data.pageData[0]
})
//--定时关闭--
th.data.full_screen=setInterval(function(){
if(!th.data.sec_show) {
clearInterval(th.data.full_screen);
th.close_full_screen();
return false;
}
th.data.sec_show--;
th.setData({sec_show:th.data.sec_show});
},1000)
}
})
}
},
})