项目问答详情页面

This commit is contained in:
txz 2016-04-05 10:30:25 +08:00
parent 4dbc619fc5
commit 8c7de04dbf
4 changed files with 138 additions and 22 deletions

View File

@ -148,7 +148,7 @@
<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"><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>

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="" />
@ -19,13 +19,12 @@
<!-- 模板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>

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,9 +65,23 @@
</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/homework-detail.js"></script>
<script src="/javascripts/wechat/project_discussion.js"></script>
<script src="/javascripts/wechat/auth.js"></script>
</body>

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 + ")");
}*/
});