diff --git a/1234567 b/1234567 index 4354b8b04..dfd7e3ee3 100644 --- a/1234567 +++ b/1234567 @@ -1 +1 @@ -{"access_token":"t3XVpwqZbAO6-uRz_ltKUiplgHcYVstA0p43ECTHEjt0-FvVLU7VXzD7n6Z76PYFWHf8hvNHZtLNAUT-FlTl98wWLIK_lh9mhzHxS_x1iXCc0mC38RjxFzZ_NSeERW7dJZCfADAOEH","expires_in":7200,"got_token_at":1460105603} \ No newline at end of file +{"access_token":"7MBMEBoE6sSC15bIHZYAZSxj47yCKlbWEVjrkUgEJxPP3K083tbhc1RIWmxGu3WoB5dAXxK_yd4l1jrcvt6YrsTcOfFGRirOHVfzrpvhsQgxOoxcdc7YljfO_dnwUtWgFTAcAIALZG","expires_in":7200,"got_token_at":1460189856} \ No newline at end of file diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index 7d52da6a1..94ee14a56 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -33,8 +33,8 @@ module Mobile shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) 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(",") + ")" + user_project_ids = (user.projects.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.map{|project| project.id}-shield_project_ids).join(",") + ")" + user_course_ids = (user.courses.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.map{|course| course.id}-shield_course_ids).join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll','Course')" project_types = "('Message','Issue','ProjectCreateInfo')" principal_types = "JournalsForMessage" diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index c60a1d87e..5187839e8 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -86,7 +86,7 @@ class BlogComment < ActiveRecord::Base data = { touser:uw.openid, template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", - url:"http://weixin.qq.com/download", + url:"http://www.trustie.net/", topcolor:"#FF0000", data:{ first: { @@ -112,7 +112,11 @@ class BlogComment < ActiveRecord::Base } } logger.info "start send template message: #{data}" + begin req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + logger.error "[blog_comment] ===> #{e}" + end logger.info "send over. #{req}" end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index bdf61dbd0..ab687c869 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -109,7 +109,7 @@ class HomeworkCommon < ActiveRecord::Base data = { touser:uw.openid, template_id:"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", - url:"http://weixin.qq.com/download", + url:"http://www.trustie.net/", topcolor:"#FF0000", data:{ first: { @@ -135,7 +135,11 @@ class HomeworkCommon < ActiveRecord::Base } } logger.info "start send template message: #{data}" - req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + logger.error "[homework_common] ===> #{e}" + end logger.info "send over. #{req}" end end diff --git a/app/models/journal.rb b/app/models/journal.rb index 0c7cb02de..e56c8b043 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -245,7 +245,7 @@ class Journal < ActiveRecord::Base data = { touser:uw.openid, template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", - url:"http://weixin.qq.com/download", + url:"http://www.trustie.net/", topcolor:"#FF0000", data:{ first: { @@ -271,7 +271,11 @@ class Journal < ActiveRecord::Base } } logger.info "start send template message: #{data}" - req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + logger.error "[journal] ===> #{e}" + end logger.info "send over. #{req}" end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index edf1d2309..f207db8a8 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -256,7 +256,7 @@ class JournalsForMessage < ActiveRecord::Base end end if self.jour_type == 'HomeworkCommon' - journal_wechat_message '您的作业有新回复了' + journal_wechat_message '您的作业有新回复了',self.jour.user_id end end @@ -269,7 +269,7 @@ class JournalsForMessage < ActiveRecord::Base if self.reply_id == 0 if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour - journal_wechat_message "您有新留言了" + journal_wechat_message "您有新留言了",self.jour_id end else # 留言回复 reply_to = User.find(self.reply_id) @@ -279,7 +279,7 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 receivers << self.parent.jour end - journal_wechat_message "您的留言有新回复了" + journal_wechat_message "您的留言有新回复了",self.reply_id end receivers.each do |r| self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) @@ -307,14 +307,14 @@ class JournalsForMessage < ActiveRecord::Base end #微信模板消息 - def journal_wechat_message type - uw = UserWechat.where(user_id: self.reply_id).first + def journal_wechat_message type, user_id + uw = UserWechat.where(user_id: user_id).first #unless uw.nil? && self.reply_id != User.current.id unless uw.nil? data = { touser:uw.openid, template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", - url:"http://weixin.qq.com/download", + url:"http://www.trustie.net/", topcolor:"#FF0000", data:{ first: { @@ -340,7 +340,11 @@ class JournalsForMessage < ActiveRecord::Base } } logger.info "start send template message: #{data}" - req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + logger.error "[journal_for_message] ===> #{e}" + end logger.info "send over. #{req}" end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 58492be31..4b7180857 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -741,7 +741,7 @@ class Mailer < ActionMailer::Base mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "项目讨论区有新帖子发布了", message.subject, @author.try(:realname), format_time(message.created_on) end else - mail_wechat_message member.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), format_time(message.created_on), message.content.html_safe + mail_wechat_message message.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), format_time(message.created_on), message.content.html_safe end elsif message.course redmine_headers 'Course' => message.course.id, @@ -763,7 +763,7 @@ class Mailer < ActionMailer::Base mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "课程问答区有新帖子发布了", message.subject, @author.try(:realname), format_time(message.created_on) end else - mail_wechat_message member.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), format_time(message.created_on), message.content.html_safe + mail_wechat_message message.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), format_time(message.created_on), message.content.html_safe end end end @@ -1128,7 +1128,7 @@ class Mailer < ActionMailer::Base data = { touser:uw.openid, template_id:template_id, - url:"http://weixin.qq.com/download", + url:"http://www.trustie.net/", topcolor:"#FF0000", data:{ first: { @@ -1155,9 +1155,12 @@ class Mailer < ActionMailer::Base } logger.info "start send template message: #{data}" - req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + logger.error "[mailer] ===> #{e}" + end logger.info "send over. #{req}" - end end end diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index b6315eb39..376fdcf6a 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -216,7 +216,7 @@
-
更多
+
更多
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index ddb577285..4c71334cc 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "1"; + _openid = "3"; } var getOpenId = function() { @@ -77,7 +77,15 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){ url: apiUrl+ "activities", data: {openid: auth.openid(), page: page} }).then(function successCallback(response) { - $scope.activities = $scope.activities.concat(response.data.data); + $scope.current_page = 0; + console.log($scope.current_page); + console.log(response.data.page); + if($scope.current_page < response.data.page) { + $scope.activities = $scope.activities.concat(response.data.data); + } else { + $scope.activities = response.data.data; + } + $scope.current_page = response.data.page; $scope.all_count = response.data.all_count; $scope.count = response.data.count; console.log(response.data); @@ -97,12 +105,10 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){ $scope.loadActData = loadActData; $scope.addPraise = function(act){ - console.log(act); common.addCommonPraise(act); }; $scope.decreasePraise = function(act){ - console.log(act); common.decreaseCommonPraise(act); }; @@ -110,7 +116,6 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){ app.factory('common', function($http, auth, $routeParams){ var addCommonReply = function(id, type, data, cb){ - console.log(data.comment); if(!data.comment || data.comment.length<=0){ return; @@ -197,12 +202,10 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth, co }; $scope.addPraise = function(act){ - console.log(act); common.addCommonPraise(act); }; $scope.decreasePraise = function(act){ - console.log(act); common.decreaseCommonPraise(act); }; }); @@ -229,12 +232,10 @@ app.controller('HomeworkController', function($scope, $http, $routeParams, auth, }; $scope.addPraise = function(act){ - console.log(act); common.addCommonPraise(act); }; $scope.decreasePraise = function(act){ - console.log(act); common.decreaseCommonPraise(act); }; }); @@ -261,12 +262,10 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a }; $scope.addPraise = function(act){ - console.log(act); common.addCommonPraise(act); }; $scope.decreasePraise = function(act){ - console.log(act); common.decreaseCommonPraise(act); }; }); @@ -293,12 +292,10 @@ app.controller('DiscussionController', function($scope, $http, $routeParams, aut }; $scope.addPraise = function(act){ - console.log(act); common.addCommonPraise(act); }; $scope.decreasePraise = function(act){ - console.log(act); common.decreaseCommonPraise(act); }; }); @@ -383,9 +380,6 @@ app.directive('textAutoHeight', function($timeout){ var e = element.parent().children().eq(4); var height = e[0].scrollHeight; var offsetHeight = e[0].offsetHeight; - console.log(height); - console.log(offsetHeight); - console.log(attr); if(height>90){ element.css('display', 'block'); element.on('click', function(){