filter.js
1.91 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
87
88
89
90
91
92
93
94
95
96
97
98
99
// components/reserve/search/filter.js
import util from '../../../utils/util'
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
consumeStr:'',
hasDisplay:false,
},
attached(){
this.min=0
this.max=300
},
/**
* 组件的方法列表
*/
methods: {
consumeEvent(e){
console.log('consumeEvent',e)
let data={
hasChange:true,
}
if(e.detail.type=='once'){
this.min=e.detail.min
this.max=e.detail.max
}else{
this[e.detail.type]=e.detail.value
}
let consumeStr=''
if(this.min==0){
if(this.max>this.min){
consumeStr='¥'+this.max+'以下'
}
}else{
if(this.min<300){
consumeStr='¥'+this.min+'-'+this.max
}else{
consumeStr='¥'+this.min+'以上'
}
}
let obj={
consumeStr:consumeStr,
}
if(e.detail.type!='once'){
obj.active=''
}
this.setData(obj)
},
changeVal(e){
let active=util.attr(e,'val')
let val=active.split(',')
this.min=val[0]
this.max=val[1]
this.setData({
active:active,
})
this.selectComponent('#consume').changeVal(this.min,this.max);
},
close(){
this.setData({
hasDisplay:false,
})
},
show(){
this.setData({
hasDisplay:true,
})
},
submit(){
this.triggerEvent('event',{
type:'set',
data:{
consumeStr:this.data.consumeStr||'',
min:this.min,
max:this.max,
active:this.data.active||'',
},
})
this.close()
},
reset(){
this.selectComponent('#consume').changeVal(0,300);
this.setData({
active:'',
consumeStr:'',
})
this.triggerEvent('event',{type:'clean'})
this.close()
},
}
})