微信动态筛选

This commit is contained in:
Tim 2016-03-28 14:45:11 +08:00
parent 43de1a21b1
commit a9fd79ec63
2 changed files with 249 additions and 19 deletions

View File

@ -0,0 +1,220 @@
<!DOCTYPE html>
<html>
<head>
<title>react js</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="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 = "course"; var act_type = "homework"; !>
<! if (container_type == "course") { !>
<! if (act_type == "homework") { !>
<!--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">我的私有课程&nbsp;&nbsp;|&nbsp;&nbsp;课程作业</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">迟交扣分10分</span> 匿评开启时间2016-03-14 00:00<br />
<span class="mr15">缺评扣分5分/作品</span> 匿评关闭时间2016-03-21 23:59</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].created_on!></span>
<div class="cl"></div>
</div>
<div class="post-interactive">
<div class="post-interactive-column c-grey2">回复<!=activities[i].reply_num!></div>
<div class="post-interactive-column c-grey2"><!=activities[i].praise_num!></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">我的私有课程&nbsp;&nbsp;|&nbsp;&nbsp;课程讨论区</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].created_on!></span>
<div class="cl"></div>
</div>
<div class="post-interactive">
<div class="post-interactive-column c-grey2">回复</div>
<div class="post-interactive-column c-grey2"></div>
</div>
</div>
</div>
<! } else if (act_type == "messge") { !>
<!--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 fl mb10 hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a> <span style="vertical-align:top;">给您留言了</span><br />
<span class="c-grey"><!=activities[i].created_on!></span> </div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<p class="post-all-content"><!:=activities[i].description!></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">回复</div>
<div class="post-interactive-column c-grey2"></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 f15 fb"><!=activities[i].author.nickname!></span>创建了<span class="c-grey3 f15 fb">我的私有课程 | 课程</span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].created_on!></a></div>
<div class="cl"></div>
</div>
</div>
</div>
<! } !>
<! } else if (container_type == "project") { !>
<! if (act_type == "activities") { !>
<!-- 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</div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<div class="post-all-content"><!:=activities[i].description!><br />
<span class="mr15">指派给:黄井泉</span> <span class="mr15">状态:新增</span> <span class="mr15">完成度30%</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"><!=activities[i].created_on!></span>
<div class="cl"></div>
</div>
<div class="post-interactive">
<div class="post-interactive-column c-grey2">回复</div>
<div class="post-interactive-column c-grey2"></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">我的私有课程&nbsp;&nbsp;|&nbsp;&nbsp;课程讨论区</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].created_on!></span>
<div class="cl"></div>
</div>
<div class="post-interactive">
<div class="post-interactive-column c-grey2">回复</div>
<div class="post-interactive-column c-grey2"></div>
</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">我的私有课程 | 课程</span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].created_on!></a></div>
<div class="cl"></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 fl mb10 hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a> <span style="vertical-align:top;">给您留言了</span><br />
<span class="c-grey"><!=activities[i].created_on!></span> </div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<p class="post-all-content"><!:=activities[i].description!></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">回复</div>
<div class="post-interactive-column c-grey2"></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].created_on!></span>
<div class="cl"></div>
</div>
<div class="post-interactive">
<div class="post-interactive-column c-grey2">回复</div>
<div class="post-interactive-column c-grey2"></div>
</div>
</div>
</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>
</body>
</html>

View File

@ -15,11 +15,13 @@ $(document).ready(function(){
var html=bt('t:result-list',{issues: data});
$('#container').prepend(html);
descToggle();
}
var loadDataFromServer = function(id){
var loadDataFromServer = function(page){
$.ajax({
url: apiUrl + 'issues/' + id,
url: apiUrl + 'activities/' + page + "?openid=",
dataType: 'json',
success: function(data){
setTemplate(data.data);
@ -31,24 +33,32 @@ $(document).ready(function(){
};
loadDataFromServer(299);
loadDataFromServer(0);
var descToggle = function(){
var postWidth = $(".post-wrapper").width();
var titleWidth = postWidth - 80;
$(".post-title").css("maxWidth",titleWidth);
$(".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);
});
}
});
}
var timeSpilt = function(){
}
var postWidth = $(".post-wrapper").width();
var titleWidth = postWidth - 80;
$(".post-title").css("maxWidth",titleWidth);
$(".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);
});
}
});
});