Authored by 陈轩

list 抖动

... ... @@ -3,7 +3,7 @@
<cheader :title="sortName" class="list-header">
<i class="icon icon-filter" slot="right" @click="openFilter"></i>
</cheader>
<order :config="orderConfig" :val="order" V-if="!empty"></order>
<order :config="orderConfig" :val="order" v-if="enableOrder"></order>
<List :data="productList" :empty="empty"></List>
<Filter :config="filterConfig" v-ref:filter></Filter>
</div>
... ... @@ -46,7 +46,8 @@
productList: [],
// state
inSearching: false // 请求中
inSearching: false, // 请求中
enableOrder: false
};
},
computed: {
... ... @@ -75,7 +76,7 @@
}
this.inSearching = true;
$.get(this.url, Object.assign({
return $.get(this.url, Object.assign({
order: this.order,
page: nextPage
}, this.filter, locationQuery))
... ... @@ -152,7 +153,12 @@
self.$refs.filter.isVisible = false;
});
this.search();
this.search()
.then(()=>{
if (self.productList.length) {
self.enableOrder = true;
}
});
}
};
... ...
... ... @@ -3,7 +3,7 @@
<cheader title="新品抢先看">
<i class="icon icon-filter" slot="right" @click="openFilter"></i>
</cheader>
<order :config="orderConfig" :val="order" v-if="!empty"></order>
<order :config="orderConfig" :val="order" v-if="enableOrder"></order>
<List :data="productList" :empty="empty"></List>
<Filter :config="filterConfig" action="/product/list.json" v-ref:filter></Filter>
</div>
... ... @@ -46,7 +46,8 @@
productList: [],
// state
inSearching: false // 请求中
inSearching: false, // 请求中
enableOrder: false
};
},
computed: {
... ... @@ -76,27 +77,27 @@
}
this.inSearching = true;
$.get(this.url, Object.assign({
return $.get(this.url, Object.assign({
order: this.order,
page: nextPage
}, this.filter, locationQuery))
.done(res => {
if (res.code === 200) {
self.page = res.data.page;
self.totalPage = res.data.pageTotal;
self.$set('productList', self.productList.concat(res.data.productList));
if (!self.filterConfig) {
self.$set('filterConfig', res.data.filter);
.done(res => {
if (res.code === 200) {
self.page = res.data.page;
self.totalPage = res.data.pageTotal;
self.$set('productList', self.productList.concat(res.data.productList));
if (!self.filterConfig) {
self.$set('filterConfig', res.data.filter);
}
}
}
})
.fail(error => {
tip('网络出错~');
})
.always(() => {
self.inSearching = false;
});
})
.fail(error => {
tip('网络出错~');
})
.always(() => {
self.inSearching = false;
});
},
openFilter() {
... ... @@ -157,7 +158,12 @@
self.$refs.filter.isVisible = false;
});
this.search();
this.search()
.then(()=>{
if (self.productList.length) {
self.enableOrder = true;
}
});
}
};
... ...
<template>
<div>
<Order :config="orderConfig" :val="order" v-if="!empty">
<Order :config="orderConfig" :val="order" v-if="enableOrder">
</Order>
<List :data="productList" :empty="empty"></List>
</div>
... ... @@ -40,7 +40,8 @@
productList: [],
// state
inSearching: false // 请求中
inSearching: false, // 请求中
enableOrder: false
};
},
computed: {
... ... @@ -69,24 +70,24 @@
this.inSearching = true;
console.log(nextPage);
$.get(this.url, {
return $.get(this.url, {
order: this.order, // 排序 信息
query: this.query,
page: nextPage
})
.done(res => {
if (res.code === 200) {
self.page = res.data.page;
self.totalPage = res.data.pageTotal;
self.$set('productList', self.productList.concat(res.data.productList));
}
})
.fail(error => {
tip('网络出错~');
})
.always(() => {
self.inSearching = false;
});
.done(res => {
if (res.code === 200) {
self.page = res.data.page;
self.totalPage = res.data.pageTotal;
self.$set('productList', self.productList.concat(res.data.productList));
}
})
.fail(error => {
tip('网络出错~');
})
.always(() => {
self.inSearching = false;
});
},
/**
... ... @@ -119,7 +120,12 @@
self.order = val;
});
this.search();
this.search()
.then(()=>{
if (self.productList.length) {
self.enableOrder = true;
}
});
}
};
... ...