Merge remote-tracking branch 'remotes/origin/weixin_guange' into develop

Conflicts:
	app/models/blog_comment.rb
chenlw_dev v20160409
huang 9 years ago
commit a2a3d6b6b9

@ -1 +1 @@
{"access_token":"t3XVpwqZbAO6-uRz_ltKUiplgHcYVstA0p43ECTHEjt0-FvVLU7VXzD7n6Z76PYFWHf8hvNHZtLNAUT-FlTl98wWLIK_lh9mhzHxS_x1iXCc0mC38RjxFzZ_NSeERW7dJZCfADAOEH","expires_in":7200,"got_token_at":1460105603} {"access_token":"7MBMEBoE6sSC15bIHZYAZSxj47yCKlbWEVjrkUgEJxPP3K083tbhc1RIWmxGu3WoB5dAXxK_yd4l1jrcvt6YrsTcOfFGRirOHVfzrpvhsQgxOoxcdc7YljfO_dnwUtWgFTAcAIALZG","expires_in":7200,"got_token_at":1460189856}

@ -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_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) 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 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_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.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_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')" course_types = "('Message','News','HomeworkCommon','Poll','Course')"
project_types = "('Message','Issue','ProjectCreateInfo')" project_types = "('Message','Issue','ProjectCreateInfo')"
principal_types = "JournalsForMessage" principal_types = "JournalsForMessage"

@ -86,7 +86,7 @@ class BlogComment < ActiveRecord::Base
data = { data = {
touser:uw.openid, touser:uw.openid,
template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",
url:"http://weixin.qq.com/download", url:"http://www.trustie.net/",
topcolor:"#FF0000", topcolor:"#FF0000",
data:{ data:{
first: { first: {
@ -112,7 +112,11 @@ class BlogComment < ActiveRecord::Base
} }
} }
logger.info "start send template message: #{data}" logger.info "start send template message: #{data}"
begin
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) 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}" logger.info "send over. #{req}"
end end
end end

