center.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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: 15
  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. // console.log("util.getUserId()", util.getUserId())
  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. stuId: util.getUserId()
  56. }
  57. })
  58. wx.showLoading({
  59. title: '努力加载中...',
  60. })
  61. app._post_form('scoreStu/page', '', this.data.params,
  62. function(res) {
  63. if (res.code == 0) {
  64. if(res.page.list.length>0 && that.data.listData.length>0 && res.page.list[0].id == that.data.listData[0].id){
  65. return ;
  66. }
  67. let listData = that.data.listData;
  68. listData.push(...res.page.list);
  69. that.setData({
  70. listData,
  71. currPage: res.page.currPage,
  72. totalPage: res.page.totalPage,
  73. noMore: res.page.totalPage == res.page.currPage
  74. })
  75. }
  76. })
  77. },
  78. /**
  79. * 生命周期函数--监听页面初次渲染完成
  80. */
  81. onReady: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面显示
  85. */
  86. onShow: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面隐藏
  90. */
  91. onHide: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面卸载
  95. */
  96. onUnload: function () {
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh: function () {
  102. },
  103. /**
  104. * 页面上拉触底事件的处理函数
  105. */
  106. onReachBottom: function () {
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage: function () {
  112. },
  113. // 自定义高度处理
  114. height() {
  115. const { platform, statusBarHeight } = wx.getSystemInfoSync()
  116. let height = statusBarHeight + 4 //ios 24px
  117. let mH = statusBarHeight + 4
  118. if (platform.toLowerCase() == "android") {
  119. height += 4 //android 28px
  120. mH += 4
  121. }
  122. height = height + 38
  123. // 胶囊高度 32px 下边框6px height 状态栏高度
  124. this.setData({
  125. statusBarHeight: height + 'px',
  126. statusBarMH: mH + 'px'
  127. })
  128. },
  129. back(){
  130. wx.navigateBack();
  131. }
  132. })