123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- const app = getApp()
- import {
- getBannerList
- } from '~/api/global'
- import share from '~/mixins/share'
- import {
- getSelfRead
- } from '~/api/user'
- import {
- getFollowWorks
- } from '~/api/works'
- import reachBottom from '~/mixins/reachBottom'
- Page({
- behaviors: [reachBottom, share],
- data: {
- navBarHeight: app.globalData.navBarHeight,
- bannerList: [],
- // 4关注作品,5我的作品
- currentType: '4',
- isFixed: false
- },
- onShow() {
- if (typeof this.getTabBar === 'function') {
- this.getTabBar().setData({
- selected: 1
- })
- }
- let uid = wx.getStorageSync('uid')
- if (uid) {
- this.resetData()
- } else {
- getApp().callBack = (res) => {
- this.resetData()
- }
- }
- },
- loadMore() {
- if (this.data.currentType == '4') {
- this.getData(getFollowWorks, {})
- } else if (this.data.currentType == '5') {
- this.getData(getSelfRead, {})
- }
- },
- changeType({
- target
- }) {
- if (target.dataset.type) {
- this.setData({
- currentType: target.dataset.type
- })
- this.selectComponent('#worksList').resetAudio()
- this.resetData()
- }
- },
- /**
- * 监听页面滚动事件
- */
- onPageScroll(e) {
- if (e.scrollTop >= 110 && !this.data.isFixed) {
- this.setData({
- isFixed: true
- })
- } else if (e.scrollTop < 20 && this.data.isFixed) {
- this.setData({
- isFixed: false
- })
- }
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- this.loadMore()
- },
- })
|