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

# Conflicts:
#	public/javascripts/wechat/app.js
This commit is contained in:
guange 2016-04-06 15:23:20 +08:00
commit 3ee79a6889
16 changed files with 2510 additions and 2406 deletions

View File

@ -24,11 +24,7 @@ module Mobile
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id])
if (feedback.errors.empty?)
homework_common.update_attributes(:updated_at => Time.now)
data = homework_common.journals_for_messages.last
present :data, data, with: Mobile::Entities::Jours
result = 2
else
result = 3
end
when "News"
news = News.find(params[:id])
@ -36,11 +32,7 @@ module Mobile
comment.comments = params[:content]
comment.author = current_user
if news.comments << comment
data = comment
present :data, data, with: Mobile::Entities::Comment
result = 2
else
result = 3
end
when "Message"
message = Message.find(params[:id])
@ -53,11 +45,7 @@ module Mobile
reply.parent_id = params[:id]
reply.subject = "RE: #{topic.subject}"
if topic.children << reply
data = reply
present :data, data, with: Mobile::Entities::Message
result = 2
else
result = 3
end
when "JournalsForMessage"
jour = JournalsForMessage.find params[:id]
@ -77,8 +65,6 @@ module Mobile
if jfm.errors.empty?
(JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now)
result = 2
else
result = 3
end
when 'Issue'
issue = Issue.find params[:id]
@ -86,13 +72,8 @@ module Mobile
is_jour.user_id = current_user.id
is_jour.notes = params[:content]
is_jour.journalized = issue
#is_jour.journalized_type = "Issue"
if is_jour.save
data = is_jour
present :data, data, with: Mobile::Entities::Journal
result = 2
else
result = 3
end
when 'BlogComment'
blog = BlogComment.find(params[:id]).root
@ -101,11 +82,8 @@ module Mobile
blogComment.blog = blog.blog
blogComment.content = params[:content]
blogComment.title = "RE: #{blog.title}"
blog.children << blogComment
if blog.save
if blog.children << blogComment
result = 2
else
result = 3
end
end
if result == 2
@ -116,7 +94,7 @@ module Mobile
update_principal_activity_api(type,params[:id])
end
else
result = 4
result = 3
end
present :result, result
present :status, 0

View File

@ -0,0 +1,40 @@
#coding=utf-8
module Mobile
module Apis
class Praise< Grape::API
include ApiHelper
resources :praise do
desc "praise an activity"
params do
requires :type, type: String
requires :openid, type: String
end
post ':id' do
obj_id = params[:id]
obj_type = params[:type]
user = UserWechat.find_by_openid(params[:openid]).user
obj = find_object_by_type_and_id(obj_id,obj_type)
pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",obj_id,obj_type.to_s,user.id)
if pts.empty?
praise_or_cancel(obj_type,obj_id,user,1)
num = get_activity_praise_num(obj)
else
pts.delete if !pts.nil?
#再更新praise_tread_cache表 使相应的记录减1 当为0时删除
ptc = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first
ptc.praise_minus(1) if !ptc.nil?
if ptc.praise_num == 0
ptc.delete
end
num = get_activity_praise_num(obj)
end
present :data, num
present :status, 0
end
end
end
end
end

View File

@ -19,6 +19,8 @@ module Mobile
time_from_now f.created_on
when :reply_count
f.children.count
when :message_praise_count
get_activity_praise_num(f)
end
end
end
@ -35,6 +37,7 @@ module Mobile
jours_expose :m_reply_id
jours_expose :m_parent_id
jours_expose :reply_count
jours_expose :message_praise_count
expose :course,using:Mobile::Entities::Course do |f,opt|
if f.is_a?(::JournalsForMessage) && f[:jour_type] == "Course"
f.course

View File

