index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const app = getApp()
  2. import {
  3. getBannerList
  4. } from '~/api/global'
  5. import {
  6. getSelfRead
  7. } from '~/api/user'
  8. import {
  9. getFollowWorks
  10. } from '~/api/works'
  11. import reachBottom from '~/mixins/reachBottom'
  12. Page({
  13. behaviors: [reachBottom],
  14. data: {
  15. navBarHeight: app.globalData.navBarHeight,
  16. bannerList: [],
  17. // 1关注的人的作品,2是自己的作品
  18. currentType: '1',
  19. isFixed: false
  20. },
  21. onShow() {
  22. if (typeof this.getTabBar === 'function') {
  23. this.getTabBar().setData({
  24. selected: 2
  25. })
  26. }
  27. let uid = wx.getStorageSync('uid')
  28. if (uid) {
  29. this.resetData()
  30. } else {
  31. getApp().callBack = (res) => {
  32. this.resetData()
  33. }
  34. }
  35. },
  36. loadMore() {
  37. if (this.data.currentType == '1') {
  38. this.getData(getFollowWorks, {})
  39. } else if (this.data.currentType == '2') {
  40. this.getData(getSelfRead, {})
  41. }
  42. },
  43. async getFollowWorks() {
  44. let res = await getFollowWorks()
  45. console.log(res);
  46. },
  47. changeType({
  48. target
  49. }) {
  50. if (target.dataset.type) {
  51. this.setData({
  52. currentType: target.dataset.type
  53. })
  54. this.resetData()
  55. }
  56. },
  57. /**
  58. * 监听页面滚动事件
  59. */
  60. onPageScroll(e) {
  61. if (e.scrollTop >= 110 && !this.data.isFixed) {
  62. this.setData({
  63. isFixed: true
  64. })
  65. } else if (e.scrollTop < 110 && this.data.isFixed) {
  66. this.setData({
  67. isFixed: false
  68. })
  69. }
  70. },
  71. /**
  72. * 页面上拉触底事件的处理函数
  73. */
  74. onReachBottom() {
  75. this.loadMore()
  76. },
  77. /**
  78. * 用户点击右上角分享
  79. */
  80. onShareAppMessage() {
  81. }
  82. })