commit
48e26fce62
@ -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>
|
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
@ -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'
|
||||||
|
});
|
||||||
|
}]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -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
@ -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"));
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
Loading…
Reference in new issue