index.js 1.5 KB

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