效果图:
<swiper current="{{currentTab}}" duration="300" bindchange="swiperTab">
<swiper-item catchtouchmove="stopTouchMove">
<view class="catalog_items display-flex-row" >
<block wx:for="{{catalogs}}">
<text data-select="{{item.select}}" class="{{item.select == catalogSelect ? 'active':''}} catalog_item" bindtap="chooseCatalog">{{item.catalogName}}</text>
</block>
</view>
</swiper-item>
<swiper-item catchtouchmove="stopTouchMove">
<view class="catalog_items display-flex-row" >
<block wx:for="{{catalogs}}">
<text data-select="{{item.select}}" class="{{item.select == catalogSelect ? 'active':''}} catalog_item" bindtap="chooseCatalog">{{item.catalogName}}</text>
</block>
</view>
</swiper-item>
<swiper-item catchtouchmove="stopTouchMove">
<view class="catalog_items display-flex-row" >
<block wx:for="{{catalogs}}">
<text data-select="{{item.select}}" class="{{item.select == catalogSelect ? 'active':''}} catalog_item" bindtap="chooseCatalog">{{item.catalogName}}</text>
</block>
</view>
</swiper-item>
<swiper-item catchtouchmove="stopTouchMove">
<view class="catalog_items display-flex-row" >
<block wx:for="{{catalogs}}">
<text data-select="{{item.select}}" class="{{item.select == catalogSelect ? 'active':''}} catalog_item" bindtap="chooseCatalog">{{item.catalogName}}</text>
</block>
</view>
</swiper-item>
<swiper-item catchtouchmove="stopTouchMove">
<view class="catalog_items display-flex-row" >
<block wx:for="{{catalogs}}">
<text data-select="{{item.select}}" class="{{item.select == catalogSelect ? 'active':''}} catalog_item" bindtap="chooseCatalog">{{item.catalogName}}</text>
</block>
</view>
</swiper-item>
<swiper-item catchtouchmove="stopTouchMove">
<view class="catalog_items display-flex-row" >
<block wx:for="{{catalogs}}">
<text data-select="{{item.select}}" class="{{item.select == catalogSelect ? 'active':''}} catalog_item" bindtap="chooseCatalog">{{item.catalogName}}</text>
</block>
</view>
</swiper-item>
<swiper-item catchtouchmove="stopTouchMove">
<view class="catalog_items display-flex-row" >
<block wx:for="{{catalogs}}">
<text data-select="{{item.select}}" class="{{item.select == catalogSelect ? 'active':''}} catalog_item" bindtap="chooseCatalog">{{item.catalogName}}</text>
</block>
</view>
</swiper-item>
</swiper>
</view>
css样式::
.show-btn {
margin-top: 100rpx;
color: #22cc22;
}
.modal-mask {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background: #000;
opacity: 0.5;
overflow: hidden;
z-index: 9000;
color: #fff;
}
.modal-dialog {
width: 100%;
position: absolute;
bottom:0;
left: 0;
z-index: 9999;
background: #f9fbff;
}
.modal-title {
line-height:96rpx;
font-size: 32rpx;
color: #030303;
text-align: center;
border-bottom: 1px solid #ccc;
}
.modal-title1 {
line-height:96rpx;
font-size: 32rpx;
color: #030303;
padding-left:60rpx;
border-bottom: 1px solid #ccc;
}
.input {
width: 100%;
height: 82rpx;
font-size: 28rpx;
line-height: 28rpx;
padding: 0 20rpx;
box-sizing: border-box;
color: #333;
}
input-holder {
color: #666;
font-size: 28rpx;
}
.modal-footer {
display: flex;
flex-direction: row;
height: 86rpx;
border-top: 1px solid #dedede;
font-size: 34rpx;
line-height: 86rpx;
}
.btn-cancel {
width: 50%;
color: #666;
text-align: center;
border-right: 1px solid #dedede;
}
.btn-confirm {
width: 50%;
color: #ec5300;
text-align: center;
}
.modal-inpt{
width: 100%;
height: 100%;
position: relative;
}
.swiper-tab{
width: 100%;
text-align: center;
height:100%;
line-height: 70rpx;
/* display: flex; */
flex-flow: row;
justify-content: space-between;
position: relative;
font-size:15px;
}
.swiper-tab-item{
width: 48%;
color:#434343;
border: 1px solid #ccc;
border-top:none;
}
.active{
color:#59B550;
background: #fff;
border-right:10rpx solid #fff;
}
swiper{
/* text-align: center; /
display: block;
position: absolute;
right:0rpx;
top: 0rpx;
/ background: red; */
width: 51.6%;
height: 100%;
background: #fff;
}
.catalog_item{
display: block;
width: 100%;
margin: 34rpx;
font-size: 30rpx;
}
js::
Page({
data: {
showModal: false,
currentTab: 0,
catalogs: [
{
“catalogName”: “上午”,
“select”: 1
},
{
“catalogName”: “下午”,
“select”: 2
}
],
catalogSelect: 0,//判断是否选中
},
chooseCatalog: function (data) {
var that = this;
that.setData({//把选中值放入判断值
catalogSelect: data.currentTarget.dataset.select,
showModal: false
})
},
onLoad: function (options) {
},
swiperTab: function (e) {
var that = this;
that.setData({
currentTab: e.detail.current
});
},
clickTab: function (e) {
var that = this;
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
that.setData({
currentTab: e.target.dataset.current,
catalogSelect: 0
})
}
},
stopTouchMove: function () {
return false; //防止swiper滑动
},
/**
- 弹窗
/
showDialogBtn: function () {
this.setData({
showModal: true
})
},
/*
- 弹出框蒙层截断touchmove事件
/
preventTouchMove: function () {
},
/*
- 隐藏模态对话框
/
hideModal: function () {
this.setData({
showModal: false
});
},
/*
- 对话框取消按钮点击事件
/
onCancel: function () {
this.hideModal();
},
/*
- 对话框确认按钮点击事件
*/
onConfirm: function () {
this.hideModal();
}
})
|
请发表评论