...
|
...
|
@@ -7,16 +7,57 @@ Page({ |
|
|
data: {
|
|
|
query: '',
|
|
|
order: '',
|
|
|
gender: '',
|
|
|
searched: false,
|
|
|
productList: []
|
|
|
productList: [],
|
|
|
isLoading: false,
|
|
|
currentPage: 0,
|
|
|
totalPage: 0,
|
|
|
showLoading: false,
|
|
|
showNoMore: false
|
|
|
},
|
|
|
onReachBottom: function () {
|
|
|
if (this.data.currentPage < this.data.totalPage) {
|
|
|
this.setData({
|
|
|
showLoading: true
|
|
|
});
|
|
|
this.productList({
|
|
|
query: this.data.query,
|
|
|
order: this.data.order,
|
|
|
gender: this.data.gender,
|
|
|
page: this.data.currentPage + 1,
|
|
|
limit: 20
|
|
|
});
|
|
|
} else {
|
|
|
this.setData({
|
|
|
showNoMore: true
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
bindQueryInput: function(e) {
|
|
|
this.setData({
|
|
|
query: e.detail.value
|
|
|
});
|
|
|
},
|
|
|
confirmQuery: function (e) {
|
|
|
let query = e.detail.value;
|
|
|
let query = e.detail.value.trim();
|
|
|
|
|
|
if (!query) {
|
|
|
return wx.showToast({
|
|
|
title: '请输入检索关键词',
|
|
|
icon: 'none',
|
|
|
duration: 1000
|
|
|
});
|
|
|
}
|
|
|
|
|
|
this.setData({searched: true, query});
|
|
|
this.search({query});
|
|
|
this.data.productList = [];
|
|
|
this.productList({page: 1, limit: 20, query, order: this.data.order, gender: this.data.gender});
|
|
|
},
|
|
|
search: function (params) {
|
|
|
productList: function (params) {
|
|
|
if (this.data.isLoading) return;
|
|
|
|
|
|
this.data.isLoading = true;
|
|
|
searchModel.productList(params).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
const keyAdapter = {
|
...
|
...
|
@@ -36,13 +77,33 @@ Page({ |
|
|
list.push(item);
|
|
|
});
|
|
|
|
|
|
this.data.isLoading = false;
|
|
|
this.setData({
|
|
|
productList: list
|
|
|
showLoading: false,
|
|
|
productList: this.data.productList.concat(list),
|
|
|
currentPage: params.page,
|
|
|
totalPage: res.data.page_total
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}).catch(() => {
|
|
|
this.data.isLoading = false;
|
|
|
});
|
|
|
},
|
|
|
orderChange: function () {
|
|
|
sortChange: function (e) {
|
|
|
let params;
|
|
|
let {curSort, gender} = e.detail;
|
|
|
|
|
|
this.data.gender = gender;
|
|
|
this.data.order = curSort;
|
|
|
|
|
|
params = {
|
|
|
gender,
|
|
|
order: curSort,
|
|
|
page: 1,
|
|
|
limit: 20,
|
|
|
query: this.data.query
|
|
|
};
|
|
|
this.data.productList = [];
|
|
|
this.productList(params);
|
|
|
}
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|