diff --git a/pages/discover/discover.vue b/pages/discover/discover.vue index eff0219..8c47876 100644 --- a/pages/discover/discover.vue +++ b/pages/discover/discover.vue @@ -7,7 +7,7 @@ + @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh" :scroll-top="scrollTop" @scroll="scroll"> @@ -58,6 +58,11 @@ + + + + + @@ -77,6 +82,9 @@ loadingText: '正在加载中' } return { + scrollTop: 0, + oldScrollTop:0, + showTotop: false, tab_list: [ {name: '最新',type: 'created_at',list:[],..._public}, {name: '最热',type: 'view_count',list:[],..._public}, @@ -100,6 +108,23 @@ this.getHotActivity() }, methods: { + scroll (e) { + //记录scroll 位置 + this.oldScrollTop = e.detail.scrollTop; + if(this.oldScrollTop > 900) { + this.showTotop = true; + }else { + this.showTotop = false; + } + }, + goTop(e) { + //视图会发生重新渲染 + this.scrollTop = this.oldScrollTop; + //当视图渲染结束 重新设置为0 + this.$nextTick(() =>{ + this.scrollTop = 0; + }); + }, checkPicture(image_list,current) { if(image_list.length <= 0) return; let list = []; @@ -147,10 +172,6 @@ }) .catch(() => { wx.hideLoading(); - wx.showModal({ - content: '请求失败', - showCancel: false - }); }); }, getMyAttention(options = {}) { @@ -158,14 +179,22 @@ this.$http .get({ api: 'api/discover/follow', + data: { + page: tab_item.page, + page_size: this.pageSize, + }, header: { Authorization: this.$cookieStorage.get('user_token') }, }) .then(res => { if (res.data.code == 200) { - let isPage = res.data.data.next_page_url == null?false:true; - tab_item.isPage = isPage; + let isPage; + if(res.data.data.per_page == res.data.data.data.length) { + isPage = true; + }else { + isPage = false; + } if(!isPage) { tab_item.loadingClass = false; tab_item.loadingText = '没有更多数据啦~'; @@ -214,7 +243,7 @@ tab_item.list = [] tab_item.loadingText = '正在加载中'; if(this.tab_current == 2) { - this.getMyAttention(); + this.getMyAttention(options); }else { this.getHotActivity(options); } @@ -253,17 +282,24 @@ this.$http .get({ api: 'api/discover', - page: tab_item.page, - page_size: this.pageSize, data:{ - order: discover_type, - user_id: this.$cookieStorage.get('user_info').id - } + page: tab_item.page, + page_size: this.pageSize, + order: discover_type + }, + header: { + Authorization: this.$cookieStorage.get('user_token') + }, }) .then(res => { if (res.data.code == 200) { if (res.data.status) { - let isPage = res.data.next_page_url == null?false:true; + let isPage; + if(res.data.data.per_page == res.data.data.data.length) { + isPage = true; + }else { + isPage = false; + } tab_item.isPage = isPage; if(!isPage) { tab_item.loadingClass = false; @@ -296,10 +332,6 @@ }) .catch(() => { wx.hideLoading(); - wx.showModal({ - content: '请求失败', - showCancel: false - }); }); } } @@ -370,6 +402,26 @@ } } + .fixed-right1{ + position: fixed; + right: 32rpx; + bottom: 320rpx; + width: max-content; + height: max-content; + padding-bottom: constant(safe-area-inset-bottom); + padding-bottom: env(safe-area-inset-bottom); + .fixed-btn{ + width: 100rpx; + height: 100rpx; + border-radius: 50%; + background-color: #15716E; + display: flex; + justify-content: center; + align-items: center; + color: #FFFFFF; + } + } + // tab样式 /deep/.u-scroll-box { diff --git a/pages/user/my/my.vue b/pages/user/my/my.vue index 44524c7..04a7964 100644 --- a/pages/user/my/my.vue +++ b/pages/user/my/my.vue @@ -62,12 +62,7 @@ }, onLoad(e) { this.user_id = e.user_id; - let user_info = this.$cookieStorage.get('user_token'); - if(user_info) { - this.loginList(); - }else { - this.noLoginList(); - } + this.loginList(); }, methods: { //关注 @@ -155,51 +150,11 @@ goDetails(id) { this.$url('/pages/discover/discoverdetails?discover_id='+id) }, - //未登录时的发现列表 - noLoginList() { - this.$http - .get({ - api: 'api/discover/user/', - data: { - page: this.page, - page_size: this.page_size - }, - header: { - Authorization: this.$cookieStorage.get('user_token') - }, - }) - .then(res => { - if (res.data.code == 200) { - if (res.data.status) { - this.discover_info = res.data.data; - console.log('未登录时的发现列表',this.discover_info); - } else { - wx.showModal({ - content: res.data.message || '请下拉页面刷新重试', - showCancel: false - }); - } - } else { - wx.showModal({ - content: res.data.message || '请下拉页面刷新重试', - showCancel: false - }); - } - wx.hideLoading(); - }) - .catch(() => { - wx.hideLoading(); - wx.showModal({ - content: '请求失败', - showCancel: false - }); - }); - }, //登录时的发现列表 loginList() { this.$http .get({ - api: 'api/discover/my/'+this.user_id, + api: 'api/discover/user/'+this.user_id, data: { page: this.page, page_size: this.page_size