@ -412,7 +412,7 @@ module ApiHelper
#课程动态的更新
def update_course_activity_api type, id
course_activity = CourseActivity.where("course_act_type=? and course_act_id =?", type.to_s, id).first
course_activity = CourseActivity.where("course_act_type=? and course_act_id =?", type.to_s, id.to_i).first
if course_activity
course_activity.updated_at = Time.now
course_activity.save
@ -420,7 +420,7 @@ module ApiHelper
end
#首页动态更新
def update_user_activity_api type, id
user_activity = UserActivity.where("act_type=? and act_id =?", type.to_s, id).first
user_activity = UserActivity.where("act_type=? and act_id =?", type.to_s, id.to_i).first
if user_activity
user_activity.updated_at = Time.now
user_activity.save
@ -428,7 +428,7 @@ module ApiHelper
end
#项目动态更新
def update_forge_activity_api type, id
forge_activity = ForgeActivity.where("forge_act_type=? and forge_act_id=?", type.to_s, id).first
forge_activity = ForgeActivity.where("forge_act_type=? and forge_act_id=?", type.to_s, id.to_i).first
if forge_activity
forge_activity.updated_at = Time.now
forge_activity.save
@ -436,7 +436,7 @@ module ApiHelper
end
#组织动态更新
def update_org_activity_api type , id
org_activity = OrgActivity.where("org_act_type=? and org_act_id =?", type.to_s, id).first
org_activity = OrgActivity.where("org_act_type=? and org_act_id =?", type.to_s, id.to_i).first
if org_activity
org_activity.updated_at = Time.now
org_activity.save
@ -444,10 +444,45 @@ module ApiHelper
end
#个人动态更新
def update_principal_activity_api type, id
principal_activity = PrincipalActivity.where("principal_act_type=? and principal_act_id =?", type.to_s, id).first
principal_activity = PrincipalActivity.where("principal_act_type=? and principal_act_id =?", type.to_s, id.to_i).first
if principal_activity
principal_activity.updated_at = Time.now
principal_activity.save
end
end
#赞/取消赞
def praise_or_cancel(type,id,user,flag)
unless id.nil? and type.nil?
#首先创建或更新praise_tread 表
pt = PraiseTread.new
pt.user_id = user.id
pt.praise_tread_object_id = id.to_i
pt.praise_tread_object_type = type
pt.praise_or_tread = flag
pt.save
# end
#再创建或更新praise_tread_cache表
#@ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type)
ptc = PraiseTreadCache.where("object_id = ? and object_type = ?",id.to_i,type).first
ptc = ptc.nil? ? PraiseTreadCache.new : ptc
ptc.object_id = id.to_i
ptc.object_type = type
ptc.save
ptc.praise_plus(flag,1)
end
end
def praise_plus(flag,num)
case flag
when 1
self.update_attribute(:praise_num, self.praise_num.to_i + num)
end
end
def praise_minus(num)
self.update_attribute(:praise_num, self.praise_num.to_i - num)
end
end

File diff suppressed because it is too large Load Diff

View File

@ -12,9 +12,9 @@
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10">{{act.author.nickname}}</a>to<a herf="javascript:void(0);" class="ml10">{{act.course_project_name}}&nbsp;&nbsp;|&nbsp;&nbsp;{{act.activity_type_name}}</a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<div class="post-all-content" ng-bind-html="act.description|safeHtml"><br />
<span class="mr15">迟交扣分:{{act.homework_common_detail.late_penalty}}分</span> 匿评开启时间:{{act.homework_common_detail.evaluation_start}}<br />
<span class="mr15">缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品</span> 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}</div>
<div class="post-all-content" ng-bind-html="act.description|safeHtml"></div>
<span class="mr15">迟交扣分:{{act.homework_common_detail.late_penalty}}分</span> 匿评开启时间:{{act.homework_common_detail.evaluation_start}}<br />
<span class="mr15">缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品</span> 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
</div>
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
<div class="cl"></div>
@ -22,7 +22,7 @@
<div class="cl"></div>
</div>
<div class="post-interactive">
<div class="post-interactive-column c-grey2"><a href="javascript:void(0);" ng-click="window.open('homework_detail.html?id={{act.act_id}}');" class="c-grey">回复 ({{act.reply_count}})</a></div>
<div class="post-interactive-column c-grey2"><a href="javascript:void(0);" ng-href="#/homework/{{act.act_id}}" class="c-grey">回复 ({{act.reply_count}})</a></div>
<div class="post-interactive-column c-grey2">赞 ({{act.activity_praise_count}})</div>
</div>
</div>
@ -47,7 +47,7 @@
<div class="cl"></div>
</div>
<div class="post-interactive">
<div class="post-interactive-column c-grey2"><a href="javascript:void(0);" ng-click="window.open('course_notice.html?id={{act.act_id}}');" class="c-grey">回复 ({{act.reply_count}})</a></div>
<div class="post-interactive-column c-grey2"><a href="javascript:void(0);" ng-href="#/course_notice/{{act.act_id}}" class="c-grey">回复 ({{act.reply_count}})</a></div>
<div class="post-interactive-column c-grey2">赞 ({{act.activity_praise_count}})</div>
</div>
</div>
@ -63,9 +63,9 @@
<div class="post-title fl mb10 hidden"><a herf="javascript:void(0);" class="mr10">{{act.author.nickname}}</a>to<a herf="javascript:void(0);" class="ml10">{{act.course_project_name}}&nbsp;&nbsp;|&nbsp;&nbsp;{{act.activity_type_name}}</a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<p class="post-all-content" ng-bind-html="act.description|safeHtml"></p>
<div class="post-all-content" ng-bind-html="act.description|safeHtml"></div>
</div>
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline;">点击展开</a>
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline;" ng-click="descToggle()">点击展开</a>
<span class="c-grey f13 mt10 fl">{{act.latest_update}}</span>
<div class="cl"></div>
</div>
@ -104,8 +104,9 @@
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10">{{act.author.nickname}}</a>to<a herf="javascript:void(0);" class="ml10">{{act.course_project_name}}&nbsp;&nbsp;|&nbsp;&nbsp;{{act.activity_type_name}}</a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<div class="post-all-content" ng-bind-html="act.description|safeHtml"><br />
<span class="mr15">状态:{{act.issue_detail.issue_status}}</span> <span class="mr15">优先级:{{act.issue_detail.issue_priority}}</span> <br /> <span class="mr15">指派给:{{act.issue_detail.issue_assigned_to}}</span> <span class="mr15">完成度:{{act.issue_detail.done_ratio}}%</span></div>
<div class="post-all-content" ng-bind-html="act.description|safeHtml"></div>
<span class="mr15">状态:{{act.issue_detail.issue_status}}</span> <span class="mr15">优先级:{{act.issue_detail.issue_priority}}</span> <br />
<span class="mr15">指派给:{{act.issue_detail.issue_assigned_to}}</span> <span class="mr15">完成度:{{act.issue_detail.done_ratio}}%</span>
</div>
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
<div class="cl"></div>
@ -141,6 +142,14 @@
<div class="post-interactive-column c-grey2"><a href="javascript:void(0);" class="c-grey"> 回复 ({{act.reply_count}}) </a></div>
<div class="post-interactive-column c-grey2">赞 ({{act.activity_praise_count}})</div>
</div>
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
<div class="cl"></div>
<span class="c-grey f13 mt10 fl"><!=activities[i].latest_update!></span>
<div class="cl"></div>
</div>
<div class="post-interactive">
<div class="post-interactive-column c-grey2"><a href="javascript:void(0);" onclick="window.open('project_discussion.html?id=<!=activities[i].act_id!>');" class="c-grey"> 回复 (<!=activities[i].reply_count!>) </a></div>
<div class="post-interactive-column c-grey2">赞 (<!=activities[i].activity_praise_count!>)</div>
</div>
</div>
</div>

