冲突解决

This commit is contained in:
txz 2016-04-05 10:43:51 +08:00
commit 48e26fce62
30 changed files with 558 additions and 41098 deletions

View File

@ -9,10 +9,10 @@ module Mobile
params do
requires :page, type: Integer
requires :openid, type: String
end
get ':id' do
#uw = UserWechat.find params[:openid]
user = User.find params[:id]
post do
user = UserWechat.find_by_openid(params[:openid]).user
shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
page = params[:page] ? params[:page] : 0

View File

@ -11,11 +11,12 @@ module Mobile
params do
requires :type, type: String
requires :content, type: String
requires :openid, type: String
end
post ':id' do
type = params[:type]
result = 1
current_user = User.find 8686
current_user = UserWechat.find_by_openid(params[:openid]).user
if params[:content]!="" && current_user
case type
when "HomeworkCommon"
@ -35,6 +36,8 @@ 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
@ -50,6 +53,8 @@ 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

View File

@ -9,7 +9,7 @@ module Mobile
elsif f.is_a?(::Comment)
if f.respond_to?(field)
if field == :created_on
format_time(f.send(field))
time_from_now(f.send(field))
else
f.send(field)
end

View File

@ -175,18 +175,18 @@ class WechatsController < ActionController::Base
def get_open_id
begin
raise "非法操作, code不存在" unless params[:code]
openid = get_openid(params[:code])
openid = get_openid_from_code(params[:code])
raise "无法获取到openid" unless openid
render :text => {status:0, openid: openid}.to_json
render :json => {status:0, openid: openid}
rescue Exception=>e
render :text => {status: -1, msg: e.message}.to_json
render :json => {status: -1, msg: e.message}
end
end
def bind
begin
raise "非法操作, code不存在" unless params[:code]
openid = get_openid(params[:code])
openid = get_openid_from_code(params[:code])
raise "无法获取到openid" unless openid
raise "此微信号已绑定用户, 不能得复绑定" if user_binded?(openid)
@ -200,9 +200,9 @@ class WechatsController < ActionController::Base
openid: openid,
user: user
)
render :text => {status:0, msg: "绑定成功"}.to_json
render :json => {status:0, msg: "绑定成功"}
rescue Exception=>e
render :text => {status: -1, msg: e.message}.to_json
render :json => {status: -1, msg: e.message}
end
end
@ -212,12 +212,14 @@ class WechatsController < ActionController::Base
end
private
def get_openid(code)
def get_openid_from_code(code)
url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{Wechat.config.appid}&secret=#{Wechat.config.secret}&code=#{code}&grant_type=authorization_code"
JSON.parse(URI.parse(url).read)["openid"]
logger.debug url
body = URI.parse(url).read
logger.debug body
JSON.parse(body)["openid"]
end
def user_binded?(openid)
uw = UserWechat.where(openid: openid).first
end

View File

@ -1165,7 +1165,7 @@ RedmineApp::Application.routes.draw do
collection do
get :login
post :bind
get :get_open_id
post :get_open_id
end
end

View File

