微信小程序實現(xiàn)列表條件篩選
更新時間:2022年07月17日 15:35:59 作者:shadow_yi8978
這篇文章主要為大家詳細介紹了微信小程序實現(xiàn)列表條件篩選,篩選框的效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了微信小程序實現(xiàn)列表條件篩選的具體代碼,供大家參考,具體內容如下
最近一個旅游項目,關于篩選框的代碼
wxml文件
<view class='chooseList'> ? ? ? <view class="nav"> ? ? <view class="nav-son {{shownavindex == 1? 'active' : ''}}" bindtap="listqy" data-nav="1"> ? ? ? <view class="content">酒店類型</view> ? ? ? <view class="icon"></view> ? ? </view> ? ? <view class="nav-son borders {{shownavindex == 2? 'active' : ''}}" bindtap="list" data-nav="2"> ? ? ? <view class="content">價格</view> ? ? ? <view class="icon"></view> ? ? </view> ? ? <!-- <view class="nav-son {{shownavindex == 3? 'active' : ''}}" bindtap="listpx" data-nav="3"> ? ? ? <view class="content">排序</view> ? ? ? <view class="icon"></view> ? ? </view> --> ? </view> ? ? <view class="quyu {{qyopen ? 'slidown' : 'slidup'}} {{qyshow ? 'disappear':''}}"> ? ? ? <view class="qy quyu-left"> ? ? ? <view class="{{select1 == index ? 'current' : ''}}" wx:for="{{cityleft}}" wx:key='{{item}}' bindtap="selectleft" data-city='{{index}}'> ? ? ? ? {{index}} ? ? ? </view> ? ? </view> ? ? <view class="qy quyu-center"> ? ? ? <view class="{{select2 == index ? 'current2' : ''}}" wx:for="{{citycenter}}" bindtap="selectcenter" data-value='{{item}}' data-city='{{index}}'> ? ? ? ? {{index}} ? ? ? ? <image src='../../images/istrue.png' style="{{select2 == index?'display:block':'display:none'}}"></image> ? ? ? </view> ? ? ? ? ? ? <!-- 如果選擇是早餐,展示篩選按鈕 --> ? ? ? ? ? ? <view style="border-style: none;" wx:if='{{isshowradio}}'> ? ? ? ? ? ? ? ? <radio-group class="radio-group" bindchange="radioChange"> ? ? ? ? ? ? ? ? ? ? <label class="radio" wx:for="{{breakfastlist}}"> ? ? ? ? ? ? ? ? ? ? ? ? <radio value="{{item.value}}" checked="{{item.checked}}" /> ? ? ? ? ? ? ? ? ? ? ? ? {{item.value}} ? ? ? ? ? ? ? ? ? ? </label> ? ? ? ? ? ? ? ? </radio-group> ? ? ? ? ? ? </view> ? ? </view> ? ? <view class='form-btn'> ? ? ? <button class='btn-reset' bindtap='quyuEmpty'>重置</button> ? ? ? <button class='btn-submit' bindtap='submitFilter'>確定</button> ? ? </view> ? </view>
js文件:
點擊酒店類型,展示篩選酒店的條件
listqy: function (e) { ? ? ? ? console.log('觸發(fā)時機---點擊酒店類型的時候') ? ? 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 ? ? }); ? },
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
相關文章
JavaScript數組去重的方法總結【12種方法,號稱史上最全】
這篇文章主要介紹了JavaScript數組去重的方法,結合實例形式較為詳細的總結分析了12種方法數組去重的方法,需要的朋友可以參考下2019-02-02bootstrap treeview 樹形菜單帶復選框及級聯(lián)選擇功能
這篇文章主要介紹了bootstrap treeview 樹形菜單帶復選框及級聯(lián)選擇功能,代碼超簡單,感興趣的朋友跟隨腳本之家小編一起學習吧2018-06-06