discount.js
1.58 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
// components/reserve/discount.js
import App from '../../../utils/api'
Component({
/**
* 组件的属性列表
*/
properties: {
cla:String,
hasPTactivity:Boolean,//平台红包开启状态
seller:{
type:Object,
value:{}
}
},
/**
* 组件的初始数据
*/
data: {
display:false,
hiddenAni:'',
mycards:[],
money:0,//最大优惠
red_envelopes_price:0,//获得金额
},
lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () {
App.Customer.SetCardRel({
sid:this.data.seller.id
}).then(res=>{
if(!res.data) return;
this.setData({
red_envelopes_price:res.data.red_envelopes_price,
money:res.data.money,
mycards:res.data.list,
})
if(res.data.red_envelopes_price>0){
setTimeout(()=>{
this.setData({
red_envelopes_price:0,
})
},3000)
}
})
},
moved: function () { },
detached: function () { },
},
/**
* 组件的方法列表
*/
methods: {
hide(){
this.setData({
hiddenAni:'discountHide',
})
this.triggerEvent('hide')
setTimeout(()=>{
this.setData({
display:false,
hiddenAni:'',
})
},250)
},
show(){
this.setData({
display:true,
hiddenAni:'',
})
this.triggerEvent('show')
},
useCard(){
this.hide()
this.triggerEvent('event',{type:'gotoReserve'})
},
},
})