View File

@ -20,6 +20,7 @@
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular-route.js"></script>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular-sanitize.min.js"></script>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular-cookies.js"></script>
<script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/wechat/app.js"></script>
</body>

View File

@ -1,31 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>课程讨论区</title>
<meta charset='utf-8' />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="apple-mobile-web-app-capable" content="no">
<meta content='True' name='HandheldFriendly' />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" />
</head>
<body>
<div id="c-discussion-container"></div>
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:course-discussion" type="text/html">
<div id="check"></div>
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=discussion.user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=discussion.subject!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=discussion.user.nickname!></a>to<a herf="javascript:void(0);" class="ml10"><!=discussion.discussion_name!>&nbsp;&nbsp;|&nbsp;&nbsp;课程问答区</a></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=discussion.user.nickname!></a>to<a herf="javascript:void(0);" class="ml10"><!=discussion.course_project_name!>&nbsp;&nbsp;|&nbsp;&nbsp;课程问答区</a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10" style="height:auto;">
<div class="post-all-content"><!:=discussion.content!></div>
@ -63,27 +43,4 @@
</div>
</div>
</div>
</div>
</script>
<script id="t:c-message-detail-reply" type="text/html">
<div class="post-reply-wrap border-bottom">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="<!=reply.user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden"><!=reply.user.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=reply.content!></div>
<div class="post-reply-date fl"><!=reply.lasted_comment!></div>
</div>
<div class="cl"></div>
</div>
</div>
</script>
<script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/baiduTemplate.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
<script src="/javascripts/wechat/course_discussion.js"></script>
</body>
</html>
</div>

View File

@ -1,91 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<title>课程通知</title>
<meta charset='utf-8' />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="apple-mobile-web-app-capable" content="no">
<meta content='True' name='HandheldFriendly' />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" />
</head>
<body>
<div id="c-notice-container"></div>
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:course-notice" type="text/html">
<div id="check"></div>
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=course.author_img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=course.title!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=course.author_name!></a>to<a herf="javascript:void(0);" class="ml10"><!=course.course_name!>&nbsp;&nbsp;|&nbsp;&nbsp;课程作业</a></div>
<div class="post-avatar fl"><img ng-src="{{news.author.img_url}}" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb">{{news.title}}</span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10">{{news.author.nickname}}</a>to<a herf="javascript:void(0);" class="ml10">{{news.course_name}}&nbsp;&nbsp;|&nbsp;&nbsp;课程通知</a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10" style="height:auto;">
<div class="post-all-content"><!:=course.description!></div>
<div class="post-all-content" ng-bind-html="news.description|safeHtml"></div>
</div>
<div class="cl"></div>
<span class="c-grey f13 mt10 fl"><!=course.created_on!></span>
<span class="c-grey f13 mt10 fl">{{news.created_on}}</span>
<div class="cl"></div>
</div>
<div class="post-interactive border-bottom">
<div class="post-interactive-reply c-grey2">回复 <span class="reply-num">(<!=course.comments_count!>)</span></div>
<div class="post-interactive-praise c-grey2"><span class="paise-text"></span><span class="praise-num">(<!=course.news_praise_count!>)</span></div>
<div class="post-interactive-reply c-grey2">回复 <span class="reply-num">({{news.comments_count}})</span></div>
<div class="post-interactive-praise c-grey2"><span class="paise-text"></span><span class="praise-num">({{news.news_praise_count}})</span></div>
</div>
<div id="all_news_reply">
<! for(var j = (course.comments.length -1); j >= 0; --j){ !>
<div class="post-reply-wrap border-bottom">
<div class="post-reply-wrap border-bottom" ng-repeat="comments in news.comments">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="<!=course.comments[j].author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-reply-avatar fl"><img ng-src="{{comments.author.img_url}}" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden"><!=course.comments[j].author.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=course.comments[j].comments!></div>
<div class="post-reply-date fl"><!=course.comments[j].created_on!></div>
<div class="post-reply-user hidden">{{comments.author.realname}}</div>
<div class="post-reply-content c-grey2 mb10">{{comments.comments}}</div>
<div class="post-reply-date fl">{{comments.created_on}}</div>
<div class="post-reply-trigger fr undis">回复</div>
</div>
<div class="cl"></div>
</div>
</div>
<! } !>
</div>
<div class="post-input-wrap">
<div class="post-reply-row">
<!--<div class="post-reply-avatar fl" id = "100"><img src="images/post-avatar.jpg" width="30" height="30" /></div>-->
<input type="text" class="post-reply-input" id="postInput" />
<input type="submit" value="回复" class="post-reply-submit fr mt10" />
<!--<div class="post-reply-avatar fl"><img src="images/post-avatar.jpg" width="30" height="30" /></div>-->
<input type="text" class="post-reply-input" id="postInput" ng-model="formData.comment" />
<button ng-click="addIssueReply(formData)" class="post-reply-submit fr mt10">回复</button>
<div class="cl"></div>
</div>
</div>
</div>
</div>
</script>
<script id="t:news-detail-reply" type="text/html">
<div class="post-reply-wrap border-bottom">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="<!=reply.author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden"><!=reply.author.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=reply.comments!></div>
<div class="post-reply-date fl"><!=reply.created_on!></div>
</div>
<div class="cl"></div>
</div>
</div>
</script>
<script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/baiduTemplate.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
<script src="/javascripts/wechat/course_notice.js"></script>
</body>
</html>

View File

@ -1,90 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<title>作业详情</title>
<meta charset='utf-8' />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="apple-mobile-web-app-capable" content="no">
<meta content='True' name='HandheldFriendly' />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" />
</head>
<body>
<div id="homework-container"></div>
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:homework-detail" type="text/html">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=homework.author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=homework.name!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=homework.author.nickname!></a>to<a herf="javascript:void(0);" class="ml10"><!=homework.course_name!>&nbsp;&nbsp;|&nbsp;&nbsp;课程作业</a></div>
<div class="post-avatar fl"><img ng-src="{{homework.author.img_url}}" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb">{{homework.name}}</span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10">{{homework.author.nickname}}</a>to<a herf="javascript:void(0);" class="ml10">{{homework.course_name}}&nbsp;&nbsp;|&nbsp;&nbsp;课程作业</a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10" style="height:auto;">
<div class="post-all-content"><!:=homework.description!><br />
<span class="mr15">迟交扣分:<!:=homework.late_penalty!></span> 匿评开启时间:<!:=homework.evaluation_start!><br />
<span class="mr15">缺评扣分:<!:=homework.absence_penalty!>分/作品</span> 匿评关闭时间:<!:=homework.evaluation_end!></div>
<div class="post-all-content" ng-bind-html="homework.description|safeHtml"></div>
<span class="mr15">迟交扣分:{{homework.late_penalty}}分</span> 匿评开启时间:{{homework.evaluation_start}}<br />
<span class="mr15">缺评扣分:{{homework.absence_penalty}}分/作品</span> 匿评关闭时间:{{homework.evaluation_end}}
</div>
<div class="cl"></div>
<span class="c-grey f13 mt10 fl"><!=homework.publish_time!></span>
<span class="c-grey f13 mt10 fl">{{homework.publish_time}}</span>
<div class="cl"></div>
</div>
<div class="post-interactive border-bottom">
<div class="post-interactive-reply c-grey2">回复 <span class="reply-num">(<!=homework.whomework_journal_count!>)</span></div>
<div class="post-interactive-praise c-grey2"><span class="paise-text"></span><span class="praise-num">(<!=homework.whomework_praise_count!>)</span></div>
<div class="post-interactive-reply c-grey2">回复 <span class="reply-num">({{homework.whomework_journal_count}})</span></div>
<div class="post-interactive-praise c-grey2"><span class="paise-text"></span><span class="praise-num">({{homework.whomework_praise_count}})</span></div>
</div>
<div id="all_homework_reply">
<! for(var j = (homework.journals_for_messages.length - 1); j >= 0; --j){ !>
<div class="post-reply-wrap border-bottom">
<div class="post-reply-wrap border-bottom" ng-repeat="journal in homework.journals_for_messages">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="<!=homework.journals_for_messages[j].user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-reply-avatar fl"><img ng-src="{{journal.user.img_url}}" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden"><!=homework.journals_for_messages[j].user.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=homework.journals_for_messages[j].notes!></div>
<div class="post-reply-date fl"><!=homework.journals_for_messages[j].lasted_comment!></div>
<div class="post-reply-user hidden">{{journal.user.realname}}</div>
<div class="post-reply-content c-grey2 mb10" ng-bind-html="journal.notes|safeHtml"></div>
<div class="post-reply-date fl">{{journal.lasted_comment}}</div>
<div class="post-reply-trigger fr undis">回复</div>
</div>
<div class="cl"></div>
</div>
</div>
<! } !>
</div>
<div class="post-input-wrap">
<div class="post-reply-row">
<!--<div class="post-reply-avatar fl"><img src="images/post-avatar.jpg" width="30" height="30" /></div>-->
<input type="text" class="post-reply-input" id="postInput" />
<input type="submit" value="回复" class="post-reply-submit fr mt10" />
<input type="text" class="post-reply-input" id="postInput" ng-model="formData.comment" />
<button ng-click="addIssueReply(formData)" value="回复" class="post-reply-submit fr mt10">回复</button>
<div class="cl"></div>
</div>
</div>
</div>
</div>
</script>
<script id="t:homework-detail-reply" type="text/html">
<div class="post-reply-wrap border-bottom">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="<!=reply.user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden"><!=reply.user.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=reply.notes!></div>
<div class="post-reply-date fl"><!=reply.lasted_comment!></div>
</div>
<div class="cl"></div>
</div>
</div>
</script>
<script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/baiduTemplate.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
<script src="/javascripts/wechat/homework_detail.js"></script>
</body>
</html>
</div>

View File

@ -8,8 +8,8 @@
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10">{{issue.author.nickname}}</a>to<span class="ml10">{{issue.project_name}}&nbsp;&nbsp;|&nbsp;&nbsp;项目缺陷</span></div>
<div class="cl"></div>
<div class="post-content" style="height:auto;">
<div class="post-all-content c-grey2 mt10"><!:=issue.description}}<br />
<span class="mr15">状态:<!:=issue.issue_status}}</span> <span class="mr15">优先级:<!:=issue.issue_priority}}</span> <br /> <span class="mr15">指派给:<!:=issue.issue_assigned_to}}</span> <span class="mr15">完成度:<!:=issue.done_ratio}}%</span></div>
<div class="post-all-content c-grey2 mt10">{{issue.description}}<br />
<span class="mr15">状态:{{issue.issue_status}}</span> <span class="mr15">优先级:{{issue.issue_priority}}</span> <br /> <span class="mr15">指派给:{{issue.issue_assigned_to}}</span> <span class="mr15">完成度:{{issue.done_ratio}}%</span></div>
</div>
<div class="cl"></div>
<span class="c-grey f13 mt10 fl">{{issue.created_on}}</span>
@ -20,7 +20,6 @@
<div class="post-interactive-praise c-grey2"><span class="paise-text"></span> <span class="praise-num">({{issue.issue_praise_count}})</span></div>
</div>
<div id="all_issue_reply">
<div class="post-reply-wrap border-bottom" ng-repeat="journal in issue.issue_journals">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img ng-src="{{journal.user.img_url}}" width="45" height="45" class="border-radius" /></div>
@ -44,17 +43,3 @@
</div>
</div>
</div>
<script id="t:issue-detail-reply" type="text/html">
<div class="post-reply-wrap border-bottom">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="{{issue_reply.user.img_url}}" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden">{{issue_reply.user.realname}}</div>
<div class="post-reply-content c-grey2 mb10"><!:=issue_reply.notes}}</div>
<div class="post-reply-date fl">{{issue_reply.created_on}}</div>
</div>
<div class="cl"></div>
</div>
</div>
</script>

