C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

103 行
2.1 KiB

  1. var config = require("../../config/config.js");
  2. var app = getApp();
  3. const Http = require("../../utils/HttpBasics");
  4. let util = require("../../utils/util");
  5. const imgurl = require("../../utils/imgurl");
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. score: 10,
  12. pageNum:1,
  13. list:[],
  14. showcontent:false,
  15. loading:"",
  16. loadingUrl: imgurl.loading.url,
  17. allow_load: true
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function(options) {
  23. },
  24. gotorule: function() {
  25. wx.navigateTo({
  26. url: '/pages/grade/grade',
  27. })
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow: function () {
  33. let that = this;
  34. that.getScore();
  35. that.record(1, 15);
  36. },
  37. record(pageNum) {
  38. var that = this;
  39. console
  40. if (that.data.allow_load) {
  41. Http.get({
  42. url: config.api.scoreHistory,
  43. data: {
  44. pageNum: pageNum,
  45. pageSize: 20,
  46. }
  47. }).then(res => {
  48. res.data.list.map(file => {
  49. file.createDate = util.formatTime(
  50. file.createDate,
  51. "yyyy-MM-dd hh:mm:ss"
  52. );
  53. });
  54. if (pageNum >= res.data.pages) {
  55. that.setData({
  56. allow_load: false
  57. });
  58. }
  59. that.data.list = that.data.list.concat(res.data.list);
  60. that.setData({
  61. list: that.data.list
  62. });
  63. })
  64. .catch(err => {
  65. wx.showToast({
  66. title: err.errMsg,
  67. icon: 'none',
  68. duration: 2000,
  69. mask: false
  70. });
  71. })
  72. }
  73. },
  74. getScore: function() {
  75. let that = this;
  76. Http.get({
  77. url: config.api.getScore,
  78. data: {}
  79. })
  80. .then(res => {
  81. console.log(res)
  82. that.setData({
  83. score: res.data.score,
  84. levelName: res.data.levelName,
  85. })
  86. })
  87. },
  88. onReachBottom: function () {
  89. var that = this;
  90. wx.showLoading({
  91. title: '',
  92. mask:true
  93. })
  94. that.data.pageNum++;
  95. that.setData({
  96. pageNum: that.data.pageNum
  97. });
  98. that.record(that.data.pageNum);
  99. }
  100. })