center.js 2.7 KB

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