diff --git a/pages/status/detail.js b/pages/status/detail.js index 49a53eb62461701d229b8cd55ff1c5d7d2bacd0a..e2edcaf2ef803db68a7bc5f442215f8136d44f88 100644 --- a/pages/status/detail.js +++ b/pages/status/detail.js @@ -7,7 +7,9 @@ Page({ pageIndex:1, pageSize:10, status_id:0, - user_id:app.user.SpaceUserId + user_id:app.user.SpaceUserId, + comment_id:'', + comment_text:'' }, onLoad:function(options){ // 页面初始化 options为页面跳转所带来的参数 @@ -48,6 +50,7 @@ Page({ formSubmit: function(e) { var content = e.detail.value.content; var status_id = e.detail.value.status_id; + var comment_id = e.detail.value.comment_id; var that = this; //发表闪存评论 wx.request({ @@ -55,6 +58,7 @@ Page({ method: 'post', data: { ReplyTo:status_id, + ParentCommentId:comment_id, Content:content }, header: { @@ -66,6 +70,9 @@ Page({ complete: function () { that.getStatus(that, status_id); that.onPullDownRefresh(); + that.setData({ + comment_text:'' + }) } }) }, @@ -142,5 +149,15 @@ Page({ that.onPullDownRefresh(); } }) + }, + //回复别人评论 + replyComment:function(event) { + var comment_id = event.currentTarget.dataset.comment_id; + var comment_user_name = event.currentTarget.dataset.comment_user_name; + + this.setData({ + comment_id:comment_id, + comment_text:"@" + comment_user_name +":" + }); } }) \ No newline at end of file diff --git a/pages/status/detail.wxml b/pages/status/detail.wxml index 8b24c1cf94cb3c80255d8875a6c94927982a6e39..ae0e75682f44ac1eaf05174d0788e224f94f5e80 100644 --- a/pages/status/detail.wxml +++ b/pages/status/detail.wxml @@ -13,9 +13,7 @@ 文字来源 {{statuses.DateAdded}} - - 回应 - + @@ -34,8 +32,7 @@ {{item.DateAdded}} 删除 - - 回应 + 回应 @@ -47,8 +44,9 @@ - - + + + diff --git a/pages/status/index.js b/pages/status/index.js index 05d1f3e8b6990a55327bca384aa422a984d44d72..2526066105caeacab18cfa9804e46b5933efd966 100644 --- a/pages/status/index.js +++ b/pages/status/index.js @@ -2,25 +2,34 @@ var app = getApp() Page({ data:{ - tabs: ["我的回应", "提到我的", "选项三"], + tabs: ["全部", "我的", "回复我", "我回应"], pageIndex:1, pageSize:10, activeIndex: 0, sliderOffset: 0, sliderLeft: 0, - statuses_all:[ - - ] + all_statuses:[], + my_statuses:[], + comment_statuses:[], + my_comment_statuses:[] }, onLoad:function(options){ - this.loadStatuses(this, this.data.pageIndex, this.data.pageSize); + // this.loadStatuses(this, this.data.pageIndex, this.data.pageSize); + this.getStatusByType(this.data.activeIndex, this, 1, this.data.pageSize); wx.stopPullDownRefresh(); }, tabClick: function (e) { + var activeIndex = e.currentTarget.id; this.setData({ sliderOffset: e.currentTarget.offsetLeft, - activeIndex: e.currentTarget.id + activeIndex: activeIndex, + pageIndex: 1, + all_statuses:[], + my_statuses:[], + comment_statuses:[], + my_comment_statuses:[] }); + this.getStatusByType(activeIndex, this, 1, this.data.pageSize); }, onReady:function(){ // 页面渲染完成 @@ -39,19 +48,40 @@ Page({ wx.showNavigationBarLoading(); this.setData({ pageIndex:1, - statuses_all:[], + all_statuses:[], + my_statuses:[], + comment_statuses:[], + my_comment_statuses:[] }); - this.loadStatuses(this, this.data.pageIndex, this.data.pageSize) + // this.getStatuses(this, this.data.pageIndex, this.data.pageSize) + this.getStatusByType(this.data.activeIndex, this, this.data.pageIndex, this.data.pageSize); }, //上拉加载更多 onReachBottom:function(){ this.setData({ pageIndex:this.data.pageIndex + 1 }); - this.loadStatuses(this, this.data.pageIndex, this.data.pageSize) + // this.getAllStatuses(this, this.data.pageIndex, this.data.pageSize) + this.getStatusByType(this.data.activeIndex, this, this.data.pageIndex, this.data.pageSize); }, - loadStatuses: function(that, pageIndex, pageSize){ - //获取闪存信息 + getStatusByType:function(activeIndex, that, pageIndex, pageSize) { + switch (parseInt(activeIndex)) { + case 0: + this.getAllStatuses(that, pageIndex, pageSize); + break; + case 1: + this.getMyStatuses(that, pageIndex, pageSize); + break; + case 2: + this.getReplyMyStatuses(that, pageIndex, pageSize); + break; + case 3: + this.getIReplyStatuses(that, pageIndex, pageSize); + break; + } + }, + getAllStatuses: function(that, pageIndex, pageSize){ + //获取全部闪存列表 wx.request({ url: 'http://api.cnblogs.com/api/statuses/@all', data: { @@ -64,13 +94,40 @@ Page({ "Authorization":"Bearer " + app.accessToken }, success: function(res) { - console.log(res); - var list = that.data.statuses_all; + var list = that.data.all_statuses; + for (var i = 0; i < res.data.length; i++) { + list.push(res.data[i]); + } + that.setData({ + all_statuses: list + }); + }, + complete: function () { + wx.hideNavigationBarLoading(); + wx.stopPullDownRefresh(); + } + }) + }, + getMyStatuses: function(that, pageIndex, pageSize){ + //获取我的闪存列表 + wx.request({ + url: 'http://api.cnblogs.com/api/statuses/@my', + data: { + pageIndex:pageIndex, + pageSize:pageSize, + tag:'is' + }, + header: { + "Content-Type":"application/x-www-form-urlencoded", + "Authorization":"Bearer " + app.accessToken + }, + success: function(res) { + var list = that.data.my_statuses; for (var i = 0; i < res.data.length; i++) { list.push(res.data[i]); } that.setData({ - statuses_all: list + my_statuses: list }); }, complete: function () { @@ -78,5 +135,61 @@ Page({ wx.stopPullDownRefresh(); } }) - } + }, + getReplyMyStatuses: function(that, pageIndex, pageSize){ + //获取回复我的闪存列表 + wx.request({ + url: 'http://api.cnblogs.com/api/statuses/@comment', + data: { + pageIndex:pageIndex, + pageSize:pageSize, + tag:'is' + }, + header: { + "Content-Type":"application/x-www-form-urlencoded", + "Authorization":"Bearer " + app.accessToken + }, + success: function(res) { + var list = that.data.comment_statuses; + for (var i = 0; i < res.data.length; i++) { + list.push(res.data[i]); + } + that.setData({ + comment_statuses: list + }); + }, + complete: function () { + wx.hideNavigationBarLoading(); + wx.stopPullDownRefresh(); + } + }) + }, + getMyReplyStatuses: function(that, pageIndex, pageSize){ + //获取我回复的闪存列表 + wx.request({ + url: 'http://api.cnblogs.com/api/statuses/@mycomment', + data: { + pageIndex:pageIndex, + pageSize:pageSize, + tag:'is' + }, + header: { + "Content-Type":"application/x-www-form-urlencoded", + "Authorization":"Bearer " + app.accessToken + }, + success: function(res) { + var list = that.data.my_comment_statuses; + for (var i = 0; i < res.data.length; i++) { + list.push(res.data[i]); + } + that.setData({ + my_comment_statuses: list + }); + }, + complete: function () { + wx.hideNavigationBarLoading(); + wx.stopPullDownRefresh(); + } + }) + }, }) \ No newline at end of file diff --git a/pages/status/index.wxml b/pages/status/index.wxml index 67649914dcec7e02c1136595029c7f5336418bcc..e08555079cc34bc133498358cf7b7cb91fb61b86 100644 --- a/pages/status/index.wxml +++ b/pages/status/index.wxml @@ -16,10 +16,11 @@ +