Commit 7fbc07bf by 姜雷

添加反馈数据切片

parent 5138e9e0
......@@ -12,18 +12,20 @@ Page({
list1: [],
list2: [],
areaList: [],
list: [],
pageNum: [null, 0, 0],
},
initData: function () {
this.fetchList(1);
this.fetchList(2);
},
toggleList: function (e) {
var _this = this;
var tabindex = e.currentTarget.dataset.tabindex;
if (tabindex !== this.data.tabIndex) {
this.setData({
tabIndex: tabindex,
this.setData({ tabIndex: tabindex }, function () {
_this.fetchList(tabindex);
});
this.fetchList(tabindex);
}
},
fetchList: function (state) {
......@@ -43,8 +45,15 @@ Page({
.then(function (res) {
wx.hideLoading();
var list = res.data;
var viewList = list.slice(0, 10);
if (state === _this.data.tabIndex) {
_this.setData({
list: viewList,
});
}
_this.setData((_a = {},
_a['list' + state] = list,
_a["pageNum[" + state + "]"] = 0,
_a));
var _a;
})
......@@ -90,5 +99,24 @@ Page({
console.log(err);
});
},
getMoreListItem: function () {
var state = this.data.tabIndex;
var index = this.data.pageNum[state] + 1;
var max = Math.ceil(this.data['list' + state].length / 10);
console.log('in getMoreListItem', index, max);
if (index >= max) {
wx.showToast({
title: '没有更多数据',
icon: 'none',
});
}
else {
this.setData((_a = {},
_a["pageNum[" + state + "]"] = index,
_a.list = this.data.list.concat(this.data['list' + state].slice(index * 10, (index + 1) * 10)),
_a));
}
var _a;
},
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlZGJhY2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJmZWVkYmFjay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHlDQUE2RDtBQUc3RCxJQUFJLENBQUM7SUFDSCxNQUFNO1FBQ0osSUFBSSxDQUFDLFFBQVEsRUFBRSxDQUFDO1FBQ2hCLElBQUksQ0FBQyxhQUFhLEVBQUUsQ0FBQztJQUN2QixDQUFDO0lBSUQsSUFBSSxFQUFFO1FBQ0osUUFBUSxFQUFFLENBQUM7UUFDWCx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kge1xuICAgIGNvbnNvbGUubG9nKGUpO1xuICAgIGNvbnN0IHsgdmFsdWUgfSA9IGUuZGV0YWlsO1xuICAgIHRoaXMuc2V0RGF0YSEoXG4gICAgICB7XG4gICAgICAgIGFyZWFJZDogdmFsdWUsXG4gICAgICB9LFxuICAgICAgKCkgPT4ge1xuICAgICAgICB0aGlzLmluaXREYXRhKCk7XG4gICAgICB9LFxuICAgICk7XG4gIH0sXG4gIHJlZnJlc2hIYW5kbGUoZSkge1xuICAgIHRoaXMuZmV0Y2hMaXN0KCk7XG4gIH0sXG4gIGZldGNoQXJlYUxpc3QoKSB7XG4gICAgYmFzZUZldGNoKHtcbiAgICAgIHVybDogJy9kY3h5L2Jhc2VBcmVhL3F1ZXJ5QWxsJyxcbiAgICB9KVxuICAgICAgLnRoZW4ocmVzID0+IHtcbiAgICAgICAgaWYgKHJlcy5kYXRhKSB7XG4gICAgICAgICAgdGhpcy5zZXREYXRhISh7XG4gICAgICAgICAgICBhcmVhTGlzdDogcmVzLmRhdGEsXG4gICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5zZXREYXRhISh7XG4gICAgICAgICAgICBhcmVhTGlzdDogW10sXG4gICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgIH0pXG4gICAgICAuY2F0Y2goZXJyID0+IHtcbiAgICAgICAgY29uc29sZS5sb2coZXJyKTtcbiAgICAgIH0pO1xuICB9LFxufSk7XG4iXX0=
\ No newline at end of file
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlZGJhY2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJmZWVkYmFjay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHlDQUE2RDtBQUc3RCxJQUFJLENBQUM7SUFDSCxNQUFNO1FBQ0osSUFBSSxDQUFDLFFBQVEsRUFBRSxDQUFDO1FBQ2hCLElBQUksQ0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HtcbiAgICAgICAgICAgIHN0YXRlLFxuICAgICAgICAgICAgYXJlYUlkOiB0aGlzLmRhdGEuYXJlYUlkLFxuICAgICAgICAgIH1cbiAgICAgICAgOiB7IHN0YXRlIH0sXG4gICAgfSlcbiAgICAgIC50aGVuKHJlcyA9PiB7XG4gICAgICAgIHd4LmhpZGVMb2FkaW5nKCk7XG4gICAgICAgIGNvbnN0IGxpc3QgPSByZXMuZGF0YTtcbiAgICAgICAgbGV0IHZpZXdMaXN0ID0gbGlzdC5zbGljZSgwLCAxMCk7XG4gICAgICAgIGlmIChzdGF0ZSA9PT0gdGhpcy5kYXRhLnRhYkluZGV4KSB7XG4gICAgICAgICAgdGhpcy5zZXREYXRhISh7XG4gICAgICAgICAgICBsaXN0OiB2aWV3TGlzdCxcbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnNldERhdGEhKHtcbiAgICAgICAgICBbJ2xpc3QnICsgc3RhdGVdOiBsaXN0LFxuICAgICAgICAgIFtgcGFnZU51bVske3N0YXRlfV1gXTogMCxcbiAgICAgICAgfSk7XG4gICAgICB9KVxuICAgICAgLmNhdGNoKGVyciA9PiB7XG4gICAgICAgIGNvbnNvbGUubG9nKGVycik7XG4gICAgICAgIHd4LnNob3dUb2FzdCh7XG4gICAgICAgICAgdGl0bGU6IGVyci5lcnJNc2csXG4gICAgICAgICAgaWNvbjogJ25vbmUnLFxuICAgICAgICB9KTtcbiAgICAgIH0pO1xuICB9LFxuICBiaW5kUGlja2VyQ2hhbmdlKGUpIHtcbiAgICBjb25zb2xlLmxvZyhlKTtcbiAgICBjb25zdCB7IHZhbHVlIH0gPSBlLmRldGFpbDtcbiAgICB0aGlzLnNldERhdGEhKFxuICAgICAge1xuICAgICAgICBhcmVhSWQ6IHZhbHVlLFxuICAgICAgfSxcbiAgICAgICgpID0+IHtcbiAgICAgICAgdGhpcy5pbml0RGF0YSgpO1xuICAgICAgfSxcbiAgICApO1xuICB9LFxuICByZWZyZXNoSG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XgsXG4gICAgICAgIGxpc3Q6IFtcbiAgICAgICAgICAuLi50aGlzLmRhdGEubGlzdCxcbiAgICAgICAgICAuLi50aGlzLmRhdGFbJ2xpc3QnICsgc3RhdGVdLnNsaWNlKGluZGV4ICogMTAsIChpbmRleCArIDEpICogMTApLFxuICAgICAgICBdLFxuICAgICAgfSk7XG4gICAgfVxuICB9LFxufSk7XG4iXX0=
\ No newline at end of file
......@@ -15,6 +15,8 @@ Page({
list1: [],
list2: [],
areaList: [],
list: [],
pageNum: [null, 0, 0],
},
initData() {
this.fetchList(1);
......@@ -23,10 +25,9 @@ Page({
toggleList(e) {
const { tabindex } = e.currentTarget.dataset;
if (tabindex !== this.data.tabIndex) {
this.setData!({
tabIndex: tabindex,
this.setData!({ tabIndex: tabindex }, () => {
this.fetchList(tabindex);
});
this.fetchList(tabindex);
}
},
fetchList(state?: number) {
......@@ -44,8 +45,15 @@ Page({
.then(res => {
wx.hideLoading();
const list = res.data;
let viewList = list.slice(0, 10);
if (state === this.data.tabIndex) {
this.setData!({
list: viewList,
});
}
this.setData!({
['list' + state]: list,
[`pageNum[${state}]`]: 0,
});
})
.catch(err => {
......@@ -90,4 +98,24 @@ Page({
console.log(err);
});
},
getMoreListItem() {
let state = this.data.tabIndex;
let index = this.data.pageNum[state] + 1;
let max = Math.ceil(this.data['list' + state].length / 10);
console.log('in getMoreListItem', index, max);
if (index >= max) {
wx.showToast({
title: '没有更多数据',
icon: 'none',
});
} else {
this.setData({
[`pageNum[${state}]`]: index,
list: [
...this.data.list,
...this.data['list' + state].slice(index * 10, (index + 1) * 10),
],
});
}
},
});
......@@ -13,10 +13,10 @@
<text class="feedback-tabCount">{{list2.length}}</text>
</view>
</view>
<view wx:if="{{tabIndex===1}}" class="feedback-list">
<feedback-item wx:for="{{list1}}" wx:key="{{item.id}}" feedback-data="{{item}}" bind:refresh="refreshHandle" />
</view>
<view wx:elif="{{tabIndex===2}}" class="feedback-list">
<feedback-item wx:for="{{list2}}" wx:key="{{item.id}}" feedback-data="{{item}}" bind:refresh="refreshHandle" />
</view>
<scroll-view wx:if="{{tabIndex===1}}" class="feedback-list" scroll-y bindscrolltolower="getMoreListItem">
<feedback-item wx:for="{{list}}" wx:key="{{item.id}}" feedback-data="{{item}}" bind:refresh="refreshHandle" />
</scroll-view>
<scroll-view wx:elif="{{tabIndex===2}}" class="feedback-list" scroll-y bindscrolltolower="getMoreListItem">
<feedback-item wx:for="{{list}}" wx:key="{{item.id}}" feedback-data="{{item}}" bind:refresh="refreshHandle" />
</scroll-view>
</view>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment