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.

111 lines
2.3 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. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. score: 10,
  11. pageNum:1,
  12. list:[],
  13. showcontent:false,
  14. loading:""
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function(options) {
  20. },
  21. gotorule: function() {
  22. wx.navigateTo({
  23. url: '/pages/grade/grade',
  24. })
  25. },
  26. /**
  27. * 生命周期函数--监听页面显示
  28. */
  29. onShow: function () {
  30. let that = this;
  31. that.getScore();
  32. let pageNum = that.data.pageNum;
  33. let pageSize = that.data.pageSize;
  34. that.record(pageNum, pageSize);
  35. },
  36. record: function (pageNum) {
  37. let that = this;
  38. Http.get({
  39. url: config.api.scoreHistory,
  40. data: {
  41. pageNum: pageNum,
  42. pageSize: 15
  43. }
  44. })
  45. .then(res => {
  46. console.log(res)
  47. if (res.data.list.length > 0 && res.data.pageNum >= pageNum) {
  48. var tmpArr = that.data.list.concat(res.data.list);
  49. tmpArr.map(file => {
  50. file.createDate = util.formatTime(file.createDate, "yyyy-MM-dd hh:mm:ss")
  51. });
  52. that.setData({
  53. list:tmpArr
  54. })
  55. setTimeout(function(){
  56. wx.hideLoading()
  57. },1200)
  58. }
  59. else if (res.data.list.length == 0){
  60. that.setData({
  61. loading:"暂无数据"
  62. })
  63. setTimeout(function () {
  64. wx.hideLoading()
  65. }, 1200)
  66. }
  67. else{
  68. setTimeout(function () {
  69. wx.hideLoading()
  70. }, 1200)
  71. }
  72. })
  73. .catch(err => {
  74. wx.showModal({
  75. title: '抱歉',
  76. content: err.message,
  77. showCancel:false
  78. })
  79. })
  80. },
  81. getScore: function() {
  82. let that = this;
  83. Http.get({
  84. url: config.api.getScore,
  85. data: {}
  86. })
  87. .then(res => {
  88. console.log(res)
  89. that.setData({
  90. score: res.data.score,
  91. levelName: res.data.levelName,
  92. })
  93. })
  94. },
  95. onReachBottom: function () {
  96. var that = this;
  97. wx.showLoading({
  98. title: '',
  99. mask:true
  100. })
  101. that.data.pageNum++;
  102. that.setData({
  103. pageNum: that.data.pageNum
  104. });
  105. that.record(that.data.pageNum);
  106. }
  107. })