chenlw_dev
guange 9 years ago
commit ce611bc725

@ -30,22 +30,26 @@ module Mobile
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count
end end
when :subject when :subject
if ac.act_type == "HomeworkCommon" unless ac.act.nil?
ac.act.name unless ac.nil? || ac.act.nil? if ac.act_type == "HomeworkCommon"
elsif ac.act_type == "News" || ac.act_type == "BlogComment" ac.act.name unless ac.nil? || ac.act.nil?
ac.act.title unless ac.nil? || ac.act.nil? elsif ac.act_type == "News" || ac.act_type == "BlogComment"
elsif ac.act_type == "Message" || ac.act_type == "Issue" ac.act.title unless ac.nil? || ac.act.nil?
ac.act.subject unless ac.nil? || ac.act.nil? elsif ac.act_type == "Message" || ac.act_type == "Issue"
elsif ac.act_type == "JournalsForMessage" ac.act.subject unless ac.nil? || ac.act.nil?
ac.act.private == 0 ? "留言" : "私信" elsif ac.act_type == "JournalsForMessage"
ac.act.private == 0 ? "留言" : "私信"
end
end end
when :description when :description
if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News" unless ac.act.nil?
ac.act.description unless ac.nil? || ac.act.nil? if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News"
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" ac.act.description unless ac.nil? || ac.act.nil?
ac.act.content unless ac.nil? || ac.act.nil? elsif ac.act_type == "Message" || ac.act_type == "BlogComment"
elsif ac.act_type == "JournalsForMessage" ac.act.content unless ac.nil? || ac.act.nil?
ac.act.notes elsif ac.act_type == "JournalsForMessage"
ac.act.notes
end
end end
when :latest_update when :latest_update
time_from_now ac.updated_at unless ac.nil? time_from_now ac.updated_at unless ac.nil?
@ -103,12 +107,14 @@ module Mobile
if a.is_a? ::UserActivity if a.is_a? ::UserActivity
if a.act_type == "ProjectCreateInfo" if a.act_type == "ProjectCreateInfo"
get_user(get_project(a.act_id).user_id) get_user(get_project(a.act_id).user_id)
elsif a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment' elsif !a.act.nil?
if a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment'
a.act.author a.act.author
elsif a.act_type == 'HomeworkCommon' || a.act_type == 'Poll' || a.act_type == 'JournalsForMessage' elsif a.act_type == 'HomeworkCommon' || a.act_type == 'Poll' || a.act_type == 'JournalsForMessage'
a.act.user a.act.user
elsif a.act_type == 'Course' elsif a.act_type == 'Course'
a.act.teacher a.act.teacher
end
end end
end end
end end

@ -77,47 +77,40 @@ class BlogComment < ActiveRecord::Base
#博客回复微信模板消息 #博客回复微信模板消息
def blog_wechat_message def blog_wechat_message
unless self.parent_id == nil uw = UserWechat.where(user_id: self.parent.author_id).first
uw = UserWechat.where(user_id: self.parent.author_id).first #unless uw.nil? && self.parent.author_id != User.current.id
#unless uw.nil? && self.parent.author_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://weixin.qq.com/download", topcolor:"#FF0000",
topcolor:"#FF0000", data:{
data:{ first: {
first: { value:"您的博客有新回复了",
value:"您的博客有新回复了", color:"#173177"
color:"#173177" },
}, keyword1:{
keyword1:{ value:self.author.try(:realname),
value:self.author.try(:realname), color:"#173177"
color:"#173177" },
}, keyword2:{
keyword2:{ value:format_time(self.created_at),
value:self.created_at, color:"#173177"
color:"#173177" },
}, keyword3:{
keyword3:{ value:h(truncate(key3, :length=>50, :omission=> '...')),
value:h(truncate(" - #{self.content.html_safe}", length:50, omission: '...')), color:"#173177"
color:"#173177" },
}, remark:{
remark:{ value:"具体内容请点击详情查看网站",
value:"具体内容请点击详情查看网站", color:"#173177"
color:"#173177" }
} }
} }
} logger.info "start send template message: #{data}"
uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567") req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
body = data.to_json logger.info "send over. #{req}"
res = Net::HTTP.new(uri.host, uri.port).start do |client|
request = Net::HTTP::Post.new(uri.path)
request.body = body
request["Content-Type"] = "application/json"
client.request(request)
end
end
end end
end end
end end