View File

@ -0,0 +1,42 @@
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img ng-src="{{message.user.img_url}}" width="45" height="45" class="border-radius" /></div>
<div class="post-title mb5 hidden"><a herf="javascript:void(0);" class="mr10">{{message.user.nickname}}</a><span style="vertical-align:top;">给您留言了</span><br /></div>
<div class="post-title hidden">{{message.created_on}}</div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10" style="height:auto;">
<div class="post-all-content">{{message.notes}}</div>
</div>
<div class="cl"></div>
</div>
<div class="post-interactive border-bottom">
<div class="post-interactive-reply c-grey2">回复 <span class="reply-num">({{message.reply_count}})</span></div>
<div class="post-interactive-praise c-grey2"><span class="paise-text"></span> <span class="praise-num">({{message.message_praise_count}})</span></div>
</div>
<div id="all_message_reply">
<div class="post-reply-wrap border-bottom" ng-repeat="journal in message.child_reply">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img ng-src="{{journal.user.img_url}}" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden">{{journal.user.realname}}</div>
<div class="post-reply-content c-grey2 mb10" ng-bind-html="journal.content|safeHtml"></div>
<div class="post-reply-date fl">{{journal.lasted_comment}}</div>
<div class="post-reply-trigger fr undis">回复</div>
</div>
<div class="cl"></div>
</div>
</div>
</div>
<div class="post-input-wrap">
<div class="post-reply-row">
<!--<div class="post-reply-avatar fl"><img src="images/post-avatar.jpg" width="30" height="30" /></div>-->
<input type="text" class="post-reply-input" id="postInput" ng-model="formData.comment" />
<button ng-click="addJournalReply(formData)" class="post-reply-submit fr mt10">回复</button>
<div class="cl"></div>
</div>
</div>
</div>
</div>

View File

