|
|
<template>
|
|
|
<div class="filter">
|
|
|
<div class="filter" :class="{ 'filter-open': isVisible}">
|
|
|
<div class="filter-actions">
|
|
|
<a href="javascript:;" class="filter-action" @click="clearVals">清空</a>
|
|
|
<button class="button button-small filter-action" @click="okAction">确定</button>
|
...
|
...
|
@@ -16,134 +16,169 @@ |
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
const $ = require('yoho-jquery');
|
|
|
const bus = require('common/vue-bus');
|
|
|
|
|
|
module.exports = {
|
|
|
props: {
|
|
|
config: Object
|
|
|
},
|
|
|
data: function() {
|
|
|
return {
|
|
|
// 选择的值
|
|
|
params: {},
|
|
|
|
|
|
// 确定的值
|
|
|
selected: {}
|
|
|
};
|
|
|
},
|
|
|
watch: {},
|
|
|
methods: {
|
|
|
clearVals: function() {
|
|
|
// remove all value
|
|
|
this.$set('params', {});
|
|
|
const $ = require('yoho-jquery');
|
|
|
const bus = require('common/vue-bus');
|
|
|
const Overlay = require('common/overlay');
|
|
|
|
|
|
module.exports = {
|
|
|
props: {
|
|
|
config: Object,
|
|
|
isVisible: Boolean
|
|
|
},
|
|
|
data: function() {
|
|
|
return {
|
|
|
// 选择的值
|
|
|
params: {},
|
|
|
|
|
|
/**
|
|
|
* 当二级筛选, 返回数据时, 调用该方法
|
|
|
* @param {[type]} cate [description]
|
|
|
* @param {[type]} val [description]
|
|
|
*/
|
|
|
setCateParams: function(cate, val) {
|
|
|
this.$set(`params.${cate}`, val);
|
|
|
// 确定的值
|
|
|
selected: {}
|
|
|
};
|
|
|
},
|
|
|
okAction: function() {
|
|
|
bus.$emit('filter.change', {
|
|
|
val: this.params,
|
|
|
ref: this._uid
|
|
|
});
|
|
|
watch: {
|
|
|
isVisible(newVal) {
|
|
|
if (newVal) {
|
|
|
this.overlay.show();
|
|
|
} else {
|
|
|
this.overlay.hide();
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
entrySub: function(key) {
|
|
|
bus.$emit('filter.sub.show', {
|
|
|
val: key,
|
|
|
ref: this._uid
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
filters: {
|
|
|
unifyTxt: function(val, category) {
|
|
|
let txt = '';
|
|
|
let arr = [];
|
|
|
let foo = $.noop;
|
|
|
|
|
|
|
|
|
if ($.isArray(val)) { // [{categoryName,..},{}..]
|
|
|
foo = (index, obj) => {
|
|
|
arr.push(obj[category + 'Name']);
|
|
|
};
|
|
|
methods: {
|
|
|
clearVals: function() {
|
|
|
// remove all value
|
|
|
this.$set('params', {});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 当二级筛选, 返回数据时, 调用该方法
|
|
|
* @param {[type]} cate [description]
|
|
|
* @param {[type]} val [description]
|
|
|
*/
|
|
|
setCateParams: function(cate, val) {
|
|
|
this.$set(`params.${cate}`, val);
|
|
|
},
|
|
|
okAction: function() {
|
|
|
bus.$emit('filter.change', {
|
|
|
val: this.params,
|
|
|
ref: this._uid
|
|
|
});
|
|
|
},
|
|
|
entrySub: function(key) {
|
|
|
bus.$emit('filter.sub.show', {
|
|
|
val: key,
|
|
|
ref: this._uid
|
|
|
});
|
|
|
}
|
|
|
|
|
|
$.each(val, foo);
|
|
|
txt = arr.join(',');
|
|
|
return txt;
|
|
|
},
|
|
|
txt: function(val) {
|
|
|
const dict = {
|
|
|
color: 'Color颜色',
|
|
|
gender: 'Gender性别',
|
|
|
size: 'Size尺寸',
|
|
|
brand: 'Brand品牌',
|
|
|
priceRange: 'Price价格',
|
|
|
groupSort: 'Category品类',
|
|
|
discount: 'Sale折扣'
|
|
|
};
|
|
|
filters: {
|
|
|
unifyTxt: function(val, category) {
|
|
|
let txt = '';
|
|
|
let arr = [];
|
|
|
let foo = $.noop;
|
|
|
|
|
|
|
|
|
if ($.isArray(val)) { // [{categoryName,..},{}..]
|
|
|
foo = (index, obj) => {
|
|
|
arr.push(obj[category + 'Name']);
|
|
|
};
|
|
|
}
|
|
|
|
|
|
$.each(val, foo);
|
|
|
txt = arr.join(',');
|
|
|
return txt;
|
|
|
},
|
|
|
txt: function(val) {
|
|
|
const dict = {
|
|
|
color: 'Color颜色',
|
|
|
gender: 'Gender性别',
|
|
|
size: 'Size尺寸',
|
|
|
brand: 'Brand品牌',
|
|
|
priceRange: 'Price价格',
|
|
|
groupSort: 'Category品类',
|
|
|
discount: 'Sale折扣'
|
|
|
};
|
|
|
|
|
|
return dict[val] || '';
|
|
|
return dict[val] || '';
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
const self = this;
|
|
|
|
|
|
this.overlay = new Overlay({
|
|
|
disableScrolling: true,
|
|
|
onClose: function() {
|
|
|
self.isVisible = false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
};
|
|
|
|
|
|
</script>
|
|
|
<style>
|
|
|
@import "../../../scss/common/color";
|
|
|
|
|
|
.filter {
|
|
|
padding: 0 30px;
|
|
|
}
|
|
|
|
|
|
.filter-actions {
|
|
|
font-size: 34px;
|
|
|
text-align: right;
|
|
|
padding: 45px 0;
|
|
|
}
|
|
|
|
|
|
.filter-action {
|
|
|
font-size: inherit;
|
|
|
margin-left: 40px;
|
|
|
}
|
|
|
|
|
|
.filter-actions,
|
|
|
.filter-cate {
|
|
|
border-bottom: 1px solid $grey;
|
|
|
}
|
|
|
|
|
|
.filter-cates {
|
|
|
list-style: none;
|
|
|
margin: 0;
|
|
|
padding: 0;
|
|
|
}
|
|
|
|
|
|
.filter-cate .icon-right {
|
|
|
margin-left: 24px;
|
|
|
}
|
|
|
|
|
|
.filter-cate,
|
|
|
.icon-right {
|
|
|
height: 118px;
|
|
|
line-height: 118px;
|
|
|
}
|
|
|
|
|
|
.filter-cate-label {
|
|
|
font-size: 36px;
|
|
|
font-weight: bold;
|
|
|
}
|
|
|
|
|
|
.filter-cate-val {
|
|
|
float: right;
|
|
|
font-size: 28px;
|
|
|
}
|
|
|
@import "../../../scss/common/color";
|
|
|
|
|
|
.filter {
|
|
|
position: fixed;
|
|
|
z-index: 1001;
|
|
|
top: 0;
|
|
|
right: 0;
|
|
|
bottom: 0;
|
|
|
left: 20%;
|
|
|
background-color: #fff;
|
|
|
transform: translate3d(100%, 0, 0);
|
|
|
transition: all 0.3s 0.2s;
|
|
|
padding: 0 30px;
|
|
|
|
|
|
&.filter-open {
|
|
|
transform: translate3d(0, 0, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.filter-actions {
|
|
|
font-size: 34px;
|
|
|
text-align: right;
|
|
|
padding: 45px 0;
|
|
|
}
|
|
|
|
|
|
.filter-action {
|
|
|
font-size: inherit;
|
|
|
margin-left: 40px;
|
|
|
}
|
|
|
|
|
|
.filter-actions,
|
|
|
.filter-cate {
|
|
|
border-bottom: 1px solid $grey;
|
|
|
}
|
|
|
|
|
|
.filter-cates {
|
|
|
list-style: none;
|
|
|
margin: 0;
|
|
|
padding: 0;
|
|
|
}
|
|
|
|
|
|
.filter-cate .icon-right {
|
|
|
margin-left: 24px;
|
|
|
}
|
|
|
|
|
|
.filter-cate,
|
|
|
.icon-right {
|
|
|
height: 118px;
|
|
|
line-height: 118px;
|
|
|
}
|
|
|
|
|
|
.filter-cate-label {
|
|
|
font-size: 36px;
|
|
|
font-weight: bold;
|
|
|
}
|
|
|
|
|
|
.filter-cate-val {
|
|
|
float: right;
|
|
|
font-size: 28px;
|
|
|
}
|
|
|
|
|
|
.filter-cate-val,
|
|
|
.filter-cate .icon {
|
|
|
color: $grey;
|
|
|
}
|
|
|
|
|
|
.filter-cate-val,
|
|
|
.filter-cate .icon {
|
|
|
color: $grey;
|
|
|
}
|
|
|
</style> |
...
|
...
|
|