index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. bannerList: [],
  16. // 1关注的人的作品,2是自己的作品
  17. currentType: '1',
  18. },
  19. onShow() {
  20. if (typeof this.getTabBar === 'function') {
  21. this.getTabBar().setData({
  22. selected: 2
  23. })
  24. }
  25. let uid = wx.getStorageSync('uid')
  26. if (uid) {
  27. this.resetData()
  28. } else {
  29. getApp().callBack = (res) => {
  30. this.resetData()
  31. }
  32. }
  33. },
  34. loadMore() {
  35. if (this.data.currentType == '1') {
  36. this.getData(getFollowWorks, {})
  37. } else if (this.data.currentType == '2') {
  38. this.getData(getSelfRead, {})
  39. }
  40. },
  41. async getFollowWorks() {
  42. let res = await getFollowWorks()
  43. console.log(res);
  44. },
  45. changeType({
  46. target
  47. }) {
  48. if (target.dataset.type) {
  49. this.setData({
  50. currentType: target.dataset.type
  51. })
  52. this.resetData()
  53. }
  54. },
  55. /**
  56. * 页面上拉触底事件的处理函数
  57. */
  58. onReachBottom() {
  59. this.loadMore()
  60. },
  61. /**
  62. * 用户点击右上角分享
  63. */
  64. onShareAppMessage() {
  65. }
  66. })