messageDetail.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // pages/messageDetail/messageDetail.js
  2. const request = require("../../utils/request.js");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. info: []
  9. },
  10. getSysMessage() {
  11. let that = this;
  12. request.getData(
  13. 'app/message/list/sys',
  14. {lastMessageId: 0},
  15. res => {
  16. let arr = res.data.data;
  17. that.setData({
  18. info: arr
  19. })
  20. },
  21. res => {
  22. console.log(res)
  23. }
  24. )
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad(options) {
  30. wx.setNavigationBarTitle({
  31. title: "TOKER官方助手"
  32. })
  33. this.getSysMessage()
  34. },
  35. /**
  36. * 生命周期函数--监听页面初次渲染完成
  37. */
  38. onReady() {
  39. },
  40. /**
  41. * 生命周期函数--监听页面显示
  42. */
  43. onShow() {
  44. },
  45. /**
  46. * 生命周期函数--监听页面隐藏
  47. */
  48. onHide() {
  49. },
  50. /**
  51. * 生命周期函数--监听页面卸载
  52. */
  53. onUnload() {
  54. },
  55. /**
  56. * 页面相关事件处理函数--监听用户下拉动作
  57. */
  58. onPullDownRefresh() {
  59. },
  60. /**
  61. * 页面上拉触底事件的处理函数
  62. */
  63. onReachBottom() {
  64. let that = this;
  65. let lastMessageId = Number(that.data.info[that.data.info.length-1].messageId);
  66. request.getData(
  67. 'app/message/list/sys',
  68. {lastMessageId: lastMessageId},
  69. res => {
  70. if(res.data.data.length > 0) {
  71. let arr = res.data.data;
  72. that.setData({
  73. info: that.data.info.concat(arr)
  74. })
  75. }
  76. },
  77. res => {
  78. console.log(res)
  79. }
  80. )
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage() {
  86. }
  87. })