@ -133,14 +133,9 @@ class HomeworkCommon < ActiveRecord::Base
} }
} }
} }
uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567") logger.info "start send template message: #{data}"
body = data.to_json req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
res = Net::HTTP.new(uri.host, uri.port).start do |client| logger.info "send over. #{req}"
request = Net::HTTP::Post.new(uri.path)
request.body = body
request["Content-Type"] = "application/json"
client.request(request)
end
end end
end end
end end

@ -256,11 +256,11 @@ class Journal < ActiveRecord::Base
color:"#173177" color:"#173177"
}, },
keyword2:{ keyword2:{
value:self.created_on, value:format_time(self.created_on),
color:"#173177" color:"#173177"
}, },
keyword3:{ keyword3:{
value:h(truncate(" - #{self.description.html_safe}", length:50, omission: '...')), value:h(truncate(key3, :length=>50, :omission=> '...')),
color:"#173177" color:"#173177"
}, },
remark:{ remark:{
@ -269,14 +269,9 @@ class Journal < ActiveRecord::Base
} }
} }
} }
uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567") logger.info "start send template message: #{data}"
body = data.to_json req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
res = Net::HTTP.new(uri.host, uri.port).start do |client| logger.info "send over. #{req}"
request = Net::HTTP::Post.new(uri.path)
request.body = body
request["Content-Type"] = "application/json"
client.request(request)
end
end end
end end
end end

@ -326,11 +326,11 @@ class JournalsForMessage < ActiveRecord::Base
color:"#173177" color:"#173177"
}, },
keyword2:{ keyword2:{
value:self.created_on, value:format_time(self.created_on),
color:"#173177" color:"#173177"
}, },
keyword3:{ keyword3:{
value:h(truncate(" - #{self.notes.html_safe}", length:50, omission: '...')), value:h(truncate(key3, :length=>50, :omission=> '...')),
color:"#173177" color:"#173177"
}, },
remark:{ remark:{
@ -339,14 +339,9 @@ class JournalsForMessage < ActiveRecord::Base
} }
} }
} }
uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567") logger.info "start send template message: #{data}"
body = data.to_json req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
res = Net::HTTP.new(uri.host, uri.port).start do |client| logger.info "send over. #{req}"
request = Net::HTTP::Post.new(uri.path)
request.body = body
request["Content-Type"] = "application/json"
client.request(request)
end
end end
end end

@ -710,7 +710,7 @@ class Mailer < ActionMailer::Base
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}", :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}",
:filter => true :filter => true
mail_wechat_message news.author_id, "3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", "您的课程通知有新回复了", @author.try(:realname), comment.created_on, comment.comments.html_safe mail_wechat_message news.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的课程通知有新回复了", @author.try(:realname), format_time(comment.created_on), comment.comments.html_safe
end end
end end
@ -737,10 +737,10 @@ class Mailer < ActionMailer::Base
:filter => true :filter => true
if message.parent_id == nil if message.parent_id == nil
message.project.members.each do |member| message.project.members.each do |member|
mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "项目讨论区有新帖子发布了", message.subject, @author.try(:realname), 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), message.created_on, message.content.html_safe 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
end end
elsif message.course elsif message.course
redmine_headers 'Course' => message.course.id, redmine_headers 'Course' => message.course.id,
@ -759,10 +759,10 @@ class Mailer < ActionMailer::Base
:filter => true :filter => true
if message.parent_id == nil if message.parent_id == nil
message.course.members.each do |member| message.course.members.each do |member|
mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "课程问答区有新帖子发布了", message.subject, @author.try(:realname), 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), message.created_on, message.content.html_safe 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
end end
end end
end end

