issue指向改变才发微信消息,增加微信动态里来源链接,@增加微信消息,菜单去掉加入班级和项目等

This commit is contained in:
yuanke 2016-08-30 14:08:10 +08:00
parent a66ecf6c28
commit 8a6ad89973
11 changed files with 205 additions and 34 deletions

View File

@ -73,6 +73,12 @@ module Mobile
elsif ac.container_type == "Blog"
"发表博客"
end
when :course_project_id
if ac.container_type == "Course"
ac.container_id
elsif ac.container_type == "Project"
ac.container_id
end
when :activity_type_name
if ac.container_type == "Course"
case ac.act_type
@ -137,6 +143,7 @@ module Mobile
act_expose :subject #标题
act_expose :description #描述
act_expose :latest_update #最新更新时间
act_expose :course_project_id #课程/项目ID
act_expose :course_project_name #课程/项目名字
act_expose :activity_type_name #课程问答区/项目缺陷等
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|

View File

@ -589,19 +589,19 @@ class IssuesController < ApplicationController
return false
end
end
@issue.safe_attributes = issue_attributes
senduser = User.find(params[:issue][:assigned_to_id])
if senduser.id != User.current.id
if senduser.id != User.current.id && @issue.assigned_to_id != params[:issue][:assigned_to_id]
issue_id = @issue.id
issue_title = params[:issue][:subject]
priority_id = params[:issue][:priority_id]
ps = ProjectsService.new
ps.send_wechat_project_issue_notice senduser,@issue.project,issue_id,issue_title,priority_id
end
@issue.safe_attributes = issue_attributes
@priorities = IssuePriority.active
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
true

View File

@ -3236,6 +3236,16 @@ def get_all_children result, jour
result
end
#获取该节点所在的帖子
def get_root_parent comment
while comment.parent
comment = comment.parent
end
comment
end
#将有置顶属性的提到数组前面
def sort_by_sticky topics
tmpTopics = []

View File

