Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange

This commit is contained in:
guange 2016-04-09 16:02:24 +08:00
commit 2d41d0a2f6
6 changed files with 21 additions and 27 deletions

View File

@ -1 +1 @@
{"access_token":"t3XVpwqZbAO6-uRz_ltKUiplgHcYVstA0p43ECTHEjt0-FvVLU7VXzD7n6Z76PYFWHf8hvNHZtLNAUT-FlTl98wWLIK_lh9mhzHxS_x1iXCc0mC38RjxFzZ_NSeERW7dJZCfADAOEH","expires_in":7200,"got_token_at":1460105603}
{"access_token":"G4QG7VJgF8Vmm71kLgC1XgHvyeXK-ZZrikaG7sPBrKuw6vgbYzV2FPYuNq3wNp7e-hsyfDI--rTlVspQXZk5bRK_CsZl8wWvuiPazV9mznGpOBGE5zVR8WOtvlqhylpHIMBdABABFU","expires_in":7200,"got_token_at":1460179500}

View File

@ -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"

View File

@ -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,8 +307,8 @@ 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 = {

View File

@ -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

View File

@ -216,7 +216,7 @@
</div>
<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>

View File

@ -1,6 +1,6 @@
var app = angular.module('wechat', ['ngRoute','ngCookies']);
var apiUrl = 'http://wechat.trustie.net/api/v1/';
var debug = true; //调试标志,如果在本地请置为true
var debug = false; //调试标志,如果在本地请置为true
if(debug===true){
apiUrl = 'http://localhost:3000/api/v1/';
@ -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(){