|
|
<template>
|
|
|
<div>
|
|
|
<Sort :config="sortConfig" :val="sort">
|
|
|
</Sort>
|
|
|
<cheader :title="sortName">
|
|
|
<i class="icon icon-filter" slot="right" @click="openFilter"></i>
|
|
|
</cheader>
|
|
|
<order :config="orderConfig" :val="order"></order>
|
|
|
<List :data="productList"></List>
|
|
|
<Drawer v-ref:drawer>
|
|
|
<Filter :config="filterConfig"></Filter>
|
|
|
</Drawer>
|
|
|
<Filter :config="filterConfig" v-ref:filter></Filter>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
const Vue = require('yoho-vue');
|
|
|
const lazyload = require('yoho-vue-lazyload');
|
|
|
const infinitScroll = require('yoho-vue-infinite-scroll');
|
|
|
const qs = require('yoho-qs');
|
|
|
const bus = require('common/vue-bus');
|
|
|
const tip = require('common/tip');
|
|
|
const sort = require('component/product/sort.vue');
|
|
|
const cheader = require('component/header.vue');
|
|
|
const order = require('component/product/order.vue');
|
|
|
const list = require('component/product/list.vue');
|
|
|
const drawer = require('component/product/drawer.vue');
|
|
|
const filter = require('component/product/filter.vue');
|
|
|
|
|
|
Vue.use(lazyload);
|
|
|
Vue.use(infinitScroll);
|
|
|
|
|
|
require('common/vue-filter');
|
|
|
|
|
|
module.exports = {
|
|
|
el: '#product-list',
|
|
|
data: function() {
|
|
|
return {
|
|
|
sortConfig: [],
|
|
|
sortName: decodeURIComponent(qs.sort_name),
|
|
|
orderConfig: [],
|
|
|
filterConfig: null,
|
|
|
|
|
|
// query
|
|
|
url: '/product/list.json',
|
|
|
sort: '',
|
|
|
order: '',
|
|
|
filter: {},
|
|
|
page: 0, // 未搜索 page=0; 全部加载完 page = totalPage; 无数据: page !=0 && productList.length=0
|
|
|
totalPage: null,
|
...
|
...
|
@@ -46,15 +47,16 @@ |
|
|
};
|
|
|
},
|
|
|
components: {
|
|
|
cheader,
|
|
|
list,
|
|
|
sort,
|
|
|
filter,
|
|
|
drawer
|
|
|
order,
|
|
|
filter
|
|
|
},
|
|
|
methods: {
|
|
|
search: function() {
|
|
|
const self = this;
|
|
|
const nextPage = this.page + 1;
|
|
|
console.log(nextPage)
|
|
|
|
|
|
if (this.inSearching) {
|
|
|
return;
|
...
|
...
|
@@ -66,9 +68,8 @@ |
|
|
}
|
|
|
|
|
|
this.inSearching = true;
|
|
|
console.log(nextPage);
|
|
|
$.get(this.url, {
|
|
|
sort: this.sort,
|
|
|
order: this.order,
|
|
|
filter: this.filter,
|
|
|
page: nextPage
|
|
|
})
|
...
|
...
|
@@ -91,6 +92,10 @@ |
|
|
});
|
|
|
},
|
|
|
|
|
|
openFilter() {
|
|
|
this.$refs.filter.isVisible = true;
|
|
|
},
|
|
|
|
|
|
openFilterSub: function(classify) {
|
|
|
console.log('TODO: open filter sub', classify);
|
|
|
},
|
...
|
...
|
@@ -105,8 +110,8 @@ |
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
/* sort 和 filter 改变 都会触发 重新搜索 */
|
|
|
sort: function() {
|
|
|
/* order 和 filter 改变 都会触发 重新搜索 */
|
|
|
order: function() {
|
|
|
this.research();
|
|
|
},
|
|
|
filter: function() {
|
...
|
...
|
@@ -122,11 +127,11 @@ |
|
|
self.search();
|
|
|
});
|
|
|
|
|
|
bus.$on('sort.change', function({
|
|
|
bus.$on('order.change', function({
|
|
|
val
|
|
|
}) {
|
|
|
console.log(val);
|
|
|
self.sort = val;
|
|
|
self.order = val;
|
|
|
});
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -134,12 +139,10 @@ |
|
|
* 1. 重新搜索
|
|
|
* 2. 关闭 drawer 组件
|
|
|
*/
|
|
|
bus.$on('filter.change', function({
|
|
|
val
|
|
|
}) {
|
|
|
bus.$on('filter.change', function({val}) {
|
|
|
console.log(val);
|
|
|
self.filter = val;
|
|
|
self.$refs.drawer.on = false;
|
|
|
self.$refs.filter.isVisible = false;
|
|
|
});
|
|
|
|
|
|
/**
|
...
|
...
|
|