搜索完成

This commit is contained in:
2020-08-09 18:29:36 +08:00
parent d00b4a75ac
commit b9b9a8e829
7 changed files with 304 additions and 75 deletions

View File

@@ -36,24 +36,29 @@ export default {
goodsList: [],
scrollHeight: '',
loadStatus: 'loadmore',
timer: true, // 防止上拉加载短时间内多次调用
timer: true, // 防止上拉加载短时间内多次调用,
value:""
}
},
watch: {
current(value) {
this.page = 1;
this.goodsListByClassId({ laod: 'reload' });
this.ShopSearch({ laod: 'reload' });
},
priceOrderAsc(value) {
this.page = 1;
this.goodsListByClassId({ laod: 'reload' });
this.ShopSearch({ laod: 'reload' });
}
},
onLoad(option) {
this.cid = option.cid;
this.goodsListByClassId({ load: 'reload' });
this.value = option.value
this.setViewHeight();
this.setTitle(option.cname);
this.ShopSearch()
},
onNavigationBarSearchInputConfirmed(value) {
this.value = value.text
this.ShopSearch()
},
methods: {
setOrderSort() {
@@ -69,10 +74,10 @@ export default {
return sort;
},
// 排序方式 goods_salenum销量 evaluation_count评价 goods_price_asc价格从低到高 goods_price_desc价格从高到低
async goodsListByClassId({ load = 'reload' } = {}) {
async ShopSearch({ load = 'reload' } = {}) {
const sort = this.setOrderSort();
const res = await this.$u.api.goodsListByClassId({
gc_id: this.cid,
const res = await this.$u.api.ShopSearch({
keyword: this.value,
page: this.page,
order: sort,
})
@@ -88,7 +93,7 @@ export default {
if(!this.timer) return false;
this.loadStatus = "loading";
this.page++;
this.goodsListByClassId({ load: 'loadmore' }).then(length => {
this.ShopSearch({ load: 'loadmore' }).then(length => {
if(length == 0) {
this.page--;
this.loadStatus = 'nomore';
@@ -101,22 +106,17 @@ export default {
})
},
switchCurrent(current) {
this.ShopSearch()
if(current == 1 && this.current == 1) this.priceOrderAsc = !this.priceOrderAsc;
this.current = current;
},
setViewHeight() {
const res = uni.getSystemInfoSync();
this.scrollHeight = res.windowHeight - (90 / 2) + 'px';
},
setTitle(title) {
uni.setNavigationBarTitle({
title: title
});
this.scrollHeight = res.windowHeight - res.windowWidth / 750 * 90 + 'px';
},
toDetailsPage(id) {
this.$u.route('/pageB/sdetails/index', {
id: id,
type: 1 // 商品详情 商品类型 1普通 2拼团 3秒杀 4优惠券
id: id
});
}
}