微信小程序?qū)崿F(xiàn)列表?xiàng)l件篩選
本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)列表?xiàng)l件篩選的具體代碼,供大家參考,具體內(nèi)容如下
最近一個(gè)旅游項(xiàng)目,關(guān)于篩選框的代碼
wxml文件
<view class='chooseList'>
? ? ? <view class="nav">
? ? <view class="nav-son {{shownavindex == 1? 'active' : ''}}" bindtap="listqy" data-nav="1">
? ? ? <view class="content">酒店類(lèi)型</view>
? ? ? <view class="icon"></view>
? ? </view>
? ? <view class="nav-son borders {{shownavindex == 2? 'active' : ''}}" bindtap="list" data-nav="2">
? ? ? <view class="content">價(jià)格</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文件:
點(diǎn)擊酒店類(lèi)型,展示篩選酒店的條件
listqy: function (e) {
? ? ? ? console.log('觸發(fā)時(shí)機(jī)---點(diǎn)擊酒店類(lèi)型的時(shí)候')
? ? 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
? ? ? })
? ? }
? },點(diǎn)擊一級(jí)菜單,展示對(duì)應(yīng)的二級(jí)菜單
selectleft: function (e) {
? ? console.log('用戶(hù)選中左邊菜單欄的索引值是:' + e.target.dataset.city);
? ? ? ? if (e.target.dataset.city === '床型、早餐') {
? ? ? ? ? ? console.log('哈哈')
? ? ? ? ? ? this.setData({
? ? ? ? ? ? ? ? isshowradio: true // 如果是早餐和床型的話(huà),就讓選擇早餐的按鈕顯示
? ? ? ? ? ? })
? ? ? ? } else {
? ? ? ? ? ? this.setData({
? ? ? ? ? ? ? ? isshowradio: false
? ? ? ? ? ? })
? ? ? ? }
? ? this.setData({
? ? ? citycenter: this.data.cityleft[e.currentTarget.dataset.city],
? ? ? select1: e.target.dataset.city,
? ? ? select2: ''
? ? });
? },點(diǎn)擊二級(jí)菜單
selectcenter: function (e) {
? ? ? ? console.log(e.target.dataset.value)
? ? ? ? console.log('用戶(hù)選中右邊邊菜單欄的索引值是:' + e.target.dataset.value, this.data.select1);
? ? ? ? let _this = this
? ? ? ? if (_this.data.select1 === '酒店類(lèi)型') {
? ? ? ? ? ? _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
? ? });
? },

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
在ASP.NET MVC項(xiàng)目中使用RequireJS庫(kù)的用法示例
這篇文章主要介紹了在ASP.NET MVC項(xiàng)目中使用RequireJS的用法示例,文中主要講解了網(wǎng)站項(xiàng)目的一些基本目錄結(jié)構(gòu)思想,并給出了一個(gè)半自動(dòng)壓縮的例子,的朋友可以參考下2016-02-02
JS中FileReader類(lèi)實(shí)現(xiàn)文件上傳及時(shí)預(yù)覽功能
這篇文章主要為大家詳細(xì)介紹了JS中FileReader類(lèi)實(shí)現(xiàn)文件上傳及時(shí)預(yù)覽功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-03-03
JavaScript數(shù)組_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
這篇文章主要介紹了JavaScript數(shù)組的相關(guān)知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-06-06
ES6擴(kuò)展運(yùn)算符的用途實(shí)例詳解
這篇文章主要介紹了ES6擴(kuò)展運(yùn)算符的用途 ,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-08-08
js+css實(shí)現(xiàn)文字散開(kāi)重組動(dòng)畫(huà)特效代碼分享
這篇文章主要介紹了js+css實(shí)現(xiàn)文字散開(kāi)重組動(dòng)畫(huà)特效,需要的朋友可以參考下2015-08-08
javascript面向?qū)ο笾x成員方法實(shí)例分析
這篇文章主要介紹了javascript面向?qū)ο笾x成員方法,實(shí)例分析了成員方法的定義與使用技巧,需要的朋友可以參考下2015-01-01
前端JavaScript經(jīng)典之Promise詳解
Promise是為了解決回調(diào)地獄問(wèn)題而誕生的,它提供了優(yōu)雅的異步回調(diào)解決方案,這篇文章主要介紹了前端JavaScript經(jīng)典之Promise的相關(guān)資料,需要的朋友可以參考下2024-09-09
Bootstrap輸入框組件簡(jiǎn)單實(shí)現(xiàn)代碼
這篇文章主要為大家詳細(xì)介紹了Bootstrap輸入框組件的簡(jiǎn)單實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03

