mineLike.js 1.7 KB

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