From 92d404c3e68b3716729e19916bbc6b9f129bf4b5 Mon Sep 17 00:00:00 2001 From: Enzo <1284707383@qq.com> Date: Wed, 15 Sep 2021 17:37:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E7=8E=B0=E8=AF=84=E8=AE=BA=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/discover/discover.vue | 54 +++++++----------- pages/discover/discoverdetails.vue | 14 +++-- pages/user/my/my.vue | 88 +++++++++++++++++++++++++++++- 3 files changed, 114 insertions(+), 42 deletions(-) diff --git a/pages/discover/discover.vue b/pages/discover/discover.vue index 706ac5c..3792559 100644 --- a/pages/discover/discover.vue +++ b/pages/discover/discover.vue @@ -78,9 +78,9 @@ } return { tab_list: [ - {name: '最新',type: 'created_at',list:[]}, - {name: '最热',type: 'view_count',list:[]}, - {name: '已关注',type: 'view_count',list:[]} + {name: '最新',type: 'created_at',list:[],..._public}, + {name: '最热',type: 'view_count',list:[],..._public}, + {name: '已关注',type: 'view_count',list:[],..._public} ], tab_current: 0, scrollH: 0, @@ -140,7 +140,7 @@ }); }); }, - getMyAttention() { + getMyAttention(options = {}) { let tab_item = this.tab_list[this.tab_current]; this.$http .get({ @@ -150,31 +150,22 @@ }, }) .then(res => { - console.log(res) if (res.data.code == 200) { - if (res.data.status) { - let isPage = res.data.next_page_url == null?false:true; - tab_item.isPage = isPage; - if(!isPage) { - tab_item.loadingClass = false; - tab_item.loadingText = '没有更多数据啦~'; - } - if(options.type == 'pageRefresh') { - uni.stopPullDownRefresh(); - }else if(options.type == 'scrollRefresh') { - this.isRefresher = false; - } - if(tab_item.page == 1) { - tab_item.list = res.data.data.data; - }else { - tab_item.list.push(...res.data.data.data); - } - console.log('发现列表',tab_item.list) - } else { - wx.showModal({ - content: res.data.message || '请下拉页面刷新重试', - showCancel: false - }); + let isPage = res.data.data.next_page_url == null?false:true; + tab_item.isPage = isPage; + if(!isPage) { + tab_item.loadingClass = false; + tab_item.loadingText = '没有更多数据啦~'; + } + if(options.type == 'pageRefresh') { + uni.stopPullDownRefresh(); + }else if(options.type == 'scrollRefresh') { + this.isRefresher = false; + } + if(tab_item.page == 1) { + tab_item.list = res.data.data.data; + }else { + tab_item.list.push(...res.data.data.data); } } else { wx.showModal({ @@ -186,10 +177,7 @@ }) .catch(() => { wx.hideLoading(); - wx.showModal({ - content: '请求失败', - showCancel: false - }); + }); }, // 页面触底,加载下一页 @@ -256,7 +244,7 @@ page_size: this.pageSize, data:{ order: discover_type, - user_id: 1 + user_id: this.$cookieStorage.get('user_info').id } }) .then(res => { diff --git a/pages/discover/discoverdetails.vue b/pages/discover/discoverdetails.vue index 8e4e2d9..36cde03 100644 --- a/pages/discover/discoverdetails.vue +++ b/pages/discover/discoverdetails.vue @@ -3,7 +3,7 @@ - + V @@ -40,10 +40,10 @@ - 共 {{commentList.total}}条评论 + 共 {{discover_details.comments_count}}条评论 - + @@ -104,7 +104,7 @@ - + {{discover_details.likes_count}} @@ -195,7 +195,7 @@ api: 'api/discover/comment/list', data: { discover_id: this.discover_id, - user_id: 6 + user_id: this.$cookieStorage.get('user_info').id }, header: { Authorization: this.$cookieStorage.get('user_token') @@ -248,6 +248,7 @@ this.$msg('回复成功').then(() => { console.log('更新回复列表'); this.comment = ''; + this.ifApply = false; this.getCommentList(); }) } else { @@ -331,6 +332,7 @@ if (res.data.code == 200) { if (res.data.status) { this.getCommentList(); + this.getDiscoverDetails(); } else { wx.showModal({ content: res.data.message || '请下拉页面刷新重试', @@ -359,7 +361,7 @@ api: 'api/discover/detail', data: { id: this.discover_id, - user_id: 6 + user_id: this.$cookieStorage.get('user_info').id }, }) .then(res => { diff --git a/pages/user/my/my.vue b/pages/user/my/my.vue index 2ddc806..44524c7 100644 --- a/pages/user/my/my.vue +++ b/pages/user/my/my.vue @@ -14,8 +14,8 @@ - - + + @@ -31,7 +31,7 @@ - + {{item.likes_count}} @@ -70,6 +70,88 @@ } }, methods: { + //关注 + payAttention() { + this.$http + .post({ + api: 'api/discover/add_follow', + data: { + user_id: this.user_id + }, + header: { + Authorization: this.$cookieStorage.get('user_token') + }, + }) + .then(res => { + if (res.data.code == 200) { + if (res.data.status) { + this.$msg(res.data.data); + this.loginList(); + } 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 + }); + }); + }, + //点赞发现 + addLike(id) { + let user_info = this.$cookieStorage.get('user_token'); + if(user_info) { + this.$http + .post({ + api: 'api/discover/like', + data: { + discover_id: id + }, + header: { + Authorization: this.$cookieStorage.get('user_token') + }, + }) + .then(res => { + if (res.data.code == 200) { + if (res.data.status) { + this.loginList(); + } 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 + }); + }); + }else { + this.$msg('你还未登录,请前往登录!'); + } + }, goDetails(id) { this.$url('/pages/discover/discoverdetails?discover_id='+id) },