@ -1,6 +1,7 @@
#coding=utf-8
class AtMessage < ActiveRecord::Base
include ApplicationHelper
belongs_to :user
belongs_to :sender, class_name: "User", foreign_key: "sender_id"
attr_accessible :at_message, :container, :viewed, :user_id, :sender_id
@ -10,7 +11,7 @@ class AtMessage < ActiveRecord::Base
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
validates :user_id, :sender_id, :at_message_id, :at_message_type, presence: true
after_create :add_user_message
after_create :add_user_message, :send_wechat_message
scope :unviewed, ->(type, id){
where(at_message_type: type, at_message_id:id, viewed: false)
@ -34,6 +35,88 @@ class AtMessage < ActiveRecord::Base
end
end
def send_wechat_message
shield_type = ""
container_id = 0
status = 0
type = ""
detail_id = 0
detail_title = ""
if defined? at_message.notes
detail_content = strip_html at_message.notes,30
elsif defined? at_message.content
detail_content = strip_html at_message.content,30
end
user = self.user
topic = get_root_parent at_message
case at_message_type
when "Issue"
shield_type = "Project"
container_id = at_message.project.id
type = "issue"
detail_id = topic.id
detail_title = at_message.subject
when "Journal"
topic = get_root_parent at_message.journalized
shield_type = "Project"
container_id = at_message.journalized.project.id
type = "issue"
detail_id = topic.id
detail_title = at_message.journalized.subject
when 'Message'
if at_message.course
shield_type = "Course"
container_id = at_message.course.id
type = "course_discussion"
detail_id = topic.id
detail_title = at_message.subject
elsif at_message.project
shield_type = "Project"
container_id = at_message.project.id
type = "project_discussion"
detail_id = topic.id
detail_title = at_message.subject
else
status = -1
end
when 'JournalsForMessage'
if at_message.jour && at_message.jour.course
shield_type = "Course"
container_id = at_message.jour.course.id
type = "homework"
detail_id = at_message.jour.id
detail_title = at_message.jour.name
else
type = "journal_for_message"
detail_id = topic.id
detail_title = at_message.subject
end
else
status = -1
end
count = 0
detail_title = detail_title.gsub(/RE: /, '')
if container_id != 0
count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='#{shield_type}' and shield_id=#{container_id}").count
end
if count == 0 && status == 0
message_title = self.sender.show_name+"@了您"
ws = WechatService.new
ws.at_notice user.id, type, detail_id, message_title, detail_title, format_time(Time.now), detail_content, "点击查看详情。",0
end
end
def subject
case at_message_type
when "Issue"

View File

@ -432,4 +432,17 @@ class WechatService
end
end
def at_notice(user_id, type, id, first, key1, key2,key3,remark="",uid=0)
uw = UserWechat.where(user_id: user_id).first
unless uw.nil?
data = three_keys_template uw.openid,Wechat.config.at_notice, type, id, first, key1, key2, key3, remark,uid
begin
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
rescue Exception => e
Rails.logger.error "[at_notice] ===> #{e}"
end
Rails.logger.info "send over. #{req}"
end
end
end

View File

@ -22,14 +22,6 @@ button:
-
name: "更多"
sub_button:
-
type: "view"
name: "加入班级"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=join_class#wechat_redirect"
-
type: "view"
name: "加入项目"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=join_project#wechat_redirect"
-
type: "view"
name: "历史推文"

View File

@ -22,14 +22,6 @@ button:
-
name: "更多"
sub_button:
-
type: "view"
name: "加入班级"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=join_class#wechat_redirect"
-
type: "view"
name: "加入项目"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=join_project#wechat_redirect"
-
type: "view"
name: "历史推文"

View File

@ -25,6 +25,7 @@ default: &default
project_review_notice: "kdb-8UlMjTc3z51Qcf8g2vY4i_nE4OGKZAucdQma_2E"
join_project_notice: "TtXvy0XMIQyCgpnXHhoB8t-x0QIfy-78gAJXsGf9afg"
project_issue_notice: "HP8JejOnkzmvFopTarc0l1Tp4bU9qnxzdH27x3186lI"
at_notice: "U3kqzgriCaqkPI9qX0NDQOInJ5hiwHCz6wgTsPysSx4"
auto_openid_url_1: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities"
auto_openid_url_2: "&response_type=code&scope=snsapi_base&state="

View File

@ -25,6 +25,7 @@ default: &default
project_review_notice: "ip192wVXTav3qchgUn9_7B6lFfTlCZjwL7A1tncTOuc"
join_project_notice: "3KnMQEMUCmQWkB5JvzrpmguEwnN8bvUHUdpOTudxv_M"
project_issue_notice: "HAF2aCta7BtnaOd_cotGvU4tErGWwCd9I9aiClFN7w8"
at_notice: "p4HfyZQuF8O5bP_44RbbJS30SGojLJAuZEqp34iB4JU"
auto_openid_url_1: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities"
auto_openid_url_2: "&response_type=code&scope=snsapi_base&state="

View File

@ -40,7 +40,7 @@
</div>
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goClass(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
@ -75,7 +75,7 @@
</div>
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goClass(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
@ -111,7 +111,7 @@
<!--<a herf="javascript:void(0);" class="c-grey2 f13 fr mt5 mb10 post-more mr20 undis" text-auto-height>点击展开</a>-->
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goClass(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
@ -147,7 +147,7 @@
<!--<a herf="javascript:void(0);" class="c-grey2 f13 fr mt5 mb10 post-more mr20 undis" text-auto-height>点击展开</a>-->
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goClass(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<!--<div class="fr f13">-->
<!--<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>赞</span></div>-->
<!--<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>-->
@ -236,7 +236,7 @@
</div>
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goProject(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
@ -272,7 +272,7 @@
</div>
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goProject(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
@ -405,7 +405,7 @@
</div>
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goClass(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
@ -440,7 +440,7 @@
</div>
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goClass(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
@ -476,7 +476,7 @@
<!--<a herf="javascript:void(0);" class="c-grey2 f13 fr mt5 mb10 post-more mr20 undis" text-auto-height>点击展开</a>-->
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goClass(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
@ -492,6 +492,42 @@
</div>
</div>
<div ng-if="act.act_type=='Poll'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div dataID = "{{act.act_id}}" id="act_{{act.id}}">
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
<div class="post-dynamic-author hidden fl">
<span>{{act.author.real_name}}</span>
<img ng-if="act.author.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
<img ng-if="act.author.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
</div>
<div class="post-dynamic-time fr f13">{{act.latest_update}}</div>
<div class="cl"></div>
<div class="post-dynamic-title c-grey3 hidden mt12 fb">【问卷】{{act.subject|safeHtml}}</div>
<div class="post-content c-grey3 mt10 mb10">
<div class="post-all-content" ng-bind-html="act.description|safeHtml" ellipsis-show></div>
</div>
<!--<a herf="javascript:void(0);" class="c-grey2 f13 fr mt5 mb10 post-more mr20 undis" text-auto-height>点击展开</a>-->
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goClass(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<!--<div class="fr f13">-->
<!--<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>赞</span></div>-->
<!--<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>-->
<!--<div ng-if="act.has_praise" ng-click="decreasePraise(act);"><img src="/images/wechat/w_praised.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>-->
<!--</div>-->
<!--<div class="fr mr25 f13">-->
<!--<a ng-if="!act.reply_count" ng-click="goDetail('course_discussion',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">回复</span></a>-->
<!--<a ng-if="act.reply_count" ng-click="goDetail('course_discussion',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">{{act.reply_count}}</span></a>-->
<!--</div>-->
<div class="cl"></div>
</div>
</div>
</div>
</div>
<div ng-if="act.act_type=='Course'">
<div class="post-container">
@ -536,7 +572,7 @@
</div>
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goProject(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
@ -572,7 +608,7 @@
</div>
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span ng-click = "goProject(act.course_project_id)" class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>

View File

@ -126,14 +126,14 @@ app.controller('ActivityController',
}
break;
}
rms.save("tab_num",$scope.currentTab);
rms.save("activity_tab_num",$scope.currentTab);
}
$scope.currentTab = rms.get('tab_num') || 1;
$scope.currentTab = rms.get('activity_tab_num') || 1;
if($scope.activities.length<=0){
$scope.loadActData('tab_num',0);
$scope.loadActData($scope.currentTab,0);
} else {
$timeout(function(){
window.scrollTo(0, rms.get("yoffset"));
@ -200,4 +200,40 @@ app.controller('ActivityController',
common.decreaseCommonPraise(act);
};
$scope.goClass = function(id){
rms.save("activities",[]);
rms.save("course_activities",[]);
rms.save("project_activities",[]);
rms.save('course_activities_page',0);
rms.save("course_has_more",false);
rms.save("course",null);
rms.save("tab_num",null);
rms.save("has_more",false);
rms.save("project_has_more",false);
$location.path("/class").search({id: id});
};
$scope.goProject = function(id){
rms.save("activities",[]);
rms.save("course_activities",[]);
rms.save("project_activities",[]);
rms.save('project_activities_page',0);
rms.save("project_has_more",false);
rms.save("project",null);
rms.save("project_master_members",[]);
rms.save("project_develop_members",[]);
rms.save("project_report_members",[]);
rms.save("review_master_members",[]);
rms.save("review_develop_members",[]);
rms.save('tab_num',null);
rms.save("has_more",false);
rms.save("course_has_more",false);
$location.path("/project").search({id: id});
};
}]);