wechat init

This commit is contained in:
Tim 2016-03-26 14:45:57 +08:00
parent aaa2a0dea7
commit 4f7d698076
4 changed files with 156 additions and 27 deletions

View File

@ -1,13 +1,20 @@
button:
-
type: "click"
type: "view"
name: "最新动态"
key: "MY_NEWS"
url: "http://wechat.trustie.net/assets/wechat/issue.html"
-
type: "click"
name: "意见返馈"
key: "FEEDBACK"
-
type: "view"
name: "进入网站"
url: "http://www.trustie.net/"
name: "更多"
sub_button:
-
type: "view"
name: "进入网站"
url: "http://www.trustie.net/"
-
type: "view"
name: "使用手册"
url: "https://www.trustie.net/organizations/1/downloads"

View File

@ -0,0 +1,52 @@
<!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 <issues.length; ++i){ !>
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl"><img src="<!=issues[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=issues[i].subject!></span></div>
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=issues[i].author.nickname!></a>项目问题</div>
<div class="cl"></div>
<div class="post-content c-grey2 mt10">
<div class="post-all-content"><!=issues[i].description!></div>
</div>
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more " style="text-decoration:underline">点击展开</a>
<div class="cl"></div>
<span class="c-grey f13 mt10 fl"><!=issues[i].created_on!></span>
<div class="cl"></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

@ -0,0 +1,54 @@
/**
* 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 setTemplate = function(data){
console.log(data);
var html=bt('t:result-list',{issues: data});
$('#container').prepend(html);
}
var loadDataFromServer = function(id){
$.ajax({
url: apiUrl + 'issues/' + id,
dataType: 'json',
success: function(data){
setTemplate(data.data);
},
error: function(xhr,status,err){
console.log(err);
}
})
};
loadDataFromServer(299);
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);
});
}
});
});

View File

@ -10,6 +10,8 @@ var Index = React.createClass({
var apiUrl = '/api/v1/';
var converter = new Showdown.converter();
var PostContainer = React.createClass({
loadDataFromServer: function(){
$.ajax({
@ -31,36 +33,52 @@ var PostContainer = React.createClass({
},
render: function(){
return (
<div className="post-container">
<div className="post-wrapper">
<PostView data={this.state.data}/>
</div>
</div>
)
<PostView data={this.state.data}/>
)issues
}
});
var PostView = React.createClass({
testClick: function(){
console.log("123123");
},
render: function(){
if(!this.props.data){
return <div></div>
}
return (
<div className="post-main">
<div className="post-avatar fl"><img src={this.props.data.author.img_url} width="45" height="45" className="border-radius" /></div>
<div className="post-title hidden mb5"><span className="c-grey3 f15 fb">{this.props.data.subject}</span></div>
<div className="post-title hidden"><a herf="javascript:void(0);" className="mr10">{this.props.data.author.nickname}</a>项目问题</div>
<div className="cl"></div>
<div className="post-content c-grey2 mt10">
<p className="post-all-content">{this.props.data.description}</p>
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>
<a herf="javascript:void(0);" className="link-blue f13 fl mt5 post-more undis" style={{textDecoration: 'underline'}}>点击展开</a>
<div className="cl"></div>
<span className="c-grey f13 mt10 fl">{this.props.data.time}</span>
<div className="cl"></div>
</div>
)
)
});
return(
<div>{issueEach}</div>
);
}
});
@ -77,5 +95,3 @@ var routes = (
React.render(routes, document.getElementById("container"));