C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 line
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. allow_load: true
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function(options) {
  22. },
  23. gotorule: function() {
  24. wx.navigateTo({
  25. url: '/pages/grade/grade',
  26. })
  27. },
  28. /**
  29. * 生命周期函数--监听页面显示
  30. */
  31. onShow: function () {
  32. let that = this;
  33. that.getScore();
  34. that.record(1, 15);
  35. },
  36. record(pageNum) {
  37. var that = this;
  38. if (that.data.allow_load) {
  39. Http.get({
  40. url: config.api.scoreHistory,
  41. data: {
  42. pageNum: pageNum,
  43. pageSize: 20,
  44. }
  45. }).then(res => {
  46. res.data.list.map(file => {
  47. file.createDate = util.formatTime(
  48. file.createDate,
  49. "yyyy-MM-dd hh:mm:ss"
  50. );
  51. });
  52. if (pageNum >= res.data.pages) {
  53. that.setData({
  54. allow_load: false,
  55. });
  56. }
  57. that.data.list = that.data.list.concat(res.data.list);
  58. that.setData({
  59. list: that.data.list
  60. });
  61. })
  62. .catch(err => {
  63. wx.showToast({
  64. title: err.errMsg,
  65. icon: 'none',
  66. duration: 2000,
  67. mask: false
  68. });
  69. })
  70. }
  71. },
  72. getScore: function() {
  73. let that = this;
  74. Http.get({
  75. url: config.api.getScore,
  76. data: {}
  77. })
  78. .then(res => {
  79. console.log(res)
  80. that.setData({
  81. score: res.data.score,
  82. levelName: res.data.levelName,
  83. })
  84. })
  85. },
  86. onReachBottom: function () {
  87. var that = this;
  88. that.data.pageNum++;
  89. that.setData({
  90. pageNum: that.data.pageNum
  91. });
  92. that.record(that.data.pageNum);
  93. }
  94. })