boost.js
1.64 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
// components/tips/boost.js
const cacheKey='A2L-INDEX'
Component({
/**
* 组件的属性列表
*/
properties: {
},
lifetimes: {
attached: function() {
this.show()
},
},
/**
* 组件的初始数据
*/
data: {
disp:false,
animation:'',
background:[{
url:'http://nosqn.colorcun.com/boots/1.png',
txt:'1.戳选地图上的商家,开始预订',
},{
url:'http://nosqn.colorcun.com/boots/3.png',
txt:'2.搜索商家或位置,开始预订',
}],
},
/**
* 组件的方法列表
*/
methods: {
show(){
wx.getStorage({
key:cacheKey,
fail:()=>{
this.setData({
disp:true,
})
setTimeout(()=>{
this.setData({
animation:'discountShow',
})
},300)
this.triggerEvent('event',{act:'show',txt:'新用户'})
//wx.setStorage({key:cacheKey, data:new Date().toISOString()})
},
success:()=>{
this.triggerEvent('event',{act:'hide',txt:'老用户'})
},
})
},
hide(){
this.setData({
animation:'discountHide',
})
this.triggerEvent('event',{act:'hide',txt:'新用户'})
setTimeout(()=>{
this.setData({
disp:false,
})
},300)
},
hasGoto:false,
bindtransition(e){
console.log(e)
if('change'==e.type){
this.hasGoto=false
}
if('animationfinish'==e.type){
if(this.hasGoto && (e.detail.current+1)==2){
this.hide()
return;
}else{
this.hasGoto=true
}
}
},
}
})