|
- var config = require("../../config/config.js");
- var app = getApp();
- const Http = require("../../utils/HttpBasics");
- let util = require("../../utils/util");
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- score: 10,
- pageNum:1,
- list:[],
- showcontent:false,
- loading:""
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
-
- },
- gotorule: function() {
- wx.navigateTo({
- url: '/pages/grade/grade',
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- let that = this;
- that.getScore();
- let pageNum = that.data.pageNum;
- let pageSize = that.data.pageSize;
- that.record(pageNum, pageSize);
- },
- record: function (pageNum) {
- let that = this;
- Http.get({
- url: config.api.scoreHistory,
- data: {
- pageNum: pageNum,
- pageSize: 15
- }
- })
- .then(res => {
- console.log(res)
- if (res.data.list.length > 0 && res.data.pageNum >= pageNum) {
- var tmpArr = that.data.list.concat(res.data.list);
-
- tmpArr.map(file => {
- file.createDate = util.formatTime(file.createDate, "yyyy-MM-dd hh:mm:ss")
- });
- that.setData({
- list:tmpArr
- })
- setTimeout(function(){
- wx.hideLoading()
- },1200)
- }
- else if (res.data.list.length == 0){
- that.setData({
- loading:"暂无数据"
- })
- setTimeout(function () {
- wx.hideLoading()
- }, 1200)
- }
- else{
- setTimeout(function () {
- wx.hideLoading()
- }, 1200)
- }
- })
- .catch(err => {
- wx.showModal({
- title: '抱歉',
- content: err.message,
- showCancel:false
- })
- })
- },
- 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;
- wx.showLoading({
- title: '',
- mask:true
- })
- that.data.pageNum++;
- that.setData({
- pageNum: that.data.pageNum
- });
- that.record(that.data.pageNum);
- }
- })
|