insideMessage.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import httpRequestApi from '../../../utils/APIClient';
  2. import {
  3. formatDate
  4. } from '../../../utils/util';
  5. Page({
  6. data: {
  7. messageList: [],
  8. totalNo: 1,
  9. totalSize: 0,
  10. index: 1
  11. },
  12. onLoad: function (options) {
  13. wx.setNavigationBarTitle({
  14. title: '消息列表'
  15. })
  16. this.getMessage();
  17. },
  18. getMessage: function () {
  19. console.log(this.data.totalNo)
  20. console.log(this.data.index)
  21. if (this.data.totalNo < this.data.index) {
  22. return;
  23. }
  24. httpRequestApi.getMessageList(this.data.index, 10).success((res) => {
  25. res.data.data.list.forEach(item => {
  26. item.gmtCreated = formatDate(item.gmtCreated, 1)
  27. this.data.messageList.push(item);
  28. })
  29. this.setData({
  30. messageList: this.data.messageList,
  31. totalNo: res.data.data.totalNo,
  32. index: this.data.index + 1
  33. })
  34. httpRequestApi.refreshMessageStatus().success((res) => {
  35. console.log(res)
  36. })
  37. });
  38. },
  39. onReachBottom: function () {
  40. this.getMessage();
  41. }
  42. })