wxml
wxss
.tabTit{
height:90rpx;
line-height: 90rpx;
border-bottom: solid 1px #eee;
/* position:fixed; /
/ top:0; */
width: 750rpx;
z-index: 1;
background: #fff;
font-size:15px;
text-align: center;
}
.tabTit .active{
color:#e64340;
}
.tabTit .active image{
transform: rotate(180deg);
background: none;
}
.tabTit image{
width:26rpx;
height:26rpx;
vertical-align: middle;
margin-left: 5px;
}
.tabLayer{
box-shadow: 0 5px 5px rgba(0,0,0,.15);
width:750rpx;
overflow: hidden;
position: fixed;
top:90rpx;
z-index: 1;
background: #fff;
padding-bottom: 40rpx;
border-bottom: solid 1px #eee;
text-align: center;
margin-top: 420rpx;
}
.tabLayer text{
width:210rpx;
height:60rpx;
line-height:60rpx;
float:left;
border: solid 1px #eee;
margin:20rpx 0 0 26rpx;
font-size:15px;
}
.tabLayer .active{
color:#e64340;
border-color:#e64340;
}
.flex1 {
flex: 1;
overflow: hidden;
display: block;
}
/弹性盒模型/
.box {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
navigator{
display:inline;
}
.list{
/* margin-top:32px; /
width: 100%;
/ background: #dfdfdf; */
}
.one{
z-index: 333;
}
.list .list_item{
margin-top:2px;
padding:10px;
height:100px;
border-bottom:1px solid #E8E8E8;
box-shadow:0 2px 2px rgba(0,0,0,.15);
background:white;
}
.list .list_item .img{
float:left;
width:30%;
height:100%;
}
.list .list_item .img image{
width:100%;
height:100%;
}
.list .list_item .info{
width:70%;
float:right;
height:100px;
position:relative;
}
.list .list_item .info .title{
color:#333;
margin-left:10px;
font-size: 15px;
}.title{
height:110rpx;
}
.list .list_item .info .price{
color:#FF2727;
margin-left:10px;
margin-top:20px;
font-size:30rpx;
}
.list .list_item .info .num{
width:90%;
position: absolute;
left:0px;
/* bottom:10px; /
color:#747474;
margin-left:10px;
font-size:30rpx;
overflow:hidden;
/ //超出一行文字自动隐藏 /
text-overflow:ellipsis;
/ //文字隐藏后添加省略号 /
white-space:nowrap;
/ //强制不换行 */
}
js
Page({
data:{tabTxt: [‘综合排序’, ‘距离排序’, ‘全部活动’], //分类
tab: [true, true, true],
pinpaiList: [{
‘id’: ‘1’,
‘title’: ‘参与最多’
}, ],
// 综合排序
Sorting: 0,
Sorting_id: 0,
Sorting_txt: ‘’,
// 距离
juli: “”,
juli_id: 0,
juli_txt: ‘’,
ju: 0,
// 全部活动
activityFlag: 0,
activityFlag_id: ‘’,
activityFlag_txt: ‘’,
},
//筛选项点击操作
filter: function(e) {
var that = this;
var id = e.currentTarget.dataset.id;
var txt = e.currentTarget.dataset.txt;
var tabTxt = this.data.tabTxt;
switch (e.currentTarget.dataset.index) {
case ‘0’:
tabTxt[0] = txt;
that.setData({
tab: [true, true, true],
tabTxt: tabTxt,
Sorting_id: id,
Sorting_txt: txt
});
break;
case ‘1’:
tabTxt[1] = txt;
that.setData({
tab: [true, true, true],
tabTxt: tabTxt,
juli_id: id,
juli_txt: txt
});
break;
case ‘2’:
tabTxt[2] = txt;
that.setData({
tab: [true, true, true],
tabTxt: tabTxt,
activityFlag_id: id,
activityFlag_txt: txt
});
break;
}
this.setData({
//距离
ajuli: that.data.juli_txt,
//活动类型
bFlag: that.data.activityFlag_id,
//综合排序
cSorting: that.data.Sorting_id,
})
this.getBargain();
},
getBargain() {
const that = this;
if (that.data.cSorting === ‘’) {
that.data.cSorting = 0;
}
if (that.data.ajuli === ‘距离排序’) {
that.data.ajuli = ‘’;
}
app.$api.request({
path: ‘bargain/classifiedQuery’,
data: {
lat: that.data.latitude,
lon: that.data.longitude,
Sorting: that.data.cSorting,
juli: that.data.ajuli,
activityFlag: that.data.bFlag,
}
}).then(({
data
}) => {
if (JSON.stringify(data) == “[]”) {
data && that.setData({
bargainList: data,
})
clearInterval(that.data.timer);
return;
}
clearInterval(that.data.timer);
//时间转换
that.data.timer = setInterval(function() {
for (let index in data) {
this.getbargina = data[index];
if (this.getbargina.activityFlag != ‘本次活动已经结束’ || this.getbargina.activityFlag != ‘活动将于’ + this.getbargina.startTime + ‘开始’) {
//正在进行中的活动
var currentDate = new Date();
var create = this.getbargina.startTime.replace(/-/g, ‘/’);
var createDate = new Date(create);
var time = (createDate.getTime() + this.getbargina.activityDay * 24 * 3600 * 1000) - currentDate.getTime();
data && that.setData({
countDown: time
})
that.data.countDown -= 1000;
var times = new Date(that.data.countDown);
times = times / 1000;
var sign1 = “/”;
var sign2 = “:”;
var day = Math.floor(times / (60 * 60 * 24));
var hour = Math.floor((times - (day * 24 * 60 * 60)) / (60 * 60));
var minutes = Math.floor(times / 60) - (hour * 60) - (day * 24 * 60);
var seconds = Math.floor(times) - (hour * 60 * 60) - (minutes * 60) - (day * 24 * 60 * 60);
if (hour >= 0 && hour <= 9) {
hour = “0” + hour;
}
if (minutes >= 0 && minutes <= 9) {
minutes = “0” + minutes;
}
if (seconds >= 0 && seconds <= 9) {
seconds = “0” + seconds;
}
this.getbargina.activityFlag = (day + “天” + hour + sign2 + minutes + sign2 + seconds);
if (that.data.countDown <= 0) { //当时间为0时显示活动结束
this.getbargina.activityFlag = ‘本次活动已经结束’;
}
}
data && that.setData({
bargainList: data,
})
}
}, 1000)
}).catch(({
message
}) => {
app.message(message);
})
},
})