...
|
...
|
@@ -2,22 +2,23 @@ import wx from '../../../utils/wx'; |
|
|
import Yas from '../../../common/yas';
|
|
|
import listModel from '../../../models/product/list';
|
|
|
|
|
|
const {windowHeight} = getApp().getSystemInfo();
|
|
|
let yas;
|
|
|
const app = getApp();
|
|
|
const {windowHeight} = getApp().getSystemInfo();
|
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
order: '',
|
|
|
gender: '',
|
|
|
searched: false,
|
|
|
productList: [],
|
|
|
showLoading: false,
|
|
|
showNoMore: false,
|
|
|
currentPage: 0,
|
|
|
|
|
|
// 原始参数
|
|
|
orgOps: {},
|
|
|
|
|
|
page: 1,
|
|
|
limit: 20,
|
|
|
totalPage: 1,
|
|
|
urlParams: {},
|
|
|
showBackTop: false,
|
|
|
allLoaded: false,
|
|
|
productList: [],
|
|
|
noResult: false,
|
|
|
windowHeight
|
|
|
},
|
...
|
...
|
@@ -31,12 +32,7 @@ Page({ |
|
|
});
|
|
|
delete options.title;
|
|
|
|
|
|
options.shop_id = app.getShopId();
|
|
|
|
|
|
this.setData({
|
|
|
urlParams: options
|
|
|
});
|
|
|
this.productList(options);
|
|
|
this._productList();
|
|
|
|
|
|
yas = new Yas();
|
|
|
yas.pageOpenReport();
|
...
|
...
|
@@ -54,38 +50,42 @@ Page({ |
|
|
});
|
|
|
},
|
|
|
onReachBottom: function() {
|
|
|
this.productList(this.data.urlParams);
|
|
|
this._productList();
|
|
|
},
|
|
|
setBrandTitle: function(brandId) {
|
|
|
listModel.brandIntro(brandId).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: res.data.brand_name
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
.catch(() => {
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: '商品列表'
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 筛选变更
|
|
|
filterChange: function(e) {
|
|
|
let {curSort, gender} = e.detail;
|
|
|
|
|
|
this.data.order = curSort;
|
|
|
this.data.gender = gender;
|
|
|
|
|
|
this._resetPage();
|
|
|
this.data.productList = [];
|
|
|
this._productList();
|
|
|
},
|
|
|
productList: function(params = {}) {
|
|
|
params.page = this.data.currentPage + 1;
|
|
|
|
|
|
if (params.page > this.data.totalPage) {
|
|
|
return;
|
|
|
}
|
|
|
_resetPage: function() {
|
|
|
this.data.page = 1;
|
|
|
this.data.totalPage = 1;
|
|
|
this.data.allLoaded = false;
|
|
|
},
|
|
|
|
|
|
if (this.data.isLoading) {
|
|
|
// 商品列表
|
|
|
_productList: function(params = {}) {
|
|
|
if (this.data.allLoaded) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
this.data.isLoading = true;
|
|
|
wx.showLoading({title: '加载中'});
|
|
|
this.setData({
|
|
|
showLoading: true
|
|
|
});
|
|
|
|
|
|
params.page = this.data.page;
|
|
|
params.limit = this.data.limit;
|
|
|
params.order = this.data.order;
|
|
|
params.gender = this.data.gender;
|
|
|
params.limit = 20;
|
|
|
params.shop_id = app.getShopId();
|
|
|
listModel.productList(params).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
const keyAdapter = {
|
...
|
...
|
@@ -106,35 +106,15 @@ Page({ |
|
|
list.push(item);
|
|
|
});
|
|
|
|
|
|
this.data.isLoading = false;
|
|
|
wx.hideLoading();
|
|
|
this.data.page += 1;
|
|
|
this.data.totalPage = res.data && res.data.page_total || 1;
|
|
|
|
|
|
this.setData({
|
|
|
showLoading: false,
|
|
|
productList: this.data.productList.concat(list),
|
|
|
currentPage: params.page,
|
|
|
totalPage: res.data.page_total,
|
|
|
showNoMore: params.page === res.data.page_total,
|
|
|
noResult: !this.data.productList.concat(list).length
|
|
|
allLoaded: this.data.page > this.data.totalPage || params.limit > list.length,
|
|
|
productList: this.data.productList.concat(list)
|
|
|
});
|
|
|
|
|
|
if (params.resetScroll) {
|
|
|
wx.pageScrollTo({
|
|
|
scrollTop: 0,
|
|
|
duration: 10
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
sortChange: function(e) {
|
|
|
let {curSort, gender} = e.detail;
|
|
|
|
|
|
this.data.gender = gender;
|
|
|
this.data.order = curSort;
|
|
|
this.data.currentPage = 0;
|
|
|
this.data.totalPage = 1;
|
|
|
|
|
|
this.data.productList = [];
|
|
|
this.productList(Object.assign({resetScroll: true}, this.data.urlParams));
|
|
|
}).catch(() => {});
|
|
|
}
|
|
|
}); |
...
|
...
|
|