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

98 行
2.0 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. loadingUrl: imgurl.loading.url,
  16. bgg: imgurl.bgg.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. if (that.data.allow_load) {
  40. Http.get({
  41. url: config.api.scoreHistory,
  42. data: {
  43. pageNum: pageNum,
  44. pageSize: 20,
  45. }
  46. }).then(res => {
  47. res.data.list.map(file => {
  48. file.createDate = util.formatTime(
  49. file.createDate,
  50. "yyyy-MM-dd hh:mm:ss"
  51. );
  52. });
  53. if (pageNum >= res.data.pages) {
  54. that.setData({
  55. allow_load: false,
  56. });
  57. }
  58. that.data.list = that.data.list.concat(res.data.list);
  59. that.setData({
  60. list: that.data.list
  61. });
  62. })
  63. .catch(err => {
  64. wx.showToast({
  65. title: err.errMsg,
  66. icon: 'none',
  67. duration: 2000,
  68. mask: false
  69. });
  70. })
  71. }
  72. },
  73. getScore: function() {
  74. let that = this;
  75. Http.get({
  76. url: config.api.getScore,
  77. data: {}
  78. })
  79. .then(res => {
  80. console.log(res)
  81. that.setData({
  82. score: res.data.score,
  83. levelName: res.data.levelName,
  84. })
  85. })
  86. },
  87. onReachBottom: function () {
  88. var that = this;
  89. that.data.pageNum++;
  90. that.setData({
  91. pageNum: that.data.pageNum
  92. });
  93. that.record(that.data.pageNum);
  94. }
  95. })