123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- const util = require('../../../utils/util.js');
- const app = getApp();
- Page({
- data: {
- isLoadMore:true,
- pageSize: 10,
- pageIndex: 1,
- info:[],
- childInfo:{
- integral: 0
- }
- },
- onLoad: function (childInfo) {
- this.setData({ childInfo });
- if (util.isObjEmpty(childInfo) || util.isEmpty(childInfo.campId) || util.isEmpty(childInfo.playerId)){
- util.showTips("缺少参数。");
- return false;
- }
- this.getIntegral(true);
- },
- getIntegral(load){
- let self = this;
- util.ajax({
- func: "v2/course/score/list",
- data: { "campId": self.data.childInfo.campId, "playerId": self.data.childInfo.playerId, "pageIndex": self.data.pageIndex, "pageSize": self.data.pageSize },
- load: load
- }, function(res) {
- if (res.code == 0) {
- let isLoadMore = true;
- let newData = res.data.list;
- let oldData = !load ? newData : [...self.data.info, ...newData];
- if (oldData.length >= self.data.pageSize) isLoadMore = false;
- self.setData({ info: oldData, isLoadMore });
- } else
- util.showTips(res.reason);
- });
- },
- onPullDownRefresh() {
- var self = this;
- wx.showNavigationBarLoading();
- setTimeout(()=> {
- self.setData({ pageIndex: 1 });
- self.getIntegral(false);
- wx.hideNavigationBarLoading();
- wx.stopPullDownRefresh();
- }, 1000);
- },
- onReachBottom() {
- var self = this;
- if (self.data.isLoadMore == false) return false;
- setTimeout(() => {
- self.setData({ pageIndex: self.data.pageIndex + 1 });
- self.getIntegral(true);
- }, 1000);
- }
- })
|