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.

114 lines
2.3 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. /**
  32. * 生命周期函数--监听页面显示
  33. */
  34. onShow: function () {
  35. let that = this;
  36. that.getScore();
  37. that.record(1, 15);
  38. },
  39. record(pageNum) {
  40. var that = this;
  41. if (that.data.allow_load) {
  42. Http.get({
  43. url: config.api.scoreHistory,
  44. data: {
  45. pageNum: pageNum,
  46. pageSize: 20,
  47. }
  48. }).then(res => {
  49. wx.stopPullDownRefresh();
  50. res.data.list.map(file => {
  51. file.createDate = util.formatTime(
  52. file.createDate,
  53. "yyyy-MM-dd hh:mm:ss"
  54. );
  55. });
  56. if (pageNum >= res.data.pages) {
  57. that.setData({
  58. allow_load: false,
  59. });
  60. }
  61. that.data.list = that.data.list.concat(res.data.list);
  62. that.setData({
  63. list: that.data.list
  64. });
  65. })
  66. .catch(err => {
  67. wx.showToast({
  68. title: err.errMsg,
  69. icon: 'none',
  70. duration: 2000,
  71. mask: false
  72. });
  73. })
  74. }
  75. },
  76. /**
  77. * 刷新
  78. */
  79. onPullDownRefresh: function (e) {
  80. let that = this;
  81. that.setData({
  82. pageNum: 1,
  83. list: [],
  84. allow_load: true
  85. });
  86. that.record(1);
  87. },
  88. getScore: function () {
  89. let that = this;
  90. Http.get({
  91. url: config.api.getScore,
  92. data: {}
  93. })
  94. .then(res => {
  95. console.log(res)
  96. that.setData({
  97. score: res.data.score,
  98. levelName: res.data.levelName,
  99. })
  100. })
  101. },
  102. onReachBottom: function () {
  103. var that = this;
  104. that.data.pageNum++;
  105. that.setData({
  106. pageNum: that.data.pageNum
  107. });
  108. that.record(that.data.pageNum);
  109. }
  110. })