insideMessage.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. statusbarobj: {
  12. isshowbtn: false, //是否显示按钮
  13. title: "小学语文朗读配音", //标题
  14. },
  15. },
  16. onLoad: function (options) {
  17. wx.setNavigationBarTitle({
  18. title: '消息列表'
  19. })
  20. this.getMessage();
  21. },
  22. getMessage: function () {
  23. console.log(this.data.totalNo)
  24. console.log(this.data.index)
  25. if (this.data.totalNo < this.data.index) {
  26. return;
  27. }
  28. httpRequestApi.getMessageList(this.data.index, 10).success((res) => {
  29. res.data.data.list.forEach(item => {
  30. item.gmtCreated = formatDate(item.gmtCreated, 1)
  31. this.data.messageList.push(item);
  32. })
  33. this.setData({
  34. messageList: this.data.messageList,
  35. totalNo: res.data.data.totalNo,
  36. index: this.data.index + 1
  37. })
  38. httpRequestApi.refreshMessageStatus().success((res) => {
  39. console.log(res)
  40. })
  41. });
  42. },
  43. onReachBottom: function () {
  44. this.getMessage();
  45. }
  46. })