|
|
|
@ -70,7 +70,8 @@ |
|
|
|
this.scrollH = info.screenHeight; |
|
|
|
this.value = options.value || ''; |
|
|
|
if(options.value){ |
|
|
|
this.getSearchList(options.value); |
|
|
|
this.getSearchGoodsList(options.value); |
|
|
|
this.getSearchBrandList(options.value); |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
@ -92,15 +93,17 @@ |
|
|
|
beforePage.$vm.updateHistory(value).then(() => { |
|
|
|
beforePage.$vm.setHistorySearch(); |
|
|
|
}) |
|
|
|
this.getSearchList(value); |
|
|
|
this.getSearchGoodsList(value); |
|
|
|
this.getSearchBrandList(value); |
|
|
|
}else{ |
|
|
|
this.$msg('页面路径出错,当前搜索值将不被记录搜索历史').then(() => { |
|
|
|
this.getSearchList(value); |
|
|
|
this.getSearchGoodsList(value); |
|
|
|
this.getSearchBrandList(value); |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
// 获取搜索列表 |
|
|
|
getSearchList(value){ |
|
|
|
// 获取搜索商品列表 |
|
|
|
getSearchGoodsList(value){ |
|
|
|
uni.showLoading({ |
|
|
|
title: '正在搜索中' |
|
|
|
}) |
|
|
|
@ -111,44 +114,56 @@ |
|
|
|
page: this.page |
|
|
|
} |
|
|
|
}).then(res => { |
|
|
|
uni.hideLoading(); |
|
|
|
if(res.data.status){ |
|
|
|
// TODO 搜索接口已改,需重新对接 |
|
|
|
if(this.$isRight(res.data.data)){ |
|
|
|
let goods = res.data.data.goods; |
|
|
|
let brand = res.data.data.brand; |
|
|
|
let isPage = this.$isRight(goods.next_page_url); |
|
|
|
this.isPage = isPage; |
|
|
|
|
|
|
|
let list = goods.data.map(item => { |
|
|
|
return { |
|
|
|
id: item.id, |
|
|
|
original_price: item.min_market_price, |
|
|
|
picture: item.img, |
|
|
|
pictures: [item.img], |
|
|
|
price: item.min_price, |
|
|
|
sale: item.sale_count, |
|
|
|
title: item.name |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
if(this.page == 1){ |
|
|
|
this.goods_list = list; |
|
|
|
}else{ |
|
|
|
this.goods_list.push(...list); |
|
|
|
let goods = res.data.data || []; |
|
|
|
let pagination = res.data.meta.pagination; |
|
|
|
let isPage = pagination.current_page != pagination.total_pages; |
|
|
|
this.isPage = isPage; |
|
|
|
if(goods.length <= 0){ |
|
|
|
this.tab_list[0].name = `商品(0)`; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
let list = goods.map(item => { |
|
|
|
return { |
|
|
|
id: item.id, |
|
|
|
original_price: item.market_price, |
|
|
|
picture: item.img, |
|
|
|
pictures: [item.img], |
|
|
|
price: item.sell_price, |
|
|
|
sale: item.sale_count, |
|
|
|
title: item.name |
|
|
|
} |
|
|
|
console.log("this.goods_list", this.goods_list) |
|
|
|
this.brand_list = brand; |
|
|
|
this.tab_list[1].name = `商户(${brand.length})`; |
|
|
|
this.tab_list[0].name = `商品(${this.goods_list.length})`; |
|
|
|
}) |
|
|
|
if(this.page == 1){ |
|
|
|
this.goods_list = list; |
|
|
|
}else{ |
|
|
|
this.$msg('该关键词没有数据哦~') |
|
|
|
this.goods_list.push(...list); |
|
|
|
} |
|
|
|
this.tab_list[0].name = `商品(${this.goods_list.length})`; |
|
|
|
}else{ |
|
|
|
this.$msg(res.data.message || '服务器错误,请稍后再试'); |
|
|
|
} |
|
|
|
uni.hideLoading(); |
|
|
|
}).catch(err => uni.hideLoading()); |
|
|
|
}, |
|
|
|
// 获取搜索品牌列表 |
|
|
|
getSearchBrandList(value){ |
|
|
|
this.$http.get({ |
|
|
|
api: 'api/brand', |
|
|
|
data: { |
|
|
|
name: value |
|
|
|
} |
|
|
|
}).then(res => { |
|
|
|
if(res.data.status){ |
|
|
|
let list = res.data.data.list || []; |
|
|
|
this.brand_list = list; |
|
|
|
this.tab_list[1].name = `商户(${list.length})`; |
|
|
|
}else{ |
|
|
|
this.$msg(res.data.message || '服务器错误,请稍后再试'); |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 切换tab |
|
|
|
tabChange(event){ |
|
|
|
this.tab_current = event; |
|
|
|
@ -163,7 +178,7 @@ |
|
|
|
if(this.tab_current == 0){ |
|
|
|
if(this.isPage){ |
|
|
|
this.page++; |
|
|
|
this.getSearchList(this.value); |
|
|
|
this.getSearchGoodsList(this.value); |
|
|
|
}else{ |
|
|
|
this.$msg('没有更多啦~'); |
|
|
|
} |
|
|
|
|