微信小程序?qū)崿F(xiàn)列表條件篩選
本文實例為大家分享了微信小程序?qū)崿F(xiàn)列表條件篩選的具體代碼,供大家參考,具體內(nèi)容如下
最近一個旅游項目,關(guā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 ? ? ? }) ? ? } ? },
點擊一級菜單,展示對應(yīng)的二級菜單
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 === '設(shè)施') { ? ? ? ? ? ? _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 ? ? }); ? },
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JavaScript數(shù)組去重的方法總結(jié)【12種方法,號稱史上最全】
這篇文章主要介紹了JavaScript數(shù)組去重的方法,結(jié)合實例形式較為詳細的總結(jié)分析了12種方法數(shù)組去重的方法,需要的朋友可以參考下2019-02-02微信小程序內(nèi)拖動圖片實現(xiàn)移動、放大、旋轉(zhuǎn)的方法
這篇文章主要介紹了微信小程序內(nèi)拖動圖片實現(xiàn)移動、放大、旋轉(zhuǎn)的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-09-09js中symbol類型以及symbol的三大應(yīng)用場景詳解
Symbol是ES6新推出的一種基本類型,它表示獨一無二的值,它可以接受一個字符串作為參數(shù),帶有相同參數(shù)的兩個Symbol值不相等,這個參數(shù)只是表示Symbol值的描述而已,下面這篇文章主要給大家介紹了關(guān)于js中symbol類型以及symbol的三大應(yīng)用場景,需要的朋友可以參考下2022-09-09bootstrap treeview 樹形菜單帶復選框及級聯(lián)選擇功能
這篇文章主要介紹了bootstrap treeview 樹形菜單帶復選框及級聯(lián)選擇功能,代碼超簡單,感興趣的朋友跟隨腳本之家小編一起學習吧2018-06-06