@ -1,6 +1,6 @@
var app = angular.module('wechat', ['ngRoute','ngCookies']); var app = angular.module('wechat', ['ngRoute','ngCookies']);
var apiUrl = 'http://wechat.trustie.net/api/v1/'; var apiUrl = 'http://wechat.trustie.net/api/v1/';
var debug = false; //调试标志,如果在本地请置为true var debug = true; //调试标志,如果在本地请置为true
if(debug===true){ if(debug===true){
apiUrl = 'http://localhost:3000/api/v1/'; apiUrl = 'http://localhost:3000/api/v1/';
@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){
var _openid = ''; var _openid = '';
if(debug===true){ if(debug===true){
_openid = "2"; _openid = "1";
} }
var getOpenId = function() { var getOpenId = function() {

@ -26,7 +26,7 @@ a.c-grey {color:#707070;}
a:link,a:visited{text-decoration:none;} a:link,a:visited{text-decoration:none;}
a:hover,a:active{cursor:pointer;} a:hover,a:active{cursor:pointer;}
a.link-blue {color:#269ac9;} a.link-blue {color:#269ac9;}
a.underline {border-bottom:1px solid #269ac9;} a.underline {text-decoration: underline;}
.border-radius {border-radius:5px;} .border-radius {border-radius:5px;}
.max-width-60 {max-width:60px;} .max-width-60 {max-width:60px;}
.max-width-130 {max-width:130px;} .max-width-130 {max-width:130px;}
@ -43,20 +43,20 @@ a.underline {border-bottom:1px solid #269ac9;}
.fl {float:left;} .fl {float:left;}
.fr {float:right;} .fr {float:right;}
.cl {clear:both; overflow:hidden;} .cl {clear:both; overflow:hidden;}
.post-content {width:100%; font-size:13px; line-height:18px; height:90px; overflow:hidden; word-break:normal; word-wrap:break-word;} .post-content {width:100%; font-size:13px; line-height:18px; height:90px; overflow:hidden; word-break:break-all; word-wrap:break-word;}
.post-interactive {width:100%; height:35px; line-height:35px; vertical-align:middle; border-top:1px solid #e6e6e6; background-color:#f8f9fb;} .post-interactive {width:100%; height:35px; line-height:35px; vertical-align:middle; border-top:1px solid #e6e6e6; background-color:#f8f9fb;}
.post-interactive-column {width:50%; text-align:center; float:left; font-size:13px;} .post-interactive-column {width:50%; text-align:center; float:left; font-size:13px;}
.post-interactive-reply {width:50%; text-align:center; float:left; font-size:13px;} .post-interactive-reply {width:50%; text-align:center; float:left; font-size:13px;}
.post-interactive-praise {width:50%; text-align:center; float:left; font-size:13px;} .post-interactive-praise {width:50%; text-align:center; float:left; font-size:13px;}
.more-wrap {width:100%;} .more-wrap {width:100%;}
.more-events {width:98%; font-size:13px; text-align:center; margin:0px auto; padding: 5px 0px; border:1px solid #e6e6e6; border-radius:3px; background-color:#f8f9fb; } .more-events {width:98%; font-size:13px; text-align:center; margin:0 auto; padding: 5px 0; border:1px solid #e6e6e6; border-radius:3px; background-color:#f8f9fb; }
.border-bottom {border-bottom:1px solid #e6e6e6;} .border-bottom {border-bottom:1px solid #e6e6e6;}
.post-reply-wrap {width:100%; line-height:18px; background-color:#f8f9fb;} .post-reply-wrap {width:100%; line-height:18px; background-color:#f8f9fb;}
.post-input-wrap {width:100%; line-height:18px; background-color:#f8f9fb;} .post-input-wrap {width:100%; line-height:18px; background-color:#f8f9fb;}
.post-reply-row {padding:10px; color:#9a9a9a;} .post-reply-row {padding:10px; color:#9a9a9a;}
.post-reply-avatar {width:45px; height:30px; text-align:center; margin-right:10px;} .post-reply-avatar {width:45px; height:30px; text-align:center; margin-right:10px;}
.post-reply-user {font-size:13px; text-align:left; margin-bottom:10px;} .post-reply-user {font-size:13px; text-align:left; margin-bottom:10px;}
.post-reply-content {font-size:13px; text-align:left; word-break:normal; word-wrap:break-word;} .post-reply-content {font-size:13px; text-align:left; word-break:break-all; word-wrap:break-word;}
.post-reply-date {font-size:13px;} .post-reply-date {font-size:13px;}
.post-reply-trigger {font-size:13px;} .post-reply-trigger {font-size:13px;}
.post-reply-input {width:100%; height:28px; line-height:28px; border:1px solid #e6e6e6; outline:none; border-radius:3px;} .post-reply-input {width:100%; height:28px; line-height:28px; border:1px solid #e6e6e6; outline:none; border-radius:3px;}

Loading…
Cancel
Save