diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index 41069b4bf..9329ea860 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -6,12 +6,16 @@ module Mobile resources :activities do desc "get user activities" + + params do + requires :page, type: Integer + end get ':id' do #uw = UserWechat.find params[:openid] user = User.find params[:id] shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) - page = params[:page] ? params[:page].to_i + 1 : 0 + page = params[:page] ? params[:page] : 0 user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll','Course')" @@ -22,8 +26,14 @@ module Mobile activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " + - "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(50).offset(page * 10) + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc') + all_count = activities.count + activities = activities.limit(10).offset(page * 10) + count = activities.count present :data, activities, with: Mobile::Entities::Activity + present :all_count, all_count + present :count, count + present :page, page present :status, 0 end end diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 63775c12d..753299956 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -12,7 +12,7 @@ module Mobile requires :type, type: String requires :content, type: String end - get ':id' do + post ':id' do type = params[:type] result = 1 current_user = User.find 8686 diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index 55923f468..bc2d92b1b 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -40,7 +40,7 @@ module Mobile issue_expose :journals_count expose :issue_journals, using: Mobile::Entities::Journal do |f, opt| if f.is_a?(::Issue) - f.journals + f.journals.where("notes != null") end end end diff --git a/app/api/mobile/entities/journal.rb b/app/api/mobile/entities/journal.rb index a2c54248e..6eb254a6b 100644 --- a/app/api/mobile/entities/journal.rb +++ b/app/api/mobile/entities/journal.rb @@ -1,11 +1,14 @@ module Mobile module Entities class Journal -
更多
+ +
更多
+ - + \ No newline at end of file diff --git a/public/javascripts/wechat/homework_detail.js b/public/javascripts/wechat/homework_detail.js index e4e3a9758..1c223bfc2 100644 --- a/public/javascripts/wechat/homework_detail.js +++ b/public/javascripts/wechat/homework_detail.js @@ -64,14 +64,14 @@ $(document).ready(function(){ //获取并传送回复用户数据 var userInfo = { - "replyType" : "homework_assignment", - "replyContent" : postInput + "type" : "HomeworkCommon", + "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语句,或者是单纯的语句 @@ -82,14 +82,14 @@ $(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/wechat_dev.js b/public/javascripts/wechat/wechat_dev.js index eacbf8559..c921ed64d 100644 --- a/public/javascripts/wechat/wechat_dev.js +++ b/public/javascripts/wechat/wechat_dev.js @@ -2,59 +2,5 @@ * Created by root on 3/25/16. */ $(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:result-list',{activities: data}); - $('#container').prepend(html); - descToggle(); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'activities/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - loadDataFromServer(1); - - //内容全部显示与部分隐藏 - var descToggle = function(){ - $(".post-all-content").each(function(){ - var postHeight = $(this).height(); - if (postHeight > 90){ - $(this).parent().next().css("display","block"); - $(this).parent().next().toggle(function(){ - $(this).text("点击隐藏"); - $(this).prev().css("height",postHeight); - },function(){ - $(this).text("点击展开"); - $(this).prev().css("height",90); - }); - } - }); - } - - + loadDataFromServer(8686, 0); });