Authored by yyq

Merge branch 'develop' of git.yoho.cn:fe/yoho-brand-shop into develop

... ... @@ -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
... ...
... ... @@ -3,7 +3,9 @@
<product-list-filter bind:sortchange="sortChange"></product-list-filter>
</view>
<view class="list-view">
<product-list list="{{productList}}"></product-list>
<product-list list="{{productList}}"
show-loading="{{showLoading}}"
show-no-more="{{showNoMore}}"></product-list>
</view>
<copyright></copyright>
</scroll-view>
\ No newline at end of file
... ...
... ... @@ -76,6 +76,7 @@ Page({
if (this.data.isLoading) return;
this.data.isLoading = true;
wx.showLoading({title: '加载中'});
params.order = this.data.order;
params.gender = this.data.gender;
params.shop_id = this.data.shopId;
... ... @@ -99,6 +100,7 @@ Page({
});
this.data.isLoading = false;
wx.hideLoading();
this.setData({
showLoading: false,
productList: this.data.productList.concat(list),
... ... @@ -173,9 +175,6 @@ Page({
});
}
let shopInfo = data.data;
let logoUrl = shopInfo.shop_logo.replace(/{width}/g, 100).replace(/{height}/g, 100).replace('{mode}', 2);
shopInfo.shop_logo = logoUrl;
... ... @@ -194,14 +193,6 @@ Page({
},
snapshootShareData: shareData
});
})
.catch(error => {
// this.setData({
// info: {
// isLoading: false,
// error,
// }
// });
});
},
shopDecFloor: function() {
... ...