...
|
...
|
@@ -6,21 +6,46 @@ let app = getApp(); |
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
query: '',
|
|
|
order: '',
|
|
|
gender: '',
|
|
|
searched: false,
|
|
|
productList: []
|
|
|
productList: [],
|
|
|
showLoading: false,
|
|
|
showNoMore: false,
|
|
|
currentPage: 0,
|
|
|
totalPage: 1,
|
|
|
urlParams: {}
|
|
|
},
|
|
|
onLoad:function (options) {
|
|
|
let title = parse(options.title) || '默认标题';
|
|
|
|
|
|
let title = decodeURIComponent(options.title) || '默认标题';
|
|
|
|
|
|
delete options.title;
|
|
|
wx.setNavigationBarTitle({
|
|
|
title
|
|
|
});
|
|
|
|
|
|
this.productList();
|
|
|
|
|
|
this.setData({
|
|
|
urlParams: options
|
|
|
});
|
|
|
this.productList(options);
|
|
|
},
|
|
|
onReachBottom: function () {
|
|
|
this.productList(this.data.urlParams);
|
|
|
},
|
|
|
productList: function (params) {
|
|
|
productList: function (params = {}) {
|
|
|
params.page = this.data.currentPage + 1;
|
|
|
|
|
|
if (params.page > this.data.totalPage) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (this.data.isLoading) return;
|
|
|
|
|
|
this.data.isLoading = true;
|
|
|
wx.showLoading({title: '加载中'});
|
|
|
params.order = this.data.order;
|
|
|
params.gender = this.data.gender;
|
|
|
params.limit = 20;
|
|
|
listModel.productList(params).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
const keyAdapter = {
|
...
|
...
|
@@ -40,20 +65,27 @@ Page({ |
|
|
list.push(item);
|
|
|
});
|
|
|
|
|
|
this.data.isLoading = false;
|
|
|
wx.hideLoading();
|
|
|
this.setData({
|
|
|
productList: list
|
|
|
showLoading: false,
|
|
|
productList: this.data.productList.concat(list),
|
|
|
currentPage: params.page,
|
|
|
totalPage: res.data.page_total,
|
|
|
showNoMore: params.page === res.data.page_total
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
sortChange: function (e) {
|
|
|
let params;
|
|
|
let {curSort, gender} = e.detail;
|
|
|
|
|
|
params = {
|
|
|
gender,
|
|
|
order: curSort,
|
|
|
};
|
|
|
this.productList(params)
|
|
|
},
|
|
|
this.data.gender = gender;
|
|
|
this.data.order = curSort;
|
|
|
this.data.currentPage = 0;
|
|
|
this.data.totalPage = 1;
|
|
|
|
|
|
this.data.productList = [];
|
|
|
this.productList(this.data.urlParams);
|
|
|
}
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|