diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index cbd739e8c..8c46d530c 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -35,6 +35,8 @@ module Mobile comment.comments = params[:content] comment.author = current_user if news.comments << comment + data = comment + present :data, data, with: Mobile::Entities::Comment result = 2 else result = 3 @@ -50,6 +52,8 @@ module Mobile reply.parent_id = params[:id] reply.subject = "RE: #{topic.subject}" if topic.children << reply + data = reply + present :data, data, with: Mobile::Entities::Message result = 2 else result = 3 diff --git a/app/api/mobile/entities/comment.rb b/app/api/mobile/entities/comment.rb index 803d0c6d0..ce40bb2e5 100644 --- a/app/api/mobile/entities/comment.rb +++ b/app/api/mobile/entities/comment.rb @@ -9,7 +9,7 @@ module Mobile elsif f.is_a?(::Comment) if f.respond_to?(field) if field == :created_on - format_time(f.send(field)) + time_from_now(f.send(field)) else f.send(field) end diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 68e8519aa..ea730d4f7 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -66,7 +66,7 @@
-
class="c-grey">回复 ()
+
回复 ()
赞 ()
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index b5d56cd7e..acef95c64 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -36,9 +36,10 @@
回复 ()
-
()
+
(())
- +
+ = 0; --j){ !>
@@ -52,11 +53,12 @@
+
- +
@@ -64,6 +66,20 @@ + + diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 6c508ab9c..6765281fa 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -36,14 +36,15 @@
回复 ()
-
1
+
()
- +
+ = 0; --j){ !>
-
+
- +
回复
@@ -52,11 +53,12 @@
+
- +
@@ -64,6 +66,22 @@
+ + + + diff --git a/public/javascripts/wechat/course_discussion.js b/public/javascripts/wechat/course_discussion.js index 12533d5f6..e01b6b451 100644 --- a/public/javascripts/wechat/course_discussion.js +++ b/public/javascripts/wechat/course_discussion.js @@ -10,6 +10,12 @@ $(document).ready(function(){ var apiUrl = '/api/v1/'; + var setReplyTemplate = function(data){ + console.log(data); + var html=bt('t:c-message-detail-reply',{reply: data}); + $('#all_course_message_reply').prepend(html); + }; + var setTemplate = function(data){ console.log(data); var html=bt('t:course-discussion',{discussion: data}); @@ -17,9 +23,9 @@ $(document).ready(function(){ $('.post-reply-submit').click(function(){ replyInsert(); }); - $('post-interactive-praise').click(function(){ + /*$('post-interactive-praise').click(function(){ praiseClick(); - }); + });*/ }; var loadDataFromServer = function(id){ @@ -52,9 +58,9 @@ $(document).ready(function(){ }else{ //将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
回复
'); + /*$(".post-reply-wrap:last").after('
回复
'); $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date()); + $(".post-reply-date:last").append(Date());*/ var postInput = $("#postInput").val(); $("#postInput").val(""); //回复数目+1 @@ -71,10 +77,11 @@ $(document).ready(function(){ $.ajax({ type: "POST", //提交方式 dataType: "json", //类型 - url: "前台地址/后台方法", //提交的页面,方法名 + url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 data: userInfo, //参数,如果没有,可以为null success: function (data) { //如果执行成功,那么执行此方法 - alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + setReplyTemplate(data.data); + alert("6"); }, error: function (err) { //如果执行不成功,那么执行此方法 alert("err:" + err); @@ -84,12 +91,12 @@ $(document).ready(function(){ } - //点赞效果 + /*//点赞效果 var praiseClick = function(){ var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); praiseNum++; $(".praise-num").text("(" + praiseNum + ")"); - } + }*/ }); \ No newline at end of file diff --git a/public/javascripts/wechat/course_notice.js b/public/javascripts/wechat/course_notice.js index f20526a5f..546aac385 100644 --- a/public/javascripts/wechat/course_notice.js +++ b/public/javascripts/wechat/course_notice.js @@ -10,6 +10,12 @@ $(document).ready(function(){ var apiUrl = '/api/v1/'; + var setReplyTemplate = function(data){ + console.log(data); + var html=bt('t:news-detail-reply',{reply: data}); + $('#all_news_reply').prepend(html); + }; + var setTemplate = function(data){ console.log(data); var html=bt('t:course-notice',{course: data}); @@ -17,9 +23,9 @@ $(document).ready(function(){ $('.post-reply-submit').click(function(){ replyInsert(); }); - $('post-interactive-praise').click(function(){ + /*$('post-interactive-praise').click(function(){ praiseClick(); - }); + });*/ }; var loadDataFromServer = function(id){ @@ -52,9 +58,9 @@ $(document).ready(function(){ }else{ //将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
回复
'); + /*$(".post-reply-wrap:last").after('
回复
'); $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date()); + $(".post-reply-date:last").append(Date());*/ var postInput = $("#postInput").val(); $("#postInput").val(""); //回复数目+1 @@ -64,17 +70,17 @@ $(document).ready(function(){ //获取并传送回复用户数据 var userInfo = { - "replyType" : "homework_assignment", - "replyContent" : postInput + "type" : "News", + "content" : postInput }; $.ajax({ type: "POST", //提交方式 dataType: "json", //类型 - url: "前台地址/后台方法", //提交的页面,方法名 + url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 data: userInfo, //参数,如果没有,可以为null success: function (data) { //如果执行成功,那么执行此方法 - alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + setReplyTemplate(data.data); }, error: function (err) { //如果执行不成功,那么执行此方法 alert("err:" + err);