@ -1,71 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>留言</title>
<meta charset='utf-8' />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="apple-mobile-web-app-capable" content="no">
<meta content='True' name='HandheldFriendly' />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" />
</head>
<body>
<div id="message-container"></div>
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:message-detail" type="text/html">
<div id="check"></div>
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=message.user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title mb5 hidden"><a herf="javascript:void(0);" class="mr10"><!=message.user.nickname!></a><span style="vertical-align:top;">给您留言了</span><br /></div>
<div class="post-title hidden"><!=message.created_on!></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10" style="height:auto;">
<div class="post-all-content"><!:=message.notes!></div>
</div>
<div class="cl"></div>
</div>
<div class="post-interactive border-bottom">
<div class="post-interactive-reply c-grey2">回复 <span class="reply-num">(<!=message.reply_count!>)</span></div>
<div class="post-interactive-praise c-grey2"><span class="paise-text"></span><span class="praise-num">()</span></div>
</div>
<! for(var j =0; j < message.child_reply.length; ++j){ !>
<div class="post-reply-wrap border-bottom">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="<!=message.child_reply[j].user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden"><!=message.child_reply[j].user.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=message.child_reply[j].content!></div>
<div class="post-reply-date fl"><!=message.child_reply[j].lasted_comment!></div>
<div class="post-reply-trigger fr undis">回复</div>
</div>
<div class="cl"></div>
</div>
</div>
<! } !>
<div class="post-input-wrap">
<div class="post-reply-row">
<!--<div class="post-reply-avatar fl" id = "100"><img src="images/post-avatar.jpg" width="30" height="30" /></div>-->
<input type="text" class="post-reply-input" id="postInput" />
<input type="submit" value="回复" class="post-reply-submit fr mt10" onclick="replyInsert()" />
<div class="cl"></div>
</div>
</div>
</div>
</div>
</script>
<script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/baiduTemplate.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
<script src="/javascripts/wechat/message_detail.js"></script>
</body>
</html>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>课程讨论区</title>
<title>项目讨论区</title>
<meta charset='utf-8' />
<meta name="keywords" content="" />
<meta name="description" content="" />
@ -18,45 +18,46 @@
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:prject-discussion" type="text/html">
<div id="check"></div>
<script id="t:project-discussion" type="text/html">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=homework.author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=homework.name!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=homework.author.nickname!></a>to<a herf="javascript:void(0);" class="ml10"><!=homework.course_name!>&nbsp;&nbsp;|&nbsp;&nbsp;课程作业</a></div>
<div class="post-avatar fl"><img src="<!=discussion.user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=discussion.subject!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=discussion.user.nickname!></a>to<a herf="javascript:void(0);" class="ml10"><!=discussion.course_project_name!>&nbsp;&nbsp;|&nbsp;&nbsp;项目讨论区</a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10" style="height:auto;">
<div class="post-all-content"><!:=homework.description!></div>
<div class="post-all-content"><!:=discussion.content!></div>
</div>
<div class="cl"></div>
<span class="c-grey f13 mt10 fl"><!=homework.publish_time!></span>
<span class="c-grey f13 mt10 fl"><!=discussion.created_on!></span>
<div class="cl"></div>
</div>
<div class="post-interactive border-bottom">
<div class="post-interactive-reply c-grey2">回复 <span class="reply-num">(<!=homework.whomework_journal_count!>)</span></div>
<div class="post-interactive-praise c-grey2"><span class="paise-text"></span><span class="praise-num">(<!=homework.whomework_praise_count!>)</span></div>
<div class="post-interactive-reply c-grey2">回复 <span class="reply-num">(<!=discussion.replies_count!>)</span></div>
<div class="post-interactive-praise c-grey2"><span class="paise-text"></span><span class="praise-num">()</span></div>
</div>
<! for(var j =0; j < homework.journals_for_messages.length; ++j){ !>
<div id="all_homework_reply">
<! for(var j = (homework.journals_for_messages.length - 1); j >= 0; --j){ !>
<div class="post-reply-wrap border-bottom">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="<!=homework.journals_for_messages[j].user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-reply-avatar fl"><img src="<!=discussion.message_children[j].user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden"><!=homework.journals_for_messages[j].user.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=homework.journals_for_messages[j].notes!></div>
<div class="post-reply-date fl"><!=homework.journals_for_messages[j].lasted_comment!></div>
<div class="post-reply-user hidden"><!=discussion.message_children[j].user.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=discussion.message_children[j].content!></div>
<div class="post-reply-date fl"><!=discussion.message_children[j].lasted_comment!></div>
<div class="post-reply-trigger fr undis">回复</div>
</div>
<div class="cl"></div>
</div>
</div>
<! } !>
</div>
<div class="post-input-wrap">
<div class="post-reply-row">
<!--<div class="post-reply-avatar fl" id = "100"><img src="images/post-avatar.jpg" width="30" height="30" /></div>-->
<!--<div class="post-reply-avatar fl"><img src="images/post-avatar.jpg" width="30" height="30" /></div>-->
<input type="text" class="post-reply-input" id="postInput" />
<input type="submit" value="回复" class="post-reply-submit fr mt10" onclick="replyInsert()" />
<input type="submit" value="回复" class="post-reply-submit fr mt10" />
<div class="cl"></div>
</div>
</div>
@ -64,10 +65,25 @@
</div>
</script>
<script id="t:homework-detail-reply" type="text/html">
<div class="post-reply-wrap border-bottom">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="<!=reply.user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden"><!=reply.user.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=reply.notes!></div>
<div class="post-reply-date fl"><!=reply.lasted_comment!></div>
</div>
<div class="cl"></div>
</div>
</div>
</script>
<script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/baiduTemplate.js"></script>
<script src="/javascripts/wechat/project_discussion.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
<script src="/javascripts/wechat/homework-detail.js"></script>
<script src="/javascripts/wechat/homework_detail.js"></script>
</body>
</html>

View File

@ -2,11 +2,15 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']);
var apiUrl = 'http://wechat.trustie.net/api/v1/';
var debug = true; //调试标志,如果在本地请置为true
if(debug===true){
apiUrl = 'http://localhost:3000/api/v1/';
}
app.factory('auth', function($http,$routeParams, $cookies, $q){
var _openid = '';
if(debug===true){
_openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg";
_openid = "2";
}
var getOpenId = function() {
@ -43,6 +47,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){
return {getOpenId: getOpenId, openid: openid};
});
app.factory('rms', function(){
var _saveStorage = {};
var save = function(key, value){
@ -88,7 +93,6 @@ app.controller('ActivityController',function($scope, $http, auth, rms){
$scope.loadActData = loadActData;
});
app.controller('IssueController', function($scope, $http, $routeParams, auth){
@ -133,8 +137,94 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth){
}, function errorCallback(response) {
});
}
});
app.controller('HomeworkController', function($scope, $http, $routeParams, auth){
$scope.formData = {comment: ''};
var loadData = function(id){
$http({
method: 'GET',
url: apiUrl+ "whomeworks/"+id,
}).then(function successCallback(response) {
console.log(response.data);
$scope.homework = response.data.data;
}, function errorCallback(response) {
});
}
loadData($routeParams.id);
$scope.addIssueReply = function(data){
console.log(data.comment);
if(!data.comment || data.comment.length<=0){
return;
}
var userInfo = {
type: "HomeworkCommon",
content: data.comment,
openid: auth.openid(),
};
$http({
method: 'POST',
url: apiUrl+ "new_comment/"+$routeParams.id,
data: userInfo,
}).then(function successCallback(response) {
alert("提交成功");
$scope.formData = {comment: ''};
loadData($routeParams.id);
}, function errorCallback(response) {
});
}
});
app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth){
$scope.formData = {comment: ''};
var loadData = function(id){
$http({
method: 'GET',
url: apiUrl+ "newss/"+id,
}).then(function successCallback(response) {
console.log(response.data);
$scope.news = response.data.data;
}, function errorCallback(response) {
});
}
loadData($routeParams.id);
$scope.addIssueReply = function(data){
console.log(data.comment);
if(!data.comment || data.comment.length<=0){
return;
}
var userInfo = {
type: "News",
content: data.comment,
openid: auth.openid(),
};
$http({
method: 'POST',
url: apiUrl+ "new_comment/"+$routeParams.id,
data: userInfo,
}).then(function successCallback(response) {
alert("提交成功");
$scope.formData = {comment: ''};
loadData($routeParams.id);
}, function errorCallback(response) {
});
}
});
app.filter('safeHtml', function ($sce) {
@ -153,6 +243,14 @@ app.config(['$routeProvider',function ($routeProvider) {
templateUrl: 'issue_detail.html',
controller: 'IssueController'
})
.when('/homework/:id', {
templateUrl: 'homework_detail.html',
controller: 'HomeworkController'
})
.when('/course_notice/:id', {
templateUrl: 'course_notice.html',
controller: 'CourseNoticeController'
})
.otherwise({
redirectTo: '/activities'
});

View File

@ -1,3 +1,105 @@
/**
* Created by root on 4/1/16.
*/
/**
* Created by root on 4/1/16.
*/
$(document).ready(function(){
var bt=baidu.template;
bt.LEFT_DELIMITER='<!';
bt.RIGHT_DELIMITER='!>';
var apiUrl = '/api/v1/';
var setReplyTemplate = function(data){
console.log(data);
var html=bt('t:homework-detail-reply',{reply: data});
$('#all_homework_reply').prepend(html);
};
var setTemplate = function(data){
console.log(data);
var html=bt('t:project-discussion',{discussion: data});
$('#p-discussion-container').prepend(html);
$('.post-reply-submit').click(function(){
replyInsert();
});
/*$('post-interactive-praise').click(function(){
praiseClick();
});*/
};
var loadDataFromServer = function(id){
//getOpenId(function(openid){
$.ajax({
url: apiUrl + 'messages/' + id,
dataType: 'json',
success: function(data){
setTemplate(data.data);
},
error: function(xhr,status,err){
console.log(err);
}
});
//})
};
var homeworkUrl = window.location.search;
var homeworkID = homeworkUrl.split("=")[1];
loadDataFromServer(homeworkID);
//点击回复按钮,插入回复内容
var replyInsert = function(){
var replyContent = $("#postInput").val();
if (!replyContent){
alert("请输入回复");
}else{
/*//将用户输入内容插入最后一条回复
$(".post-reply-wrap:last").after('<div class="post-reply-wrap border-bottom"><div class="post-reply-row"><div class="post-reply-avatar fl"><img src="images/post-avatar.jpg" width="45" height="45" /></div><div class="ml55"><div class="post-reply-user hidden">Mrs. Ashford</div><div class="post-reply-content c-grey2 mb10"></div><div class="post-reply-date fl"></div><div class="post-reply-trigger fr undis">回复</div></div><div class="cl"></div></div> </div>');
$(".post-reply-content:last").append(replyContent);
$(".post-reply-date:last").append(Date());*/
var postInput = $("#postInput").val();
$("#postInput").val("");
//回复数目+1
var replyNum = $(".post-interactive-reply").text().match(/\d+/g);
replyNum++;
$(".reply-num").text("(" + replyNum + ")");
//获取并传送回复用户数据
var userInfo = {
"type" : "Message",
"content" : postInput
};
$.ajax({
type: "POST", //提交方式
dataType: "json", //类型
url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名
data: userInfo, //参数如果没有可以为null
success: function (data) { //如果执行成功,那么执行此方法
setReplyTemplate(data.data); //用data.d来获取后台传过来的json语句或者是单纯的语句
},
error: function (err) { //如果执行不成功,那么执行此方法
alert("err:" + err);
}
});
}
}
//点赞效果
/*var praiseClick = function(){
var praiseNum = $(".post-interactive-praise").text().match(/\d+/g);
praiseNum++;
$(".praise-num").text("(" + praiseNum + ")");
}*/
});