insideMessage.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. onShareAppMessage() {
  47. return {
  48. title: '课文朗读,从未如此有趣。',
  49. path: `/pages/index/index?&uid=${wx.getStorageSync('uid')}`,
  50. imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/shareContent.png'
  51. }
  52. }
  53. })