微信小程序实现列表条件筛选
本文实例为大家分享了微信小程序实现列表条件筛选的具体代码,供大家参考,具体内容如下
最近一个旅游项目,关于筛选框的代码
wxml文件
<view>
<view>
<view bindtap="listqy">
<view>酒店类型</view>
<view></view>
</view>
<view bindtap="list">
<view>价格</view>
<view></view>
</view>
<!-- <view bindtap="listpx">
<view>排序</view>
<view></view>
</view> -->
</view>
<view>
<view>
<view wx:for="{{cityleft}}" wx:key='{{item}}' bindtap="selectleft" bindtap="selectcenter">
{{index}}
<image src='https://www.zhangshengrong.com/images/istrue.png'display:block':'display:none'}}"></image>
</view>
<!-- 如果选择是早餐,展示筛选按钮 -->
<view wx:if='{{isshowradio}}'>
<radio-group bindchange="radioChange">
<label wx:for="{{breakfastlist}}">
<radio value="{{item.value}}" checked="{{item.checked}}" />
{{item.value}}
</label>
</radio-group>
</view>
</view>
<view>
<button bindtap='quyuEmpty'>重置</button>
<button bindtap='submitFilter'>确定</button>
</view>
</view>
js文件:
点击酒店类型,展示筛选酒店的条件
listqy: function (e) {
console.log('触发时机---点击酒店类型的时候')
if (this.data.qyopen) {
console.log(this.data.qyopen)
this.setData({
qyopen: false,
nzopen: false,
nzshow: true,
qyshow: false,
isfull: false,
shownavindex: 0
})
} else {
this.setData({
qyopen: true,
nzopen: false,
nzshow: true,
qyshow: false,
isfull: true,
shownavindex: e.currentTarget.dataset.nav
})
}
},
点击一级菜单,展示对应的二级菜单
selectleft: function (e) {
console.log('用户选中左边菜单栏的索引值是:' + e.target.dataset.city);
if (e.target.dataset.city === '床型、早餐') {
console.log('哈哈')
this.setData({
isshowradio: true // 如果是早餐和床型的话,就让选择早餐的按钮显示
})
} else {
this.setData({
isshowradio: false
})
}
this.setData({
citycenter: this.data.cityleft[e.currentTarget.dataset.city],
select1: e.target.dataset.city,
select2: ''
});
},
点击二级菜单
selectcenter: function (e) {
console.log(e.target.dataset.value)
console.log('用户选中右边边菜单栏的索引值是:' + e.target.dataset.value, this.data.select1);
let _this = this
if (_this.data.select1 === '酒店类型') {
_this.data.type = e.target.dataset.city
console.log(_this.data.type)
}
if (_this.data.select1 === '设施') {
_this.data.facility = e.target.dataset.city
console.log(_this.data.facility)
}
if (_this.data.select1 === '地理位置') {
_this.data.maxdistance = e.target.dataset.value
console.log(_this.data.maxdistance)
}
if (_this.data.select1 === '床型、早餐') {
_this.data.cbedtype = e.target.dataset.city
console.log(_this.data.cbedtype)
}
this.setData({
select2: e.target.dataset.city
});
},

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。