center.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // pointExchange/pages/center/center.js
  2. const app = getApp();
  3. import util from '../../../utils/util.js'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. appAssetsUrl:app.appAssetsUrl,
  10. statusBarHeight: 0,
  11. statusBarMH: 0,
  12. nodata: util.nodata(),
  13. params: {
  14. pageNum: 1,
  15. pageSize: 10,
  16. stuId: util.getUserId()
  17. },
  18. total:{
  19. currPage: 0,
  20. totalPage: 0
  21. },
  22. noMore:false,
  23. totalScore: '--',
  24. listData:[]
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. this.height();
  31. this.loadList(true);
  32. this.setData({
  33. totalScore: options.totalScore
  34. })
  35. },
  36. bindscrolltolower(){
  37. this.loadList();
  38. },
  39. loadList(isRefresh) {
  40. let that = this;
  41. if (!isRefresh && this.data.noMore) {
  42. wx.showToast({
  43. title: '没有更多了~',
  44. icon: 'none'
  45. })
  46. return false;
  47. }
  48. this.setData({
  49. listData: isRefresh ? [] : this.data.listData,
  50. noMore: isRefresh ? false : this.data.noMore,
  51. params: {
  52. ...this.data.params,
  53. pageNum: isRefresh?1:this.data.params.pageNum+1
  54. }
  55. })
  56. wx.showLoading({
  57. title: '努力加载中...',
  58. })
  59. app._post_form('scoreStu/page', '', this.data.params,
  60. function(res) {
  61. if (res.code == 0) {
  62. if(res.page.list.length>0 && that.data.listData.length>0 && res.page.list[0].id == that.data.listData[0].id){
  63. return ;
  64. }
  65. let listData = that.data.listData;
  66. listData.push(...res.page.list);
  67. that.setData({
  68. listData,
  69. currPage: res.page.currPage,
  70. totalPage: res.page.totalPage,
  71. noMore: res.page.totalPage == res.page.currPage
  72. })
  73. }
  74. })
  75. },
  76. /**
  77. * 生命周期函数--监听页面初次渲染完成
  78. */
  79. onReady: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面显示
  83. */
  84. onShow: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面隐藏
  88. */
  89. onHide: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面卸载
  93. */
  94. onUnload: function () {
  95. },
  96. /**
  97. * 页面相关事件处理函数--监听用户下拉动作
  98. */
  99. onPullDownRefresh: function () {
  100. },
  101. /**
  102. * 页面上拉触底事件的处理函数
  103. */
  104. onReachBottom: function () {
  105. },
  106. /**
  107. * 用户点击右上角分享
  108. */
  109. onShareAppMessage: function () {
  110. },
  111. // 自定义高度处理
  112. height() {
  113. const { platform, statusBarHeight } = wx.getSystemInfoSync()
  114. let height = statusBarHeight + 4 //ios 24px
  115. let mH = statusBarHeight + 4
  116. if (platform.toLowerCase() == "android") {
  117. height += 4 //android 28px
  118. mH += 4
  119. }
  120. height = height + 38
  121. // 胶囊高度 32px 下边框6px height 状态栏高度
  122. this.setData({
  123. statusBarHeight: height + 'px',
  124. statusBarMH: mH + 'px'
  125. })
  126. },
  127. back(){
  128. wx.navigateBack();
  129. }
  130. })