const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px' var config = require("../../../config/config.js"); var app = getApp(); const Http = require("../../../utils/HttpBasics"); let util = require("../../../utils/util"); const imgurl = require("../../../utils/imgurl"); const {creditType} = require("../../../utils/creditType"); Page({ /** * 页面的初始数据 */ data: { navigationBarHeight, score: 10, pageNum: 1, list: [], showcontent: false, loadingUrl: imgurl.loading.url, bgg: imgurl.bgg.url, allow_load: true, creditAmount:0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, gotorule: function () { tt.navigateTo({ url: '/pages/grade/grade', }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { let that = this; that.record(1, 15); }, record(pageNum) { var that = this; if (that.data.allow_load) { Http.get({ url: config.api.integralList, data: { pageNum: pageNum, pageSize: 20, } }).then(res => { tt.stopPullDownRefresh(); res.data.list.map(file => { creditType.map((item,index)=>{ if (file.creditType==item.value){ file.creditTypeName = item.name; } }) file.createDate = util.formatTime( file.createDate, "yyyy-MM-dd hh:mm:ss" ); }); if (pageNum >= res.data.pages) { that.setData({ allow_load: false, }); } that.data.list = that.data.list.concat(res.data.list); that.setData({ list: that.data.list, creditAmount: that.data.list[0].creditAmount }); }) .catch(err => { tt.stopPullDownRefresh(); tt.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) } }, /** * 刷新 */ onPullDownRefresh: function (e) { let that = this; that.setData({ pageNum: 1, list:[], allow_load:true }); that.record(1); }, onReachBottom: function () { var that = this; that.data.pageNum++; that.setData({ pageNum: that.data.pageNum }); that.record(that.data.pageNum); } })