|  | const navigationBarHeight = (getApp().statusBarHeight + 44) + '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");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    navigationBarHeight,
    score: 10,
    pageNum:1,
    list:[],
    showcontent:false,
    loadingUrl: imgurl.loading.url,
    bgg: imgurl.bgg.url,
    allow_load: true
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
  },
  gotorule: function() {
    wx.navigateTo({
      url: '/pages/grade/grade',
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this;
    that.getScore();
    that.record(1, 15);
  },
  record(pageNum) {
    var that = this;
    if (that.data.allow_load) {
      Http.get({
        url: config.api.scoreHistory,
        data: {
          pageNum: pageNum,
          pageSize: 20,
        }
      }).then(res => {
        wx.stopPullDownRefresh();
        res.data.list.map(file => {
          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
        });
      })
        .catch(err => {
          wx.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);
  },
  getScore: function() {
    let that = this;
    Http.get({
        url: config.api.getScore,
        data: {}
      })
      .then(res => {
        console.log(res)
        that.setData({
          score: res.data.score,
          levelName: res.data.levelName,
        })
      })
  },
  onReachBottom: function () {
    var that = this;
    that.data.pageNum++;
    that.setData({
      pageNum: that.data.pageNum
    });
    that.record(that.data.pageNum);
  }
})
 |