@ -1,146 +1,145 @@
<!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" />
<div id="container">
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" />
</head>
<body>
<div id="container"></div>
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:result-list" type="text/html">
<! for(var i =0; i < activities.length; ++i){ !>
<! var container_type = activities[i].container_type; var act_type = activities[i].act_type; !>
<! if (container_type == "Course") { !>
<! if (act_type == "HomeworkCommon") { !>
<!--homework -->
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10"><!=activities[i].course_project_name!>&nbsp;&nbsp;|&nbsp;&nbsp;<!=activities[i].activity_type_name!></a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<div class="post-all-content"><!:=activities[i].description!><br />
<span class="mr15">迟交扣分:<!:=activities[i].homework_common_detail.late_penalty!></span> 匿评开启时间:<!:=activities[i].homework_common_detail.evaluation_start!><br />
<span class="mr15">缺评扣分:<!:=activities[i].homework_common_detail.absence_penalty!>分/作品</span> 匿评关闭时间:<!:=activities[i].homework_common_detail.evaluation_end!></div>
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<div ng-repeat="act in activities">
<div ng-if="act.container_type=='Course'">
<div ng-if="act.act_type=='HomeworkCommon'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb">{{act.subject|safeHtml}}</span></div>
<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>
<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">{{act.latest_update}}</span>
<div class="cl"></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('homework_detail.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>
<! } else if (act_type == "News") { !>
<!-- course news -->
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10"><!=activities[i].course_project_name!>&nbsp;&nbsp;|&nbsp;&nbsp;<!=activities[i].activity_type_name!></a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<div class="post-all-content"><!:=activities[i].description!></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">赞 ({{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('course_notice.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>
<! } else if (act_type == "Message") { !>
<!--course message -->
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="images/post-avatar.jpg" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
<div class="post-title fl mb10 hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10"><!=activities[i].course_project_name!>&nbsp;&nbsp;|&nbsp;&nbsp;<!=activities[i].activity_type_name!></a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<p class="post-all-content"><!:=activities[i].description!></p>
<div ng-if="act.act_type=='News'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb">{{act.subject|safeHtml}}</span></div>
<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"></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">{{act.latest_update}}</span>
<div class="cl"></div>
</div>
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline;">点击展开</a>
<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('course_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>
<! } else if (act_type == "Course") { !>
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f13 fb mr10"><!=activities[i].author.nickname!></span>创建了<span class="c-grey3 f13 fb ml10"><!=activities[i].course_project_name!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].latest_update!></a></div>
<div class="cl"></div>
</div>
</div>
</div>
<! } !>
<! } else if (container_type == "Project") { !>
<! if (act_type == "Issue") { !>
<!-- activities -->
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10"><!=activities[i].course_project_name!>&nbsp;&nbsp;|&nbsp;&nbsp;<!=activities[i].activity_type_name!></a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<div class="post-all-content"><!:=activities[i].description!><br />
<span class="mr15">状态:<!:=activities[i].issue_detail.issue_status!></span> <span class="mr15">优先级:<!:=activities[i].issue_detail.issue_priority!></span> <br /> <span class="mr15">指派给:<!:=activities[i].issue_detail.issue_assigned_to!></span> <span class="mr15">完成度:<!:=activities[i].issue_detail.done_ratio!>%</span></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">赞 ({{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('issue_detail.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>
<! } else if (act_type == "Message") { !>
<!-- project news -->
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10"><!=activities[i].course_project_name!>&nbsp;&nbsp;|&nbsp;&nbsp;<!=activities[i].activity_type_name!></a></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<div class="post-all-content"><!:=activities[i].description!></div>
<div ng-if="act.act_type=='Message'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="/images/post-avatar.jpg" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb">{{act.subject|safeHtml}}</span></div>
<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>
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline;">点击展开</a>
<span class="c-grey f13 mt10 fl">{{act.latest_update}}</span>
<div class="cl"></div>
</div>
<div class="post-interactive">
<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>
</div>
</div>
</div>
<div ng-if="act.act_type=='Course'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f13 fb mr10">{{act.author.nickname}}</span>创建了<span class="c-grey3 f13 fb ml10">{{act.course_project_name}}</span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10">{{act.latest_update}}</a></div>
<div class="cl"></div>
</div>
</div>
</div>
</div>
</div>
<div ng-if="act.container_type=='Project'">
<div ng-if="act.act_type=='Issue'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb">{{act.subject|safeHtml}}</span></div>
<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>
<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">{{act.latest_update}}</span>
<div class="cl"></div>
</div>
<div class="post-interactive">
<div class="post-interactive-column c-grey2"><a href="javascript:void(0);" ng-href="#/issues/{{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>
</div>
</div>
<div ng-if="act.act_type=='Message'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb">{{act.subject|safeHtml}}</span></div>
<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"></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">{{act.latest_update}}</span>
<div class="cl"></div>
</div>
<div class="post-interactive">
<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>
@ -153,124 +152,74 @@
</div>
</div>
</div>
<! } else if (act_type == "ProjectCreateInfo") { !>
<!-- project created -->
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].author.nickname!></span>创建了<span class="c-grey3 f15 fb"><!=activities[i].course_project_name!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].latest_update!></a></div>
<div class="cl"></div>
<div ng-if="act.act_type=='ProjectCreateInfo'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb">{{act.author.nickname}}</span>创建了<span class="c-grey3 f15 fb">{{act.course_project_name}}</span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10">{{act.latest_update}}</a></div>
<div class="cl"></div>
</div>
</div>
</div>
</div>
<! } !>
<! } else if (container_type == "Principal") { !>
<!--留言 -->
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="images/post-avatar.jpg" width="45" height="45" class="border-radius" /></div>
<div class="post-title mb5 hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a> <span style="vertical-align:top;">给您留言了</span></div>
<div class="post-title hidden"><!=activities[i].latest_update!></div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<p class="post-all-content"><!:=activities[i].description!></p>
<div ng-if="act.act_type=='Principal'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="images/post-avatar.jpg" width="45" height="45" class="border-radius" /></div>
<div class="post-title mb5 hidden"><a herf="javascript:void(0);" class="mr10">{{act.author.nickname}}</a> <span style="vertical-align:top;">给您留言了</span></div>
<div class="post-title hidden">{{act.latest_update}}</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>
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline;">点击展开</a>
<div class="cl"></div>
</div>
<div class="post-interactive">
<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>
</div>
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline;">点击展开</a>
<div class="cl"></div>
</div>
<div class="post-interactive">
<div class="post-interactive-column c-grey2"><a href="javascript:void(0);" <!--onclick="window.open('message_detail.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 ng-if="act.act_type=='Blog'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb">{{act.subject|safeHtml}}</span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10">{{act.author.nickname}}</a>发表博客</div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<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>
<div class="cl"></div>
<span class="c-grey f13 mt10 fl">{{act.latest_update}}</span>
<div class="cl"></div>
</div>
<div class="post-interactive">
<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>
</div>
</div>
</div>
</div>
<! } else if (container_type == "Blog") { !>
<!--blog -->
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>发表博客</div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<div class="post-all-content"><!:=activities[i].description!></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('blog_detail.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>
<! } !>
<! } !>
<! if ((count + page * 10) < all_count) {!>
<div id="more_activities" class="more-events mt10" onclick="loadDataFromServer(8686, <!= page+1 !>);">更多</div>
<! } !>
</script>
<script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/baiduTemplate.js"></script>
<script src="/javascripts/wechat/wechat_dev.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
<script type="text/javascript">
var bt=baidu.template;
bt.LEFT_DELIMITER='<!';
bt.RIGHT_DELIMITER='!>';
</div>
var apiUrl = '/api/v1/';
var loadDataFromServer = function(id, page){
//getOpenId(function(openid){
$.ajax({
url: apiUrl + 'activities/' + id +"?page=" + parseInt(page),
dataType: 'json',
success: function(data){
setTemplate(data.data, data.all_count, data.count, data.page);
},
error: function(xhr,status,err){
console.log(err);
}
});
//})
<div id="more_activities" class="more-events mt10" ng-click="loadActData(page+1);">更多</div>
};
var setTemplate = function(data, all_count, count, page){
console.log(data);
var html=bt('t:result-list',{activities: data, all_count: all_count, count: count, page: page});
if (page == 0) {
$('#container').prepend(html);
} else {
$("#more_activities").remove();
$('#container').append(html);
}
descToggle();
};
//内容全部显示与部分隐藏
var descToggle = function(){
$(".post-all-content").each(function(){
var postHeight = $(this).height();
if (postHeight > 90){
$(this).parent().next().css("display","block");
$(this).parent().next().toggle(function(){
$(this).text("点击隐藏");
$(this).prev().css("height",postHeight);
},function(){
$(this).text("点击展开");
$(this).prev().css("height",90);
});
}
});
}
</div>
</script>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html ng-app="wechat">
<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 ng-view></div>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.js"></script>
<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="/javascripts/wechat/app.js"></script>
</body>
</html>

View File

@ -66,8 +66,8 @@
<script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/baiduTemplate.js"></script>
<script src="/javascripts/wechat/blog_detail.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
<script src="/javascripts/wechat/blog_detail.js"></script>
</body>
</html>

View File

@ -35,9 +35,10 @@
</div>
<div class="post-interactive border-bottom">
<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 class="post-interactive-praise c-grey2"><span class="paise-text"></span><span class="praise-num">((<!=discussion.message_praise_count!>))</span></div>
</div>
<! for(var j =0; j < discussion.message_children.length; ++j){ !>
<div id="all_course_message_reply">
<! for(var j = (discussion.message_children.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="<!=discussion.message_children[j].user.img_url!>" width="45" height="45" class="border-radius" /></div>
@ -51,11 +52,12 @@
</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()" />
<input type="submit" value="回复" class="post-reply-submit fr mt10"/>
<div class="cl"></div>
</div>
</div>
@ -63,10 +65,24 @@
</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/course_discussion.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
<script src="/javascripts/wechat/course_discussion.js"></script>
</body>
</html>

View File

@ -36,14 +36,15 @@
</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">1</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>
<! for(var j =0; j < course.comments.length; ++j){ !>
<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-row">
<div class="post-reply-avatar fl"><img src="<!=course.comments[j].user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-reply-avatar fl"><img src="<!=course.comments[j].author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden"><!=course.comments[j].user.realname!></div>
<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-trigger fr undis">回复</div>
@ -52,11 +53,12 @@
</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()" />
<input type="submit" value="回复" class="post-reply-submit fr mt10" />
<div class="cl"></div>
</div>
</div>
@ -64,10 +66,26 @@
</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/course_notice.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
<script src="/javascripts/wechat/course_notice.js"></script>
</body>
</html>

View File

@ -83,8 +83,8 @@
<script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/baiduTemplate.js"></script>
<script src="/javascripts/wechat/homework_detail.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
<script src="/javascripts/wechat/homework_detail.js"></script>
</body>
</html>

View File

@ -1,89 +1,60 @@
<!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="issue-container"></div>
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:issue-detail" type="text/html">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=issues.author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=issues.subject!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=issues.author.nickname!></a>to<span class="ml10"><!=issues.project_name!>&nbsp;&nbsp;|&nbsp;&nbsp;项目缺陷</span></div>
<div class="post-avatar fl"><img ng-src="{{issue.author.img_url}}" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb">{{issue.subject}}</span></div>
<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"><!:=issues.description!><br />
<span class="mr15">状态:<!:=issues.issue_status!></span> <span class="mr15">优先级:<!:=issues.issue_priority!></span> <br /> <span class="mr15">指派给:<!:=issues.issue_assigned_to!></span> <span class="mr15">完成度:<!:=issues.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"><!=issues.created_on!></span>
<span class="c-grey f13 mt10 fl">{{issue.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">(<!=issues.journals_count!>)</span></div>
<div class="post-interactive-praise c-grey2"><span class="paise-text"></span> <span class="praise-num">(<!=issues.issue_praise_count!>)</span></div>
<div class="post-interactive-reply c-grey2">回复 <span class="reply-num">({{issue.journals_count}})</span></div>
<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">
<! for(var j = (issues.issue_journals.length -1); j >= 0; --j){ !>
<div class="post-reply-wrap border-bottom">
<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 src="<!=issues.issue_journals[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"><!=issues.issue_journals[j].user.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=issues.issue_journals[j].notes!></div>
<div class="post-reply-date fl"><!=issues.issue_journals[j].created_on!></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.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"><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)" class="post-reply-submit fr mt10">回复</button>
<div class="cl"></div>
</div>
</div>
</div>
</div>
</script>
<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="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 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>
<script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/baiduTemplate.js"></script>
<script src="/javascripts/wechat/issue_detail.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
</body>
</html>

View File

@ -64,8 +64,8 @@
<script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/baiduTemplate.js"></script>
<script src="/javascripts/wechat/message_detail.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
<script src="/javascripts/wechat/message_detail.js"></script>
</body>
</html>

View File

@ -83,6 +83,7 @@
<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>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,131 @@
var app = angular.module('wechat', ['ngRoute']);
var apiUrl = 'http://wechat.trustie.net/api/v1/';
//var openid= "oCnvgvz8R7QheXE-R9Kkr39j8Ndg";
var openid = '';
app.factory('auth', function($http,$routeParams){
var _openid = '';
var getOpenId = function(cb) {
if (_openid.length > 0) {
cb(_openid);
}
var code = $routeParams.code;
$http({
url: '/wechat/get_open_id',
data: {code: code},
method: 'POST'
}).then(function successCallback(response) {
_openid = data.openid;
cb(_openid);
}, function errorCallback(response) {
cb(null);
});
};
var setOpenId = function(id){
_openid = id;
}
return {getOpenId: getOpenId, setOpenId: setOpenId};
});
app.controller('ActivityController',function($scope, $http, auth){
$scope.repaceUrl = function(url){
return "http://www.trustie.net/" + url;
}
$scope.activities = [];
$scope.page = 1;
auth.getOpenId(function(openid){
if(!openid){
alert("获取openid出错");
} else {
openid = openid;
$scope.loadActData($scope.page);
}
});
$scope.loadActData = function(page){
$scope.page = page;
$http({
method: 'POST',
url: apiUrl+ "activities",
data: {openid: openid, page: page},
}).then(function successCallback(response) {
$scope.activities = $scope.activities.concat(response.data.data);
}, function errorCallback(response) {
});
}
});
app.controller('IssueController', function($scope, $http, $routeParams, auth){
$scope.formData = {comment: ''};
var loadData = function(id){
$http({
method: 'GET',
url: apiUrl+ "issues/"+id,
}).then(function successCallback(response) {
console.log(response.data);
$scope.issue = 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: "Issue",
content: data.comment,
openid: 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) {
});
}
console.log(auth.getOpenId());
});
app.filter('safeHtml', function ($sce) {
return function (input) {
return $sce.trustAsHtml(input);
}
});
app.config(['$routeProvider',function ($routeProvider) {
$routeProvider
.when('/activities', {
templateUrl: 'activities.html',
controller: 'ActivityController'
})
.when('/issues/:id', {
templateUrl: 'issue_detail.html',
controller: 'IssueController'
})
.otherwise({
redirectTo: '/activities'
});
}]);

View File

@ -20,8 +20,9 @@ $(function(){
}
var code = getUrlParam("code");
$.ajax({
url: '/wechat/get_open_id?code='+code,
type: 'get',
url: '/wechat/get_open_id',
data: {code: code},
type: 'post',
dataType: 'json',
success: function(data){
g_openid = data.openid;

File diff suppressed because one or more lines are too long

View File

@ -10,6 +10,12 @@ $(document).ready(function(){
var apiUrl = '/api/v1/';
var setReplyTemplate = function(data){
console.log(data);
var html=bt('t:c-message-detail-reply',{reply: data});
$('#all_course_message_reply').prepend(html);
};
var setTemplate = function(data){
console.log(data);
var html=bt('t:course-discussion',{discussion: data});
@ -17,9 +23,9 @@ $(document).ready(function(){
$('.post-reply-submit').click(function(){
replyInsert();
});
$('post-interactive-praise').click(function(){
/*$('post-interactive-praise').click(function(){
praiseClick();
});
});*/
};
var loadDataFromServer = function(id){
@ -52,9 +58,9 @@ $(document).ready(function(){
}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-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());
$(".post-reply-date:last").append(Date());*/
var postInput = $("#postInput").val();
$("#postInput").val("");
//回复数目+1
@ -71,10 +77,11 @@ $(document).ready(function(){
$.ajax({
type: "POST", //提交方式
dataType: "json", //类型
url: "前台地址/后台方法", //提交的页面,方法名
url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名
data: userInfo, //参数如果没有可以为null
success: function (data) { //如果执行成功,那么执行此方法
alert(data.d); //用data.d来获取后台传过来的json语句或者是单纯的语句
setReplyTemplate(data.data);
alert("6");
},
error: function (err) { //如果执行不成功,那么执行此方法
alert("err:" + err);
@ -84,12 +91,12 @@ $(document).ready(function(){
}
//点赞效果
/*//点赞效果
var praiseClick = function(){
var praiseNum = $(".post-interactive-praise").text().match(/\d+/g);
praiseNum++;
$(".praise-num").text("(" + praiseNum + ")");
}
}*/
});

View File

@ -10,6 +10,12 @@ $(document).ready(function(){
var apiUrl = '/api/v1/';
var setReplyTemplate = function(data){
console.log(data);
var html=bt('t:news-detail-reply',{reply: data});
$('#all_news_reply').prepend(html);
};
var setTemplate = function(data){
console.log(data);
var html=bt('t:course-notice',{course: data});
@ -17,9 +23,9 @@ $(document).ready(function(){
$('.post-reply-submit').click(function(){
replyInsert();
});
$('post-interactive-praise').click(function(){
/*$('post-interactive-praise').click(function(){
praiseClick();
});
});*/
};
var loadDataFromServer = function(id){
@ -52,9 +58,9 @@ $(document).ready(function(){
}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-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());
$(".post-reply-date:last").append(Date());*/
var postInput = $("#postInput").val();
$("#postInput").val("");
//回复数目+1
@ -64,17 +70,17 @@ $(document).ready(function(){
//获取并传送回复用户数据
var userInfo = {
"replyType" : "homework_assignment",
"replyContent" : postInput
"type" : "News",
"content" : postInput
};
$.ajax({
type: "POST", //提交方式
dataType: "json", //类型
url: "前台地址/后台方法", //提交的页面,方法名
url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名
data: userInfo, //参数如果没有可以为null
success: function (data) { //如果执行成功,那么执行此方法
alert(data.d); //用data.d来获取后台传过来的json语句或者是单纯的语句
setReplyTemplate(data.data);
},
error: function (err) { //如果执行不成功,那么执行此方法
alert("err:" + err);

View File

@ -68,23 +68,26 @@ $(document).ready(function(){
replyNum++;
$(".reply-num").text("(" + replyNum + ")");
//获取并传送回复用户数据
var userInfo = {
"type" : "HomeworkCommon",
"content" : postInput
};
getOpenId(function(openid) {
//获取并传送回复用户数据
var userInfo = {
"type": "HomeworkCommon",
"content": postInput,
openid: openid
};
$.ajax({
type: "POST", //提交方式
dataType: "json", //类型
url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名
data: userInfo, //参数如果没有可以为null
success: function (data) { //如果执行成功,那么执行此方法
setReplyTemplate(data.data);
},
error: function (err) { //如果执行不成功,那么执行此方法
alert("err:" + err);
}
$.ajax({
type: "POST", //提交方式
dataType: "json", //类型
url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名
data: userInfo, //参数如果没有可以为null
success: function (data) { //如果执行成功,那么执行此方法
setReplyTemplate(data.data);
},
error: function (err) { //如果执行不成功,那么执行此方法
alert("err:" + err);
}
})
});
}

View File

@ -72,23 +72,26 @@ $(document).ready(function(){
replyNum++;
$(".reply-num").text("(" + replyNum + ")");
//获取并传送回复用户数据
var userInfo = {
"type" : "Issue",
"content" : postInput
};
getOpenId(function(openid) {
//获取并传送回复用户数据
var userInfo = {
"type": "Issue",
"content": postInput,
openid: openid,
};
$.ajax({
type: "POST", //提交方式
dataType: "json", //类型
url: apiUrl + 'new_comment/' + IssueID, //提交的页面,方法名
data: userInfo, //参数如果没有可以为null
success: function (data) { //如果执行成功,那么执行此方法
setReplyTemplate(data.data);
},
error: function (err) { //如果执行不成功,那么执行此方法
alert("err:" + err);
}
$.ajax({
type: "POST", //提交方式
dataType: "json", //类型
url: apiUrl + 'new_comment/' + IssueID, //提交的页面,方法名
data: userInfo, //参数如果没有可以为null
success: function (data) { //如果执行成功,那么执行此方法
setReplyTemplate(data.data);
},
error: function (err) { //如果执行不成功,那么执行此方法
alert("err:" + err);
}
})
});
}

File diff suppressed because one or more lines are too long

View File

@ -1,42 +0,0 @@
/**
* ReactDOM v0.14.0
*
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
// Based off https://github.com/ForbesLindesay/umd/blob/master/template.js
;(function(f) {
// CommonJS
if (typeof exports === "object" && typeof module !== "undefined") {
module.exports = f(require('react'));
// RequireJS
} else if (typeof define === "function" && define.amd) {
define(['react'], f);
// <script>
} else {
var g
if (typeof window !== "undefined") {
g = window;
} else if (typeof global !== "undefined") {
g = global;
} else if (typeof self !== "undefined") {
g = self;
} else {
// works providing we're not in "use strict";
// needed for Java 8 Nashorn
// see https://github.com/facebook/react/issues/3037
g = this;
}
g.ReactDOM = f(g.React);
}
})(function(React) {
return React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
});

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,97 +0,0 @@
/**
* Created by guange on 16/3/21.
*//*
var Index = React.createClass({
render: function(){
return (<div>index page</div>);
}
});
var apiUrl = '/api/v1/';
var PostContainer = React.createClass({
loadDataFromServer: function(){
$.ajax({
url: apiUrl + 'issues/' + this.props.params.id,
dataType: 'json',
success: function(data){
this.setState({data: data.data});
}.bind(this),
error: function(xhr,status,err){
console.log(err);
}.bind(this)
})
},
componentDidMount: function(){
this.loadDataFromServer();
},
getInitialState: function(){
return {data: null};
},
render: function(){
return (
<PostView data={this.state.data}/>
)
}
});
var PostView = React.createClass({
testClick: function(){
console.log("123123");
},
render: function(){
if(!this.props.data){
return <div></div>
}
var issueEach = this.props.data.map(function(issue){
var descMarkup = converter.makeHtml(issue.description.toString());
return (
<div className="post-container">
<div className="post-wrapper">
<div className="post-main">
<div className="post-avatar fl"><img src={issue.author.img_url} width="45" height="45" className="border-radius" /></div>
<div className="post-title hidden mb5"><span className="c-grey3 f15 fb">{issue.subject}</span></div>
<div className="post-title hidden"><a herf="javascript:void(0);" className="mr10">{issue.author.nickname}</a>项目问题</div>
<div className="cl"></div>
<div className="post-content c-grey2 mt10">
<div className="post-all-content" dangerouslySetInnerHTML={{__html: descMarkup}}></div>
</div>
<a herf="javascript:void(0);" className="link-blue f13 fl mt5 post-more " style={{textDecoration: 'underline'}}>点击展开</a>
<div className="cl"></div>
<span onClick={this.testClick} className="c-grey f13 mt10 fl">{issue.created_on}</span>
<div className="cl"></div>
</div>
</div>
</div>
)
});
return(
<div>{issueEach}</div>
);
}
});
var Route = ReactRouter.Route;
var Router = ReactRouter.Router;
var routes = (
<Router>
<Route path="/" component={Index}/>
<Route path="issue/:id" component={PostContainer} />
</Router>
);
React.render(routes, document.getElementById("container"));
*/

View File

@ -2,5 +2,56 @@
* Created by root on 3/25/16.
*/
$(document).ready(function(){
var bt=baidu.template;
bt.LEFT_DELIMITER='<!';
bt.RIGHT_DELIMITER='!>';
var apiUrl = '/api/v1/';
var loadDataFromServer = function(id, page){
getOpenId(function(openid){
$.ajax({
url: apiUrl + 'activities',
data: {openid: openid, page: page},
type: 'POST',
dataType: 'json',
success: function(data){
setTemplate(data.data, data.all_count, data.count, data.page);
},
error: function(xhr,status,err){
console.log(err);
}
});
})
};
var setTemplate = function(data, all_count, count, page){
console.log(data);
var html=bt('t:result-list',{activities: data, all_count: all_count, count: count, page: page});
if (page == 0) {
$('#container').prepend(html);
} else {
$("#more_activities").remove();
$('#container').append(html);
}
descToggle();
};
//内容全部显示与部分隐藏
var descToggle = function(){
$(".post-all-content").each(function(){
var postHeight = $(this).height();
if (postHeight > 90){
$(this).parent().next().css("display","block");
$(this).parent().next().toggle(function(){
$(this).text("点击隐藏");
$(this).prev().css("height",postHeight);
},function(){
$(this).text("点击展开");
$(this).prev().css("height",90);
});
}
});
}
loadDataFromServer(8686, 0);
});