二十三、小程序中的三级下拉框(下拉菜单)
XHTML部分 <view class='area'><view class="product-list"><!--条件选择--><view class="choice-bar"><!--头部--><!--第一个--><view bindtap="choiceItem" data-item="1" class="chioce-item" hover-class="click-once-opaque">{{name}}<image class="icon-chioce" src="{{staticImg}}maintenance/icon-go-black.png"></image></view><!--蜀山区--><view bindtap="choiceItem" data-item="2" class="chioce-item" hover-class="click-once-opaque">{{activeSortingName}}<image class="icon-chioce" src="{{staticImg}}maintenance/icon-go-black.png"></image></view><!--默认排序--><view bindtap="choiceItem" data-item="3" class="chioce-item" hover-class="click-once-opaque">{{ordername}}<image class="icon-chioce" src="{{staticImg}}maintenance/icon-go-black.png"></image></view><!--对应的下拉框 --><!--名字--><view class="sorting-list{{!chioceDistrict?' chioce-list-hide':' chioce-list-show'}}"><view wx:for="{{DjList}}" catchtap="getDistrictList" data-index="{{index}}" class="sorting-item" hover-class="click-once" bindtap='selectColor'>{{item.value}}<text>123</text></view></view><!--地区--><view class="sorting-list{{!chioceSorting?' chioce-list-hide':' chioce-list-show'}}"><view wx:for="{{sortingList}}" catchtap="selectSorting" data-index="{{index}}" class="sorting-item" hover-class="click-once" bindtap='selectColor'>{{item.value}}<text>123</text></view></view><!--默认排序--><view class="filter-list{{!chioceFilter?' chioce-list-hide':' chioce-list-show'}}"><view wx:for="{{filterList}}" catchtap="selectFilter" data-index="{{index}}" class="filter-item" hover-class="click-once" catchtap="filterButtonClick">{{item.value}}<image hidden="{{!item.selected}}" class="icon-selected" src="/pages/maintenance/img/icon-selected.png"></image></view> </view></view><view bindtap="hideAllChioce" class="mask" hidden="{{!chioceDistrict&&!chioceSorting&&!chioceFilter}}"></view> </view></view>
WXSS样式
/* pages/maintenance/maintenance.wxss */
page{ display: flex; flex-direction: column; height: 100%; background: #f0f0f0;
}
.navbar{ flex: none; display: flex; background: #fff; box-sizing: border-box;z-index: 9999;
}
.navbar .item{ position: relative; flex: auto; text-align: center; line-height: 80rpx; padding-top: 1px;font-size: 30rpx;
}
.navbar .item.active:after{ content: ""; display: block; position: absolute; bottom: 0; left: 0; right: 0; height: 4rpx; background: #c00;
}
.active {background: #c00;color: #fff;
}
.area {width: 100%;height: 84rpx;background: #fff;border-top: 1px solid #ccc;/* display: none; */
}
.fixdd {width: 100%;height: 78rpx;background: #fff;border-top: 1px solid #ccc;box-sizing: border-box;padding-left: 43rpx;
}
.fixddImg {width: 40rpx;height: 40rpx;margin-top: 19rpx;display: block;float: left;
}
.fixddtext {font-size: 30rpx;height: 80rpx;line-height: 80rpx;margin-left: 30rpx;color: #888;
}.stores {width: 100%;height: 205rpx;
}
.storesLi {width: 100%;height: 205rpx;background: #fff;box-sizing: border-box;padding: 30rpx;margin-top: 10rpx;
}
.storesL {width: 150rpx;height: 150rpx;float: left;
}
.storesL image {width: 150rpx;height: 150rpx;
}
.storesR {width: 530rpx;height: 150rpx;float: left;position: relative;box-sizing: border-box;padding-left: 20rpx;
}
.Ul {width: 77%;height: 150rpx;
}
.storestext1 {font-size: 30rpx;
}
.storestext2 {font-size: 24rpx;color: #888;
}
.storestext3 {font-size: 24rpx;color: #888;line-height: 50rpx;
}
.storestext3 text {color: #c00;margin-right: 30rpx;
}
.selt {width: 87rpx;height: 81rpx;line-height: 81rpx;border-radius: 10rpx;border: 1px solid #888;position: absolute;right: 0;top: 0;text-align: center;font-size: 24rpx;color: #888;
}
.dist {position: absolute;right: 0;bottom: 0;font-size: 24rpx;color: #888;
}.editor {width: 100%;height: 100rpx;background: #fff;margin-top: 50rpx;box-sizing: border-box;padding-left: 56rpx;
}
.editortext1 {height: 100rpx;line-height: 100rpx;
}
.editorImg {width: 45rpx;height: 45rpx;margin-top: 28rpx;float: right;margin-right: 40rpx;
}
.editortext1 {font-size:30rpx;margin-right: 50rpx;
}
.editortext2 {display: inline-block;width: 100rpx;height: 45rpx;font-size: 24rpx;background: #c00;color: #fff;text-align: center;line-height: 45rpx;
}
.addEdict {width: 80%;height: 80rpx;color: #fff;line-height: 80rpx;background: #c00;margin-top: 80rpx;
} /*顶部的下拉框样式*/.product-list {min-height: 100vh;background-color: #f0f0f0;padding-top: 80rpx;box-sizing: border-box;
}/*条件选择*/.choice-bar {position: absolute;top: 80rpx;display: flex;width: 100vw;font-size: 16px;background-color: #fff;z-index: 9;
}.chioce-item {background-color: #fff;/* display: flex; */align-items: center;justify-content: space-between;padding: 0 20rpx;width: 33.3%;height: 80rpx;line-height: 80rpx;text-align: center;border-top: 1rpx solid #ddd;border-bottom: 1rpx solid #ddd;border-left: 1rpx solid #ddd;font-size: 26rpx;/*border-right: 1rpx solid #ddd;*/
}.chioce-item-last {border-right: none;
}.chioce-item-first {border-left: none;
}.icon-chioce {height: 25rpx;width: 25rpx;
}
.mask{position: fixed;top:0;bottom: 0;right: 0;left: 0;background-color: #000;opacity: 0.5;
}
.district-list,.sorting-list,.filter-list {margin-top: 2rpx;position: absolute;top: 80rpx;left: 0;width: 100%;background-color: #fff;z-index: -1;font-size: 14px;border-bottom: 1rpx solid #ddd;
}.chioce-list-show {top: 80rpx;animation: slide 500ms;
}@keyframes slide {0% {top: -500rpx;}100% {top: 80rpx;}
}.chioce-list-hide {display: none !important;
}/*区域位置*/.district-list {display: flex;
}.district-left {flex-grow: 1;
}.district-right {flex-grow: 4;
}
.scroll-district{height: 500rpx;
}
.district-parent {height: 100rpx;line-height: 100rpx;padding: 0 40rpx;border-bottom: 1rpx solid #ddd;border-right: 1rpx solid #ddd;background-color: #f0f0f0;
}.district-parent-active {background-color: #fff;
}.district-children {height: 100rpx;line-height: 100rpx;padding: 0 40rpx;border-bottom: 1rpx solid #ddd;
}/*综合排序*/
.sorting-item {height: 80rpx;line-height: 80rpx;padding: 0 40rpx;border-bottom: 1rpx solid #ddd;
}
.sorting-item text {float: right;
}/*筛选*/.filter-item {height: 80rpx;line-height: 80rpx;padding: 0 40rpx;border-bottom: 1rpx solid #ddd;display: flex;justify-content: space-between;align-items: center;
}.icon-selected {height: 30rpx;width: 30rpx;
}.filter-footer {display: flex;justify-content: space-between;
}.filter-footer button {margin: 20rpx 80rpx;border-radius: 0 !important;
}.button-reset {border: 1rpx solid #ddd !important;color: #666 !important;
}
.seleColor {color: #c00;
}
JS
// pages/maintenance/maintenance.js
Page({/*** 页面的初始数据*/data: {staticImg: app.globalData.staticImg,curIndex: 0,currentTab: 0,// 下拉框的data值typeID: 0,isLoading: true,loadOver: false,districtList: [],sortingList: [{ key: 1, value: "合肥市" }, {key: 2, value: "合肥市"}, {key: 3, value: "瑶海区"}, {key: 4, value: "瑶海区"}, {key: 5, value: "瑶海区"}, {key: 6, value: "瑶海区"}],filterList: [{ key: 1, value: "默认排序", selected: false },{ key: 2, value: "距离最近", selected: false },{ key: 3, value: "评分最高", selected: false },{ key: 4, value: "累计订单", selected: false },],DjList: [{ key: 1, value: "邓杰"},{ key: 2, value: "小明"},{ key: 3, value: "小唐"},{ key: 4, value: "小杰"},],// districtChioceIcon: "/pages/maintenance/img/icon-go-black.png",// sortingChioceIcon: "/pages/maintenance/img/icon-go-black.png",chioceDistrict: false,chioceSorting: false,chioceFilter: false,// activeDistrictParentIndex: -1,// activeDistrictChildrenIndex: -1,// activeDistrictName: "区域位置",// scrollTop: 0,// scrollIntoView: 0,// activeSortingIndex: -1,activeSortingName: "蜀山区",ordername: "默认排序",name:"貂蝉"},// 下拉框的对应js//条件选择choiceItem: function (e) {switch (e.currentTarget.dataset.item) {case "1":if (this.data.chioceDistrict) {this.setData({districtChioceIcon: "/pages/maintenance/img/icon-go-black.png",sortingChioceIcon: "/pages/maintenance/img/icon-go-black.png",chioceDistrict: false,chioceSorting: false,chioceFilter: false,});}else {this.setData({districtChioceIcon: "/pages/maintenance/img/icon-go-black.png",sortingChioceIcon: "/pages/maintenance/img/icon-go-black.png",chioceDistrict: true,chioceSorting: false,chioceFilter: false,});}break;case "2":if (this.data.chioceSorting) {this.setData({districtChioceIcon: "/pages/maintenance/img/icon-go-black.png",sortingChioceIcon: "/pages/maintenance/img/icon-go-black.png",chioceDistrict: false,chioceSorting: false,chioceFilter: false,});}else {this.setData({districtChioceIcon: "/pages/maintenance/img/icon-go-black.png",sortingChioceIcon: "/pages/maintenance/img/icon-go-black.png",chioceDistrict: false,chioceSorting: true,chioceFilter: false,});}break;case "3":if (this.data.chioceFilter) {this.setData({districtChioceIcon: "/pages/maintenance/img/icon-go-black.png",sortingChioceIcon: "/pages/maintenance/img/icon-go-black.png",chioceDistrict: false,chioceSorting: false,chioceFilter: false,});}else {this.setData({districtChioceIcon: "/pages/maintenance/img/icon-go-black.png",sortingChioceIcon: "/pages/maintenance/img/icon-go-black.png",chioceDistrict: false,chioceSorting: false,chioceFilter: true,});}break;}},getDistrictList: function (e) {var index = e.currentTarget.dataset.index;this.setData({sortingChioceIcon: "/pages/maintenance/img/icon-go-black.png",chioceDistrict: false,activeSortingIndex: index,name: this.data.DjList[index].value,productList: [],pageIndex: 1,loadOver: false,isLoading: true})},//蜀山区selectSorting: function (e) {var index = e.currentTarget.dataset.index;this.setData({sortingChioceIcon: "/pages/maintenance/img/icon-go-black.png",chioceSorting: false,activeSortingIndex: index,activeSortingName: this.data.sortingList[index].value,productList: [],pageIndex: 1,loadOver: false,isLoading: true})},//默认排序filterButtonClick: function (e) {var index = e.currentTarget.dataset.index;this.setData({chioceFilter: false,productList: [],pageIndex: 1,loadOver: false,isLoading: true,ordername: this.data.filterList[index].value,})},
})
转载于:https://www.cnblogs.com/deng-jie/p/9239527.html
二十三、小程序中的三级下拉框(下拉菜单)相关推荐
- php地址选择插件,微信小程序中关于三级联动地址选择器的实例分享
本文介绍了微信小程序三级联动地址选择器的实例代码,分享给大家,有需要的可以一起了解一下 在一些电商类的小程序中,地址选择这个功能一般是必备的,一般的收货信息都需要有一个能选择省市县的控件,当然也有些人 ...
- 《微信小程序案例8》实现聊天框下部分别人向我发消息
一.先安装node.js 如若安装时出现磁盘无效的报错信息,以下解决方法 1.win+r 输入subst Y: %TEMP% 2.再次win+r 输入subst Y:/Y Y代表报错时出现的 ...
- 转载:在微信小程序中 生成二维码
目录 转载: weapp-qrcode-canvas-2d 仓库地址 测试环境 使用 安装方法1:直接引入 js 文件 安装方法2:npm安装 安装完成后调用 例子1:没有使用叠加图片 例子2:使用叠 ...
- 如何在微信小程序中生成二维码:一个最简单的案例就让你明白
使用weapp.qrcode.js 在 微信小程序 中,快速生成二维码 一.效果 二.具体步骤.代码 下载weapp-qrcode代码 然后 将 dist 目录下的weapp.qrcode.esm.j ...
- 在微信小程序中识别付款二维码
一.前言 由于微信小程序的规则限制,在小程序内部是无法直接识别二维码的,这样对于想通过微信小程序给微信公众号引流的想法大抵都被扼杀了,偶然间发现微信官方小程序"微保"竟然做到了,而 ...
- 在H5、微信小程序中使用canvas绘制二维码、分享海报
在H5.微信小程序中使用canvas绘制二维码.分享海报 文章目录 在H5.微信小程序中使用canvas绘制二维码.分享海报 前言 一.canvas绘制二维码 1.H5中使用canvas 2.微信小程 ...
- 微信小程序中开发环境下的POST请求
写在前面 不得不说,开发环境下,微信小程序要是在发起网络请求的话,遇到的坑也是有的.尽管,微信提供了十分便捷的API 供开发者调用.今天在小程序中写了一个表单,需要提交到服务器上,于是发起了一个 PO ...
- 跳一跳 微信小程序中的跳一跳相信大家都玩过。emmm???只学习不玩游戏?那就吃亏了...好好读题理解吧 简化后的跳一跳规则如下:玩家每次从当前方块跳到下一个方块,如果没有跳到下一个方块上则游
3 跳一跳 微信小程序中的跳一跳相信大家都玩过.emmm???只学习不玩游戏?那就吃亏了-好好读题理解吧. 简化后的跳一跳规则如下:玩家每次从当前方块跳到下一个方块,如果没有跳到下一个方块上则游戏结束 ...
- Canvas 动画引擎解析与微信小程序中的应用
点击观看大咖分享 抗击疫情,腾讯云在行动.在开发微信小程序的过程中,我们经常需要展现一些图形和图表.目前市面上有好几款常用的图形库,在这些图形库的底层都有渲染引擎在支撑. ZRender 是其中一款非 ...
- 关于小程序中地图的应用(联动搜索,模糊查询,定位导航)
小程序中地图的应用 一.获取微信地址 二.联动搜索及模糊查询 三.导航 一.获取微信地址 在小程序的开发中,内置了获取微信地址的API接口.我们可以直接调用,对返回的数据进行相关的处理即可.代码如下: ...
最新文章
- java 获取泛型t的class_阿里巴巴都鼎力推荐的java基础之集合其他内容和泛型3
- 《Redis in action》读书笔记
- 如何更改ubuntu的用户密码
- TemplateBinding与Binding区别,以及WPF自定义控件开发的遭遇
- JavaScript基础(五分钟让你了解js全貌)
- 【java】关于Java NIO的一切
- Android非常好用的组件或者框架
- 世界备份日——如果您丢失了所有文件
- 二手房六大产权问题最关键
- jenkins 管理员账号丢失
- 深度学习常用的数据集,包括各种数据跟图像数据
- 【转载】 禁止国外IP访问你的网站
- 【物联网】12.物联网服务器发送方式(HTTP,WebSocket ,MQTT )
- Improved Zero-shot Neural Machine Translation via Ignoring Spurious Correlations
- STM32开源代码——OLED汉字显示程序
- 惊鸿一现的永恒经典2007-05-07 09:40:18
- idea中找到VM options选项
- 计算机课堂活跃小游戏,几个课堂小游戏(能活跃课堂气氛)
- 也谈分库分表在实际应用的实践
- 1416711-60-8,DBCO-PEG4-Hydroxyl,DBCO-PEG4-alcohol,DBCO-PEG4-OH含有DBCO部分和末端伯羟基的PEG连接剂
热门文章
- linux设置北京时区
- axure命令行_axure怎么计算器
- 什么是软件EV代码签名证书
- wps表格l制作甘特图_如何制作甘特图(横道图)
- Nano板使用USB与PX4通信
- android studio红色下划线,如何在Android Studio中为文字加下划线?
- 警察心理素质测试的软件,2016招警考试心理素质测评常用试题
- 关于计算机教学的论文,关于计算机教学论文.docx
- 在Node.js中了解Hello World
- 尚学堂1811期python视频_尚学堂1811期人工智能全套视频教程震撼发布,转型百万年薪工程师!...