小程序筛选列表可单选可同时选效果

 <view class="sxBox" wx:if="{{sxBox}}">
       <view class="shuaixuan">
        <text class="changFs">商家特色</text>
        <view class='sxList' >
          <text bindtap="filter" data-index="0" data-value="1" class="{{currDj[0]==1?'sxListColor':'sxListdefault'}}">减免运费</text>
          <text bindtap="filter" data-index="1" data-value="2" class="{{currDj[1]==2?'sxListColor':'sxListdefault'}}">优惠券</text>
        </view>
      </view>
       <view class="shuaixuan">
        <text class="changFs">商家活动</text>
        <view class='sxList'>
          <text bindtap="filter"  data-index="2" data-value="3" class="{{currDj[2]==3?'sxListColor':'sxListdefault'}}">首单优惠</text>
          <text bindtap="filter"  data-index="3" data-value="4" class="{{currDj[3]==4?'sxListColor':'sxListdefault'}}">满减优惠</text>
        </view>
      </view>``
      </view>
      <view class="btn">
        <text>重置</text>
        <text>确定</text>
      </view>
    </view>
/* 筛选 */
.sxBox{
  width: 100%;
  height: 666rpx;
  position: absolute;
  top: 560rpx;
  left: 0;
  z-index: 200;
  background: #fff;
}
.shuaixuan {
  display: flex;
  flex-direction: column;
}

.shuaixuan .changFs {
  display: flex;
  font-size: 24rpx;
  color: #989898;
  margin: 34rpx 0 24rpx 32rpx;
}

.sxList {
  display: flex;
  flex-wrap: wrap;
  flex: 1;
  margin: 0 0 0 30rpx;
}
.sxList .sxListdefault,.sxList .sxListColor{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 220rpx;
  height: 56rpx;
  font-family: PingFangSC-Regular;
  font-size: 28rpx;
  color: #2B2B2B;
  background: #F7F7F7;
  border-radius: 2px;
  margin-right: 12rpx;
}
.sxList .sxListColor{
  color: #FF5C4D !important;
  background: #FFF0F0 !important;
  border-radius: 2px !important;
}
.sxListTwo text{
  margin-bottom: 20rpx;
}
.btn{
  width: 100%;
  display: flex;
  margin-top: 48rpx;
  border-top: 1px solid #F5F5F5; 
}
.btn text{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 376rpx;
  height: 98rpx;
  font-family: PingFangSC-Regular;
  font-size: 32rpx;
  color: #989898;
}
.btn text:nth-child(2){
  color: #FFFFFF;
  background-image: linear-gradient(49deg, #FF4F4F 0%, #FF8644 100%);
}

data{
	 currDj: ['', ''],
}

 // 筛选事件
  filter:function(e){
    var that=this
    var index=e.currentTarget.dataset.index
    var currDj = that.data.currDj
    console.log(currDj)
    currDj[index] = currDj[index] == e.currentTarget.dataset.value ? '' : e.currentTarget.dataset.value
    this.setData({
      currDj: currDj
    })
    console.log(this.data.currDj)
    console.log(e.currentTarget.dataset.value)
  },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值