Commit 7dce30c3bdbc6fae7f61945f217b8fe197b4a02f

Authored by vking
1 parent 437b8693

filter 人均

/* components/reserve/caixi.wxss */
@import "../../app.wxss";
.mask{
z-index:99999;
}
.caixi{
background-color: #fefefe;
position: fixed;
... ...
// components/reserve/search/filter.js
import util from '../../../utils/util'
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
consumeStr:'',
hasDisplay:false,
},
attached(){
this.min=0
this.max=300
},
/**
* 组件的方法列表
*/
methods: {
consumeEvent(e){
console.log('consumeEvent',e)
let data={
hasChange:true,
}
if(e.detail.type=='once'){
this.min=e.detail.min
this.max=e.detail.max
}else{
this[e.detail.type]=e.detail.value
}
let consumeStr=''
if(this.min==0){
if(this.max>this.min){
consumeStr='¥'+this.max+'以下'
}
}else{
if(this.min<300){
consumeStr='¥'+this.min+'-'+this.max
}else{
consumeStr='¥'+this.min+'以上'
}
}
let obj={
consumeStr:consumeStr,
}
if(e.detail.type!='once'){
obj.active=''
}
this.setData(obj)
},
changeVal(e){
let active=util.attr(e,'val')
let val=active.split(',')
this.min=val[0]
this.max=val[1]
this.setData({
active:active,
})
this.selectComponent('#consume').changeVal(this.min,this.max);
},
close(){
this.setData({
hasDisplay:false,
})
},
show(){
this.setData({
hasDisplay:true,
})
},
submit(){
this.triggerEvent('event',{
type:'set',
data:{
consumeStr:this.data.consumeStr||'',
min:this.min,
max:this.max,
active:this.data.active||'',
},
})
this.close()
},
reset(){
this.selectComponent('#consume').changeVal(0,300);
this.setData({
active:'',
consumeStr:'',
})
this.triggerEvent('event',{type:'clean'})
this.close()
},
}
})
... ...
{
"component": true,
"usingComponents": {
"consume":"/components/stat/zyslider"
}
}
\ No newline at end of file
... ...
<!--components/reserve/search/filter.wxml-->
<view class="mask" wx:if="{{hasDisplay}}" bindtap="close">
<view class="filter" catchtap="catchtap">
<view class="header flex-lr">
<view></view>
<view class="title">更多筛选</view>
<view class="close" bindtap="close"></view>
</view>
<view class="part flex-ll">
人均消费
<view class="txt" wx:if="{{consumeStr}}">{{consumeStr}}</view>
</view>
<view class="flex-lr tips">
<view class="content">¥0</view>
<view class="content">¥300以上</view>
</view>
<view class="consume flex-vc">
<consume style="width:99%;" id="consume"
minValue="0" maxValue="300" min="0" max="300"
blockColor="#fefefe"
backgroundColor="#D8D8D8"
selectedColor="#E9BE94"
bindevent="consumeEvent">
</consume>
</view>
<view class="flex-lr split">
<view class="item {{active=='0,100'?'active':''}}" bindtap="changeVal" data-val="0,100">¥100以下</view>
<view class="item {{active=='100,200'?'active':''}}" bindtap="changeVal" data-val="100,200">¥100-200</view>
<view class="item {{active=='200,300'?'active':''}}" bindtap="changeVal" data-val="200,300">¥200-300</view>
<view class="item {{active=='300,300'?'active':''}}" bindtap="changeVal" data-val="300,300">¥300以上</view>
</view>
<view class="flex-lr buttons">
<view class="reset" bindtap="reset">重置</view>
<view class="submit" bindtap="submit">完成</view>
</view>
</view>
</view>
... ...
/* components/reserve/search/filter.wxss */
@import "../../../app.wxss";
.mask{
z-index: 99999;
}
.filter{
position: fixed;
bottom: env(safe-area-inset-bottom);
width: 100%;
background-color: #fefefe;
z-index: 9999;
padding: 40rpx 30rpx;
box-sizing: border-box;
border-radius: 20rpx 20rpx 0px 0px;
}
.header{
height: 42rpx;
font-size: 30rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #353535;
line-height: 42rpx;
}
.header .close{
background-image: url("http://nosqn.colorcun.com/reserve/images/close.png");
background-size: 100% 100%;
width:32rpx;
height:32rpx;
position: relative;
}
.close:after{
width:100rpx;
height:100rpx;
position: absolute;
content: "";
top:-50rpx;
left:-50rpx;
}
.part{
height: 48rpx;
font-size: 34rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #353535;
line-height: 48rpx;
margin-top: 60rpx;
}
.part .txt{
height: 48rpx;
font-size: 34rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #E9BE94;
line-height: 48rpx;
margin-left: 30rpx;
}
.tips{
height: 40rpx;
font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #353535;
line-height: 40rpx;
margin-top: 40rpx;
}
.tips .content{
width: 130rpx;
text-align: center;
}
.consume{
margin: 0rpx auto;
width: calc(100% - 60rpx);
height: 80rpx;
overflow: hidden;
}
.split{
margin-top: 60rpx;
}
.split .item{
width: calc(calc(100% - 66rpx) / 4);
margin-right: 22rpx;
height: 84rpx;
background: #F0F0F9;
border-radius: 6rpx;
font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #353535;
line-height: 84rpx;
text-align: center;
}
.split .item:last-child{
margin-right: 0;
}
.split .item.active{
background: #F4DAB9;
color: #8B5318;
}
.buttons{
margin-top: 100rpx;
}
.buttons .reset,.buttons .submit{
width: calc(50% - 21rpx);
height: 84rpx;
background: #FFFFFF;
border-radius: 12rpx;
border: 2rpx solid #C0C0C0;
margin-right: 21rpx;
font-size: 34rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #5E5E5E;
line-height: 84rpx;
text-align: center;
box-sizing: border-box;
}
.buttons .submit{
margin-right: 0;
margin-left: 21rpx;
background: linear-gradient(180deg, #F4DAB9 0%, #E9BE94 100%);
color: #8B5318;
border-width: 0;
}
\ No newline at end of file
... ...
// component/zyslider/zyslider.js
var util = require('../../utils/util')
Component({
/**
* 组件的属性列表
*/
properties: {
/** slider 最小值 */
min: {
type: Number
},
/** slider 最大值 */
max: {
type: Number
},
/** 步进 (没做,有时间再说,项目里没用到撒) */
step: {
type: Number
},
/** 预选选择的小值*/
minValue: {
type: Number
},
/** 预选选择的大值 */
maxValue: {
type: Number
},
/** 滑块颜色 */
blockColor:{
type: String
},
/** 未选择进度条颜色 */
backgroundColor:{
type: String
},
/** 已选择进度条颜色 */
selectedColor:{
type: String
}
},
/**
* 组件的初始数据
*/
data: {
min: 0,
max: 300,
leftValue: 0,
rightValue: 300,
totalLength: 0,
bigLength: 0,
ratio: 0.5,
sliderLength: 30,
containerLeft: 0, //标识整个组件,距离屏幕左边的距离
hideOption: '', //初始状态为显示组件
},
/**
* 组件的方法列表
*/
methods: {
/**
* 设置左边滑块的值
*/
_propertyLeftValueChange: function () {
let minValue = this.data.minValue / this.data.max * this.data.bigLength
let min = this.data.min / this.data.max * this.data.bigLength
this.setData({
leftValue: minValue - min
})
},
/**
* 设置右边滑块的值
*/
_propertyRightValueChange: function () {
let right = this.data.maxValue / this.data.max * this.data.bigLength + this.data.sliderLength
this.setData({
rightValue: right
})
},
/**
* 滑块滑动
* @param e
*/
sliderMove(e){
this.sliderEvent=e
//console.log('sliderMove.changing',this.sliderMoving)
if(this.sliderMoving) return;//移动中
setTimeout(()=>{
//console.log('changing',this.sliderEvent);
let pagex = this.sliderEvent.changedTouches[0].pageX / this.data.ratio - this.data.containerLeft - this.data.sliderLength / 2
let myEventDetail={}
if(util.attr(this.sliderEvent,'type')=='max'){
if (pagex <= this.data.leftValue + this.data.sliderLength) {
pagex = this.data.leftValue + this.data.sliderLength
} else if (pagex >= this.data.totalLength - this.data.sliderLength) {
pagex = this.data.totalLength - this.data.sliderLength
}
this.setData({
rightValue: pagex
})
pagex = pagex - this.data.sliderLength
let heighValue = parseInt(pagex / this.data.bigLength * (this.data.max - this.data.min) + this.data.min)
myEventDetail = { type:'max',value: heighValue }
}else{
if (pagex + this.data.sliderLength >= this.data.rightValue) {
pagex = this.data.rightValue - this.data.sliderLength
} else if (pagex <= 0) {
pagex = 0
}
this.setData({
leftValue: pagex
})
let lowValue = parseInt(pagex / this.data.bigLength * parseInt(this.data.max - this.data.min) + this.data.min)
myEventDetail = { type:'min',value: lowValue }
}
//console.log('event',myEventDetail);
this.triggerEvent('event', myEventDetail)
this.sliderMoving=false
},0)
this.sliderMoving=true
},
/**
* 隐藏组件
*/
hide: function () {
this.setData({
hideOption: 'hide',
})
},
/**
* 显示组件
*/
show: function () {
this.setData({
hideOption: '',
})
},
/**
* 重置
*/
reset: function () {
this.setData({
rightValue: this.data.totalLength,
leftValue: 0,
})
},
changeVal(min,max) {
this.setData({
minValue: parseInt(min),
maxValue: parseInt(max),
})
this._propertyLeftValueChange()
this._propertyRightValueChange()
this.triggerEvent('event', { type:'once',min:min,max:max})
},
},
ready: function () {
let that = this;
const getSystemInfo = util.wxPromisify(wx.getSystemInfo)
const queryContainer = util.wxPromisify(wx.createSelectorQuery().in(this).select(".container").boundingClientRect)
util.wxPromisify(wx.getSystemInfo)()
.then(res => {
let ratio = res.windowWidth / 750
that.setData({
ratio: ratio,
})
})
.then(() => {
var query = wx.createSelectorQuery().in(this)
query.select(".container").boundingClientRect(function (res) {
that.setData({
totalLength: res.width / that.data.ratio - that.data.sliderLength,
bigLength: res.width / that.data.ratio - that.data.sliderLength * 3,
rightValue: res.width / that.data.ratio - that.data.sliderLength,
containerLeft: res.left / that.data.ratio
})
/**
* 设置初始滑块位置
*/
that._propertyLeftValueChange()
that._propertyRightValueChange()
}).exec()
})
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--component/zyslider.wxml-->
<slot></slot>
<view class="container {{hideOption}}">
<view class="slider-item min" style="left:{{leftValue}}rpx;background-color:{{blockColor}};" catchtouchmove="sliderMove" data-type="min"></view>
<view class="slider-item max" style="left:{{rightValue}}rpx;background-color:{{blockColor}};" catchtouchmove="sliderMove" data-type="max"></view>
<view class="slider-body left" style="left:{{sliderLength}}rpx; width:{{leftValue}}rpx;background-color:{{backgroundColor}};"></view>
<view class="slider-body body" style="left:{{leftValue}}rpx; width:{{rightValue-leftValue}}rpx;background-color:{{selectedColor}};"></view>
<view class="slider-body right" style="left:{{rightValue}}rpx; width:{{totalLength - rightValue}}rpx;background-color:{{backgroundColor}};"></view>
</view>
... ...
/* component/zyslider.wxss */
.container {
/*height: 100%;*/
width: 100%;
position: relative;
}
.slider-body {
height: 6rpx;
background: #D8D8D8;
border-radius: 3rpx;
position: relative;
}
.body {
bottom: 60rpx;
height: 6rpx;
background: #E9BE94;
border-radius: 3rpx;
z-index: 0.3;
}
.left {
bottom: 60rpx;
z-index: 0.1;
}
.right {
z-index: 0.2;
bottom: 64rpx;
}
.slider-item {
width: 60rpx;
height: 60rpx;
background: #FFFFFF;
box-shadow: 0px 4rpx 8rpx 0rpx #F4DAB9;
border: 2rpx solid #E9BE94;
border-radius: 50%;
z-index: 2;
}
.min {
position: relative;
top: 40rpx;
/*left: 100rpx;*/
}
.max {
position: relative;
bottom: 22rpx;
/*left: 600rpx;*/
}
.hide{
display: none;
}
\ No newline at end of file
... ...
... ... @@ -506,6 +506,13 @@ Page({
if(this.findSellerData){
param=Object.assign(param,this.findSellerData.paramObj)
}
if(this.filterParams){//人均过滤
let filterParams=this.filterParams.min+','+this.filterParams.max
if(this.filterParams.min==this.filterParams.max && this.filterParams.min==300){
filterParams=this.filterParams.min+','+parseInt(new Date()/1000)
}
param.filterParams=filterParams
}
//this.selectComponent('#list').getList(param);
this.param=param;
let now_sid=[];
... ... @@ -982,4 +989,17 @@ Page({
}
}
},
filterShow(){
this.selectComponent('#filter').show();
},
filterParams:null,
filterEvent(e){
console.log('filterEvent',e)
if(e.detail.type=='clean'){
this.filterParams=null
}else{
this.filterParams=e.detail.data
}
setTimeout(()=>{this.getMarkers();},0)
},
})
\ No newline at end of file
... ...
... ... @@ -12,6 +12,7 @@
"caixi":"/components/reserve/caixi",
"activity-enter":"/components/activity/enter",
"as-phone":"/components/actionSheet/phone",
"activity-tips":"/components/tips/discount"
"activity-tips":"/components/tips/discount",
"filter":"/components/reserve/search/filter"
}
}
\ No newline at end of file
... ...
... ... @@ -35,7 +35,7 @@
</view>
</view>
</navigator>
<view class="transverse-search flex-ll">
<view class="transverse-search">
<view
bindtap="caixiShow"
class="tags {{multiIndex[0]>0?'active':''}}"
... ... @@ -53,6 +53,18 @@
bindtap="tagsChange"
data-id="{{item.id}}">{{item.name}}</view>
</block>
<view
bindtap="filterShow"
class="tags {{multiIndex[0]>0?'active':''}}"
>
<view class="picker flex-lr">
<view class="input">
<block wx:if="{{multiIndex[0]==0}}">筛选</block>
<block wx:else="">{{multiArray[0][multiIndex[0]]}}</block>
</view>
<view class="more"></view>
</view>
</view>
<!--
<view class="fingSeller flex-ll" bindtap="findSeller">
<view class="icon"></view>
... ... @@ -161,4 +173,5 @@
<activity-enter hasInHome wx:if="{{hasGetPos}}"></activity-enter>
<boost bindevent="boostEvent" wx:if="{{hasBoost}}"></boost>
<activity-tips wx:if="{{hasSetActivity}}" map="{{map}}"></activity-tips>
<as-phone id="as"></as-phone>
\ No newline at end of file
<as-phone id="as"></as-phone>
<filter id="filter" bindevent="filterEvent"></filter>
\ No newline at end of file
... ...
... ... @@ -43,6 +43,7 @@ page{
background-color: #fefefe;
/*height: 264rpx;*/
width: 100%;
margin-top: -360rpx;
}
.transverse-list .seller{
width: 98%;
... ... @@ -101,6 +102,8 @@ page{
.picker{
height: 50rpx;
line-height: 50rpx;
padding-left: 8rpx;
padding-right: 10rpx;
}
.picker .input{
height: 50rpx;
... ... @@ -331,11 +334,20 @@ page{
}
.transverse-search{
background-color: #fefefe;
height: 90rpx;
/*height: 90rpx;*/
height: 450rpx;
font-size: 24rpx;
padding-left: 40rpx;
padding-left: 16rpx;
line-height: 90rpx;
width: calc(100% - 16rpx);
overflow-x: auto;
white-space:nowrap;
}
.transverse-search view{
display: inline-block;
}
.disabled .transverse-search{
padding-top: 0;
}
... ...
... ... @@ -30,7 +30,7 @@
"packNpmRelationList": []
},
"compileType": "miniprogram",
"libVersion": "2.10.1",
"libVersion": "2.11.1",
"appid": "wxd3dc4206c76f14fc",
"projectname": "c%E7%AB%AF%E9%A2%84%E5%AE%9A",
"isGameTourist": false,
... ...
... ... @@ -110,7 +110,25 @@ function timetouUnix(dasr, connect) {
var time_str = date.getTime().toString();
return time_str.substr(0, 10);
}
/**
* 将小程序的API封装成支持Promise的API
* @params fn {Function} 小程序原始API,如wx.login
*/
const wxPromisify = fn => {
return function (obj = {}) {
return new Promise((resolve, reject) => {
obj.success = function (res) {
resolve(res)
}
obj.fail = function (res) {
reject(res)
}
fn(obj)
})
}
}
module.exports = {
formatTime: formatTime,
unixtoTime: unixtoTime,
... ... @@ -343,6 +361,7 @@ module.exports = {
},
})
},
wxPromisify:wxPromisify,
}
... ...