效果
html
结构说明:三个tab头部head为一个盒子,弹出框popup为一个盒子
<view class="goods_list">
<!-- 搜索 -->
<view class="search">
<input type="text" name="search" bindconfirm='shop_search_function' confirm-type='search'
placeholder="请输入关键词" />
<image src="{{imgurl}}l_shousuo.png" />
</view>
<!-- 三个筛选 -->
<view class="head flex">
<view class="item flex_l {{tab==1?'active':''}}" data-tab='1' bindtap="changeTab">
<text>默认排序</text>
<image wx:if="{{tab!=1}}" src="{{imgurl}}l_zonghe.png" />
<image wx:if="{{tab==1}}" src="{{imgurl}}l_zonghed.png" />
</view>
<view class="item flex_l {{tab==2?'active':''}}" data-tab='2' bindtap="changeTab">
<text>拍卖状态</text>
<image wx:if="{{tab!=2}}" src="{{imgurl}}l_zonghe.png" />
<image wx:if="{{tab==2}}" src="{{imgurl}}l_zonghed.png" />
</view>
<view class="item {{tab==3?'active':''}}" data-tab='3' bindtap="changeTab">
<text>筛选</text>
</view>
</view>
<!-- 默认排序弹出框 -->
<view class="popup" wx:if="{{tab==1&&tab1show}}">
<view class="item flex_l {{tab1==1?'active':''}}" data-tab1="1" bindtap="selectTab1">
<image class="hide" src="{{imgurl}}l_xuanzhong.png" />
<text>默认排序</text>
</view>
<view class="item flex_l {{tab1==2?'active':''}}" data-tab1="2" bindtap="selectTab1">
<image class="hide" src="{{imgurl}}l_xuanzhong.png" />
<text>按拍卖时间排序</text>
</view>
<view class="item flex_l {{tab1==3?'active':''}}" data-tab1="3" bindtap="selectTab1">
<image class="hide" src="{{imgurl}}l_xuanzhong.png" />
<text>当前价格由高到低</text>
</view>
<view class="item flex_l {{tab1==4?'active':''}}" data-tab1="4" bindtap="selectTab1">
<image class="hide" src="{{imgurl}}l_xuanzhong.png" />
<text>当前价格由低到高</text>
</view>
<view class="item flex_l {{tab1==5?'active':''}}" data-tab1="5" bindtap="selectTab1">
<image class="hide" src="{{imgurl}}l_xuanzhong.png" />
<text>最新发布</text>
</view>
</view>
<!-- 拍卖状态弹出框 -->
<view class="popup" wx:if="{{tab==2&&tab2show}}">
<view class="item flex_l {{tab2==1?'active':''}}" data-tab2="1" bindtap="selectTab2">
<image class="hide" src="{{imgurl}}l_xuanzhong.png" />
<text>正在进行</text>
</view>
<view class="item flex_l {{tab2==2?'active':''}}" data-tab2="2" bindtap="selectTab2">
<image class="hide" src="{{imgurl}}l_xuanzhong.png" />
<text>即将开始</text>
</view>
<view class="item flex_l {{tab2==3?'active':''}}" data-tab2="3" bindtap="selectTab2">
<image class="hide" src="{{imgurl}}l_xuanzhong.png" />
<text>已结束</text>
</view>
<view class="item flex_l {{tab2==4?'active':''}}" data-tab2="4" bindtap="selectTab2">
<image class="hide" src="{{imgurl}}l_xuanzhong.png" />
<text>流拍</text>
</view>
</view>
<!-- 列表为空时 -->
<view class="null hide">
<image src="{{imgurl}}l-null.png" />
<text>您还没有收藏过圈子呢,快去看看吧</text>
</view>
<!-- 瀑布流 -->
<view class='pubuliu'>
<view class='list-masonry'>
<view class='item-masonry' wx:for="{{list}}" wx:if="{{index % 2 == 0}}">
<image src='{{item.url}}' mode='widthFix'></image>
<text class="title erhang">{{item.title}}</text>
<view class="keys flex_l">
<text>真迹</text>
<text>真迹</text>
</view>
<view class="price">
起拍价<text>¥8888</text>
</view>
<text class="time">预计今天20:00结束</text>
</view>
<view class='item-masonry' wx:for="{{list}}" wx:if="{{index % 2 ==1}}">
<image src='{{item.url}}' mode='widthFix'></image>
<text class="title erhang">{{item.title}}</text>
<view class="keys flex_l">
<text>真迹</text>
<text>真迹</text>
</view>
<view class="price">
起拍价<text>¥8888</text>
</view>
<text class="time">预计今天20:00结束</text>
</view>
</view>
</view>
</view>
less
样式说明:页面布局所有盒子高度为百分比,整个页面高度为100%=搜索高+head高+弹出框popup高
弹出框popup设置透明背景色,筛选条件为其内部item,背景色为白色
弹出框popup设置相对整个页面固定定位,top值为搜索高+head高,从而实现无缝对接并有背景的效果
.goods_list {
height: 100%;
.search {
height: 5%;
margin: 1.5% 60rpx 1.5% 24rpx;
position: relative;
input {
height: 100%;
border-radius: 32rpx;
padding-left: 85rpx;
border: 1rpx solid rgba(153, 153, 153, 1);
}
image {
width: 44rpx;
height: 44rpx;
position: absolute;
left: 30rpx;
top: 10rpx;
}
}
.head {
height: 8%;
padding: 0 30rpx;
font-size: 28rpx;
color: #0C0B0B;
border-top: 1rpx solid #E5E5E5;
border-bottom: 1rpx solid #E5E5E5;
.item.active {
color: #FC5E62;
}
image {
width: 12rpx;
height: 7rpx;
margin-left: 12rpx;
}
}
.popup {
height: 85%;
background-color: rgba(0, 0, 0, .5);
position: fixed;
top: 15%;
left: 0;
right: 0;
.item {
height: 98rpx;
background-color: #fff;
padding-left: 30rpx;
&.active {
font-weight: 700;
image {
display: block;
}
}
image {
width: 25rpx;
height: 18rpx;
margin-right: 25rpx;
}
}
}
.null {
text-align: center;
image {
display: block;
width: 393rpx;
height: 294rpx;
margin: 200rpx auto 30rpx;
}
text {
font-size: 28rpx;
color: rgba(153, 153, 153, 1);
}
}
.pubuliu {
padding: 0 24rpx;
.list-masonry {
column-count: 2;
column-gap: 23rpx;
}
.item-masonry {
background-color: #fff;
break-inside: avoid;
box-sizing: border-box;
margin-bottom: 40rpx;
image {
width: 100%;
}
.title {
margin: 15rpx 0;
}
.keys {
text {
display: block;
border: 1rpx solid rgba(153, 153, 153, 1);
border-radius: 20rpx;
padding: 2rpx 15rpx;
margin-right: 10rpx;
color: #999;
font-size: 24rpx;
}
}
.price {
margin: 10rpx 0;
font-size: 24rpx;
text {
color: #FC5E62;
font-size: 30rpx;
margin-left: 5rpx;
}
}
.time {
font-size: 24rpx;
color: rgba(153, 153, 153, 1);
}
}
}
}
js
// pages/goods_list/goods_list.js
const app = getApp()
const request = require('../../utils/request.js')
Page({
/**
* 页面的初始数据
*/
data: {
imgurl: app.globalData.pmhImgurl, //全局img路径
imgWidth: 0, imgHeight: 0,
id: '', // 二级分类id
list: [
{
title: '案例名称1',
url: 'http://zq.jhcms.cn/attachs/photo/201711/20171130_176CFE51B6710715B1BBBEF2F86ACB0C.jpg',
},
{
title: '你所不知道的红酒知识2',
url: 'http://img3.imgtn.bdimg.com/it/u=1417732605,3777474040&fm=26&gp=0.jpg',
},
{
title: '红酒知识3',
url: 'http://f10.baidu.com/it/u=121654667,1482133440&fm=72',
},
{
title: '案例名称4',
url: 'http://zq.jhcms.cn/attachs/photo/201711/20171130_9E39DA252E3946BE36218D85876C4AB4.jpg',
},
{
title: '案例名称5',
url: 'http://img3.imgtn.bdimg.com/it/u=1417732605,3777474040&fm=26&gp=0.jpg'
},
{
title: '案例名称6',
url: 'http://f10.baidu.com/it/u=121654667,1482133440&fm=72'
},
{
title: '案例名称7',
url: 'http://img4.imgtn.bdimg.com/it/u=2748975304,2710656664&fm=26&gp=0.jpg'
},
{
title: '案例名称8',
url: 'http://img2.imgtn.bdimg.com/it/u=1561660534,130168102&fm=26&gp=0.jpg'
},
{
title: '案例名称9',
url: 'http://img3.imgtn.bdimg.com/it/u=1417732605,3777474040&fm=26&gp=0.jpg'
}
],
tab: 0, //三个tab切换 1 默认排序 2 拍卖状态 3 筛选
tab1show: false, //1 默认排序弹出框是否显示
tab2show: false, //2 拍卖状态弹出框是否显示
tab1: 0, //tab1默认排序弹窗的值 1,2,3,4,5
tab2: 0, //tab2拍卖状态弹窗的值 1,2,3,4
},
// 点击三个tab切换
changeTab(e) {
console.log(e.currentTarget.dataset.tab);
let tab = e.currentTarget.dataset.tab
this.setData({
tab: tab
})
if (tab == 1) {
this.setData({
tab1show: !this.data.tab1show,
tab2show: false
})
} else if (tab == 2) {
this.setData({
tab2show: !this.data.tab2show,
tab1show: false
})
} else if (tab == 3) {
this.setData({
tab1show: false,
tab2show: false
})
}
},
// 点击tab1默认排序弹窗的5个选项
selectTab1(e) {
let tab1 = e.currentTarget.dataset.tab1
this.setData({
tab1: tab1,
tab1show: false
})
},
// 点击tab2拍卖状态弹窗的4个选项
selectTab2(e) {
let tab2 = e.currentTarget.dataset.tab2
this.setData({
tab2: tab2,
tab2show: false
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options.id);
this.setData({
id: options.id
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})