Authored by 李奇

商品列表修改

... ... @@ -52,7 +52,7 @@ Page({
});
},
onReachBottom: function() {
this._productList(this.data.urlParams);
this._productList();
},
// 筛选变更
... ...
... ... @@ -51,7 +51,7 @@ Page({
});
},
onReachBottom: function() {
this._productList(this.data.urlParams);
this._productList();
},
// 筛选变更
... ...
... ... @@ -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
});
if (params.resetScroll) {
wx.pageScrollTo({
scrollTop: 0,
duration: 10
allLoaded: this.data.page > this.data.totalPage || params.limit > list.length,
productList: this.data.productList.concat(list)
});
}
}
});
},
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(() => {});
}
});
... ...
<view class="list-container" style="min-height:{{windowHeight}}px;">
<view class="filter-view">
<product-list-filter bind:sortchange="sortChange" cur-gender="{{gender}}"></product-list-filter>
<product-list-filter bind:sortchange="filterChange" cur-gender="{{gender}}"></product-list-filter>
</view>
<view class="list-view">
<view class="no-res" wx:if="{{noResult}}">
... ... @@ -8,9 +8,11 @@
<view class="no-res-txt">未搜索到任何相关商品</view>
</view>
<view wx:if="{{productList.length}}">
<product-list list="{{productList}}"
<product-list
list="{{productList}}"
show-loading="{{showLoading}}"
show-no-more="{{showNoMore}}"></product-list>
show-no-more="{{allLoaded}}">
</product-list>
</view>
</view>
<copyright class="copy-right"></copyright>
... ...
... ... @@ -10,7 +10,7 @@
"compileType": "miniprogram",
"libVersion": "1.9.1",
"appid": "wxe8bfc9b404772199",
"projectname": "有货官方-VANS",
"projectname": "%E6%9C%89%E8%B4%A7%E5%AE%98%E6%96%B9-VANS",
"condition": {
"search": {
"current": -1,
... ...