@ -109,7 +109,7 @@ class HomeworkCommon < ActiveRecord::Base
data = { data = {
touser:uw.openid, touser:uw.openid,
template_id:"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", template_id:"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI",
url:"http://weixin.qq.com/download", url:"http://www.trustie.net/",
topcolor:"#FF0000", topcolor:"#FF0000",
data:{ data:{
first: { first: {
@ -135,7 +135,11 @@ class HomeworkCommon < ActiveRecord::Base
} }
} }
logger.info "start send template message: #{data}" 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}" logger.info "send over. #{req}"
end end
end end

@ -245,7 +245,7 @@ class Journal < ActiveRecord::Base
data = { data = {
touser:uw.openid, touser:uw.openid,
template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",
url:"http://weixin.qq.com/download", url:"http://www.trustie.net/",
topcolor:"#FF0000", topcolor:"#FF0000",
data:{ data:{
first: { first: {
@ -271,7 +271,11 @@ class Journal < ActiveRecord::Base
} }
} }
logger.info "start send template message: #{data}" 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}" logger.info "send over. #{req}"
end end
end end

@ -256,7 +256,7 @@ class JournalsForMessage < ActiveRecord::Base
end end
end end
if self.jour_type == 'HomeworkCommon' if self.jour_type == 'HomeworkCommon'
journal_wechat_message '您的作业有新回复了' journal_wechat_message '您的作业有新回复了',self.jour.user_id
end end
end end
@ -269,7 +269,7 @@ class JournalsForMessage < ActiveRecord::Base
if self.reply_id == 0 if self.reply_id == 0
if self.user_id != self.jour_id # 过滤自己给自己的留言消息 if self.user_id != self.jour_id # 过滤自己给自己的留言消息
receivers << self.jour receivers << self.jour
journal_wechat_message "您有新留言了" journal_wechat_message "您有新留言了",self.jour_id
end end
else # 留言回复 else # 留言回复
reply_to = User.find(self.reply_id) 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 # 给东家发信息,如果回复的对象是东家则不发 if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发
receivers << self.parent.jour receivers << self.parent.jour
end end
journal_wechat_message "您的留言有新回复了" journal_wechat_message "您的留言有新回复了",self.reply_id
end end
receivers.each do |r| 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) 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 end
#微信模板消息 #微信模板消息
def journal_wechat_message type def journal_wechat_message type, user_id
uw = UserWechat.where(user_id: self.reply_id).first uw = UserWechat.where(user_id: user_id).first
#unless uw.nil? && self.reply_id != User.current.id #unless uw.nil? && self.reply_id != User.current.id
unless uw.nil? unless uw.nil?
data = { data = {
touser:uw.openid, touser:uw.openid,
template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",
url:"http://weixin.qq.com/download", url:"http://www.trustie.net/",
topcolor:"#FF0000", topcolor:"#FF0000",
data:{ data:{
first: { first: {
@ -340,7 +340,11 @@ class JournalsForMessage < ActiveRecord::Base
} }
} }
logger.info "start send template message: #{data}" 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}" logger.info "send over. #{req}"
end end
end end

@ -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) mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "项目讨论区有新帖子发布了", message.subject, @author.try(:realname), format_time(message.created_on)
end end
else 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
elsif message.course elsif message.course
redmine_headers 'Course' => message.course.id, 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) mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "课程问答区有新帖子发布了", message.subject, @author.try(:realname), format_time(message.created_on)
end end
else 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 end
end end
@ -1128,7 +1128,7 @@ class Mailer < ActionMailer::Base
data = { data = {
touser:uw.openid, touser:uw.openid,
template_id:template_id, template_id:template_id,
url:"http://weixin.qq.com/download", url:"http://www.trustie.net/",
topcolor:"#FF0000", topcolor:"#FF0000",
data:{ data:{
first: { first: {
@ -1155,9 +1155,12 @@ class Mailer < ActionMailer::Base
} }
logger.info "start send template message: #{data}" 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}" logger.info "send over. #{req}"
end end
end end
end end

@ -216,7 +216,7 @@
</div> </div>
<div ng-if="(count + page * 10) < all_count"> <div ng-if="(count + page * 10) < all_count">
<div id="more_activities" class="more-events mt10" ng-click="loadActData(page+1);">更多</div> <div id="more_activities" class="more-events mt10" ng-click="loadActData(current_page+1);">更多</div>
</div> </div>
</div> </div>

@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){
var _openid = ''; var _openid = '';
if(debug===true){ if(debug===true){
_openid = "1"; _openid = "3";
} }
var getOpenId = function() { var getOpenId = function() {
@ -77,7 +77,15 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){
url: apiUrl+ "activities", url: apiUrl+ "activities",
data: {openid: auth.openid(), page: page} data: {openid: auth.openid(), page: page}
}).then(function successCallback(response) { }).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.all_count = response.data.all_count;
$scope.count = response.data.count; $scope.count = response.data.count;
console.log(response.data); console.log(response.data);
@ -97,12 +105,10 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){
$scope.loadActData = loadActData; $scope.loadActData = loadActData;
$scope.addPraise = function(act){ $scope.addPraise = function(act){
console.log(act);
common.addCommonPraise(act); common.addCommonPraise(act);
}; };
$scope.decreasePraise = function(act){ $scope.decreasePraise = function(act){
console.log(act);
common.decreaseCommonPraise(act); common.decreaseCommonPraise(act);
}; };
@ -110,7 +116,6 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){
app.factory('common', function($http, auth, $routeParams){ app.factory('common', function($http, auth, $routeParams){
var addCommonReply = function(id, type, data, cb){ var addCommonReply = function(id, type, data, cb){
console.log(data.comment);
if(!data.comment || data.comment.length<=0){ if(!data.comment || data.comment.length<=0){
return; return;
@ -197,12 +202,10 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth, co
}; };
$scope.addPraise = function(act){ $scope.addPraise = function(act){
console.log(act);
common.addCommonPraise(act); common.addCommonPraise(act);
}; };
$scope.decreasePraise = function(act){ $scope.decreasePraise = function(act){
console.log(act);
common.decreaseCommonPraise(act); common.decreaseCommonPraise(act);
}; };
}); });
@ -229,12 +232,10 @@ app.controller('HomeworkController', function($scope, $http, $routeParams, auth,
}; };
$scope.addPraise = function(act){ $scope.addPraise = function(act){
console.log(act);
common.addCommonPraise(act); common.addCommonPraise(act);
}; };
$scope.decreasePraise = function(act){ $scope.decreasePraise = function(act){
console.log(act);
common.decreaseCommonPraise(act); common.decreaseCommonPraise(act);
}; };
}); });
@ -261,12 +262,10 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a
}; };
$scope.addPraise = function(act){ $scope.addPraise = function(act){
console.log(act);
common.addCommonPraise(act); common.addCommonPraise(act);
}; };
$scope.decreasePraise = function(act){ $scope.decreasePraise = function(act){
console.log(act);
common.decreaseCommonPraise(act); common.decreaseCommonPraise(act);
}; };
}); });
@ -293,12 +292,10 @@ app.controller('DiscussionController', function($scope, $http, $routeParams, aut
}; };
$scope.addPraise = function(act){ $scope.addPraise = function(act){
console.log(act);
common.addCommonPraise(act); common.addCommonPraise(act);
}; };
$scope.decreasePraise = function(act){ $scope.decreasePraise = function(act){
console.log(act);
common.decreaseCommonPraise(act); common.decreaseCommonPraise(act);
}; };
}); });
@ -383,9 +380,6 @@ app.directive('textAutoHeight', function($timeout){
var e = element.parent().children().eq(4); var e = element.parent().children().eq(4);
var height = e[0].scrollHeight; var height = e[0].scrollHeight;
var offsetHeight = e[0].offsetHeight; var offsetHeight = e[0].offsetHeight;
console.log(height);
console.log(offsetHeight);
console.log(attr);
if(height>90){ if(height>90){
element.css('display', 'block'); element.css('display', 'block');
element.on('click', function(){ element.on('click', function(){

Loading…
Cancel
Save