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.

118 lines
2.4 KiB

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