index.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. console.log(e.scrollTop);
  62. if (e.scrollTop >= 110 && !this.data.isFixed) {
  63. this.setData({
  64. isFixed: true
  65. })
  66. } else if (e.scrollTop < 110 && this.data.isFixed) {
  67. this.setData({
  68. isFixed: false
  69. })
  70. }
  71. },
  72. /**
  73. * 页面上拉触底事件的处理函数
  74. */
  75. onReachBottom() {
  76. this.loadMore()
  77. },
  78. /**
  79. * 用户点击右上角分享
  80. */
  81. onShareAppMessage() {
  82. }
  83. })