@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var ua = navigator.userAgent.toLowerCase();
|
||||||
|
var isWeixin = ua.indexOf('micromessenger') != -1;
|
||||||
|
var isAndroid = ua.indexOf('android') != -1;
|
||||||
|
var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1);
|
||||||
|
if (!isWeixin) {
|
||||||
|
document.head.innerHTML = '<title>抱歉,出错了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/connect/zh_CN/htmledition/style/wap_err1a9853.css">';
|
||||||
|
document.body.innerHTML = '<div class="page_msg"><div class="inner"><span class="msg_icon_wrp"><i class="icon80_smile"></i></span><div class="msg_content"><h4>请在微信客户端打开链接</h4></div></div></div>';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddInviteCodeToCourse < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :courses, :invite_code, :string
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,6 @@
|
|||||||
|
class AddIndexToInviteCode < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :courses, :qrcode, :string
|
||||||
|
add_index :courses, :invite_code, unique: true
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,13 @@
|
|||||||
|
<div class="post-container">
|
||||||
|
<div class="add-class-box">
|
||||||
|
<p class="tac add-class-tip">输入班级邀请码,即刻加入班级!</p>
|
||||||
|
<form class="mb20">
|
||||||
|
<input type="text" class="class-number-input" />
|
||||||
|
</form>
|
||||||
|
<a href="javascript:void(0);" class="c-grey4 fl cancel-btn">取消</a>
|
||||||
|
<div class="slice fl">
|
||||||
|
<div class="slice-line"></div>
|
||||||
|
</div>
|
||||||
|
<a href="javascript:void(0);" class="c-blue fl submit-btn">确定</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,15 @@
|
|||||||
|
<div class="post-container">
|
||||||
|
<div class="qr-code-wrap">
|
||||||
|
<div class="qr-code-box">
|
||||||
|
<div class="share-class-name">{{course.name}}</div>
|
||||||
|
<div class="qr-img-wrap"><img ng-src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={{course.qrcode}}" width="152" class="qr-code-img" /></div>
|
||||||
|
<div class="invitation-code-wrap">邀请码:{{course.invite_code}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="share-code-wrap">
|
||||||
|
<a ng-click="share()" href="javascript:void(0);" class="share-code-btn">分享邀请码</a>
|
||||||
|
<div class="share-code-instruction"> 1.将此页面分享给好友,邀请好友加入班级<br />
|
||||||
|
2.通过微信扫一扫加入班级<br />
|
||||||
|
3.输入邀请码加入班级</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,25 @@
|
|||||||
|
<div class="post-container">
|
||||||
|
<div loading-spinner></div>
|
||||||
|
|
||||||
|
<form name="loginFrm" novalidate>
|
||||||
|
<div class="blue-title">绑定<span class="f13 blue-title-sub" ng-click="goReg()">注册</span></div>
|
||||||
|
<div class="input-box-wrap login-wrap mt30">
|
||||||
|
<input name="login" ng-model="user.login" required class="input-box f12" placeholder="请输入电子邮箱地址或登录名" />
|
||||||
|
<div ng-show="loginFrm.$submitted || loginFrm.login.$touched">
|
||||||
|
<span ng-show="loginFrm.login.$error.required" class="c-red fl f12">电子邮箱地址或登录名不能为空</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="input-box-wrap login-wrap mt10 mb20">
|
||||||
|
<input class="input-box f12" placeholder="请输入密码" name="password" type="password" ng-model="user.password" required />
|
||||||
|
<div ng-show="loginFrm.$submitted || loginFrm.password.$touched">
|
||||||
|
<span ng-show="loginFrm.password.$error.required" class="c-red fl f12">密码不能为空</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="login-wrap mt5"><a href="javascript:void(0);" ng-class="['btn1', 'bg-blue', 'f18', {'btn-disabled':!loginFrm.$valid} ]" ng-click="login(loginFrm, user)">确定绑定</a></div>
|
||||||
|
<div class="forget-psw-wrap"><a href="javascript:void(0);" class="f12 forget-psw" ng-click="showBox()">忘记密码?</a></div>
|
||||||
|
<my-alert message="findPwdDialog.message" title="findPwdDialog.title" visible="findPwdDialog.visible"></my-alert>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
|
@ -0,0 +1,32 @@
|
|||||||
|
<div class="post-container">
|
||||||
|
<div loading-spinner></div>
|
||||||
|
<div class="class-detail-name">{{course.name}}<span ng-click="invite()" class="f13 blue-title-sub">邀请码</span></div>
|
||||||
|
<div class="slice3 fl"></div>
|
||||||
|
<div id="class_tab_1" ng-class="['class-detail-tab3',{'class-tab-active':currentTab==1}]" ng-click="tab(1);"><a herf="javascript:void(0);">课堂资源</a></div>
|
||||||
|
<div class="slice2 fl">
|
||||||
|
<div class="slice-line2"></div>
|
||||||
|
</div>
|
||||||
|
<div id="class_tab_2" ng-class="['class-detail-tab3',{'class-tab-active':currentTab==2}]" ng-click="tab(2);"><a herf="javascript:void(0);">我的同学</a></div>
|
||||||
|
<div class="slice3 fl"></div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="class-search-wrap">
|
||||||
|
<div class="class-search-inner"> <img src="/images/wechat/search.png" width="18" class="class-search-icon" />
|
||||||
|
<input class="class-detail-search" ng-model="searchText" placeholder="输入关键词进行搜索" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ng-class="{'undis': currentTab!=1}">
|
||||||
|
<div ng-repeat="r in resources|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.filename}}</span></div>
|
||||||
|
</div>
|
||||||
|
<div ng-class="{'undis': currentTab!=2}">
|
||||||
|
<div class="member-banner f13 c-grey3">授课老师</div>
|
||||||
|
|
||||||
|
<div class="class-detail-row f13 c-grey3" ng-repeat="teacher in teachers|filter:searchText">
|
||||||
|
<img ng-src="/images/wechat/{{teacher.gender==0 ? 'male' : 'female'}}.jpg" width="30" class="fl ml10 img-circle mt4" /><span class="fl ml10">{{teacher.name}}</span><span class="fr mr10 c-grey2">{{teacher.role_name|identify}}</span><img ng-src="/images/wechat/{{teacher.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt10" />
|
||||||
|
</div>
|
||||||
|
<div class="member-banner f13 mt10 c-grey3">我的同学</div>
|
||||||
|
<div class="class-detail-row f13 c-grey3" ng-repeat="student in students|filter:searchText">
|
||||||
|
<img ng-src="/images/wechat/{{student.gender==0 ? 'male' : 'female'}}.jpg" width="30" class="fl ml10 img-circle mt4" /><span class="fl ml10">{{student.name}}</span><img ng-src="/images/wechat/{{student.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt10" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,43 @@
|
|||||||
|
<div class="post-container">
|
||||||
|
<form name="regFrm" novalidate>
|
||||||
|
<div class="blue-title">注册<span class="f13 blue-title-sub" ng-click="goLogin()">登录</span></div>
|
||||||
|
<img src="/images/wechat/male.jpg" width="60" class="img-circle mt15 block-center"/>
|
||||||
|
<div class="input-box-wrap login-wrap mt10 mb20">
|
||||||
|
<input class="input-box f12" type="email" ng-model="user.email" name="email" required placeholder="请输入电子邮箱地址"/>
|
||||||
|
<div ng-show="regFrm.$submitted || regFrm.email.$touched">
|
||||||
|
<span class="f12 c-red fl" ng-show="regFrm.email.$error.required">电子邮箱地址不能为空</span>
|
||||||
|
<span class="f12 c-red fl" ng-show="regFrm.email.$error.email">电子邮箱地址不合法</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="input-box-wrap login-wrap mb20">
|
||||||
|
<input class="input-box f12" type="password" ng-model="user.password" name="password" ng-maxlength="20" ng-minlength="8" required placeholder="请输入密码"/>
|
||||||
|
<div ng-show="regFrm.$submitted || regFrm.password.$touched">
|
||||||
|
<span class="f12 c-red fl" ng-show="regFrm.password.$error.required">密码不能为空</span>
|
||||||
|
<span class="f12 c-red fl" ng-show="regFrm.password.$error.minlength">密码长度为8-20位</span>
|
||||||
|
<span class="f12 c-red fl" ng-show="regFrm.password.$error.maxlength">密码长度为8-20位</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="input-box-wrap login-wrap mb20">
|
||||||
|
<input class="input-box f12" type="password" ng-model="user.password_confirm" name="password_confirm" required placeholder="请再次输入密码" pwdconfirm/>
|
||||||
|
<div ng-show="regFrm.$submitted || regFrm.password_confirm.$touched">
|
||||||
|
<span class="f12 c-red fl" ng-show="regFrm.password_confirm.$error.pwdconfirm">两次密码不一致</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="input-box-wrap login-wrap mb20">
|
||||||
|
<input class="input-box f12" required ng-model="user.username" name="username" placeholder="输入用户登录名"/>
|
||||||
|
<div ng-show="regFrm.$submitted || regFrm.username.$touched">
|
||||||
|
<span class="f12 c-red fl" ng-show="regFrm.username.$error.required">用户名不能为空</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="login-op-wrap login-wrap f12 c-grey3">
|
||||||
|
<span ng-class="['login-box', 'mr5',{'checked': isagreed}]"
|
||||||
|
ng-click="agreed(isagreed)"></span>我已阅读并接受<a
|
||||||
|
href="javascript:void(0);" class="link-blue2">Trustie服务协议</a>条款
|
||||||
|
</div>
|
||||||
|
<div class="login-wrap mt5"><a href="javascript:void(0);" ng-class="['btn1', 'bg-blue', 'f18', {'btn-disabled':!regFrm.$valid} ]" ng-click="reg(regFrm, user)">确定注册</a></div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<my-alert message="errDialog.message" title="errDialog.title" visible="errDialog.visible"></my-alert>
|
@ -0,0 +1,12 @@
|
|||||||
|
<!--BEGIN dialog2-->
|
||||||
|
<div class="weui_dialog_alert" id="dialog2" ng-show="visible">
|
||||||
|
<div class="weui_mask"></div>
|
||||||
|
<div class="weui_dialog">
|
||||||
|
<div class="weui_dialog_hd"><strong class="weui_dialog_title">{{title}}</strong></div>
|
||||||
|
<div class="weui_dialog_bd"><span class="weui_dialog_info">{{message}}</span></div>
|
||||||
|
<div class="weui_dialog_ft">
|
||||||
|
<a href="javascript:;" class="weui_btn_dialog primary" ng-click="dismiss()">确定</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--END dialog2-->
|
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 1.9 KiB |
@ -1,108 +0,0 @@
|
|||||||
/**
|
|
||||||
* Created by guange on 16/3/19.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var CommentBox = React.createClass({
|
|
||||||
|
|
||||||
loadFromServer: function(){
|
|
||||||
$.ajax({
|
|
||||||
url: this.props.url,
|
|
||||||
dataType: 'json',
|
|
||||||
success: function(data){
|
|
||||||
this.setState({data: data});
|
|
||||||
}.bind(this),
|
|
||||||
error: function(xhr,status,err){
|
|
||||||
console.error(this.props.url, status, err.toString());
|
|
||||||
}.bind(this)
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onCommentSubmit: function(comment){
|
|
||||||
console.log(comment);
|
|
||||||
},
|
|
||||||
getInitialState: function(){
|
|
||||||
return {data: []};
|
|
||||||
},
|
|
||||||
componentDidMount: function(){
|
|
||||||
this.loadFromServer();
|
|
||||||
setInterval(this.loadFromServer, 2000);
|
|
||||||
},
|
|
||||||
render: function(){
|
|
||||||
return(
|
|
||||||
<div className="commentBox">
|
|
||||||
<CommentForm onCommentSubmit={this.onCommentSubmit}/>
|
|
||||||
<CommentList data={this.state.data}/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var CommentList = React.createClass({
|
|
||||||
render: function(){
|
|
||||||
|
|
||||||
var commentNodes = this.props.data.map(function(comment){
|
|
||||||
return (
|
|
||||||
<Comment author={comment.author}>
|
|
||||||
{comment.text}
|
|
||||||
</Comment>
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="commentList">
|
|
||||||
{commentNodes}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var CommentForm = React.createClass({
|
|
||||||
handleSubmit: function(e){
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
var author = this.refs.author.value.trim();
|
|
||||||
var text = this.refs.text.value.trim();
|
|
||||||
if(!text || !author){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.props.onCommentSubmit({author: author, text: text});
|
|
||||||
|
|
||||||
this.refs.author.value = '';
|
|
||||||
this.refs.text.value = '';
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
render: function(){
|
|
||||||
return (
|
|
||||||
<form className="commentForm" onSubmit={this.handleSubmit}>
|
|
||||||
<input type="text" placeholder="Your name" ref="author" />
|
|
||||||
<input type="text" placeholder="Say something..." ref="text" />
|
|
||||||
<input type="submit" value="Post" />
|
|
||||||
</form>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var Comment = React.createClass({
|
|
||||||
|
|
||||||
rawMarkup: function() {
|
|
||||||
var rawMarkup = marked(this.props.children.toString(), {sanitize: true});
|
|
||||||
return { __html: rawMarkup };
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function(){
|
|
||||||
return (
|
|
||||||
<div className="comment">
|
|
||||||
<h2 className="commentAuthor">
|
|
||||||
{this.props.author}
|
|
||||||
</h2>
|
|
||||||
<span dangerouslySetInnerHTML={this.rawMarkup()}></span>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
React.render(<CommentBox url="api/comment.json"/>, document.getElementById("example"));
|
|
@ -1,546 +1,29 @@
|
|||||||
var app = angular.module('wechat', ['ngRoute']);
|
var app = angular.module('wechat', ['ngRoute']);
|
||||||
var apiUrl = '/api/v1/';
|
|
||||||
var debug = false; //调试标志,如果在本地请置为true
|
|
||||||
|
|
||||||
if(debug===true){
|
app.constant('config', {
|
||||||
//apiUrl = 'http://localhost:3000/api/v1/';
|
rootPath: '/assets/wechat/',
|
||||||
apiUrl = 'http://www.trustie.net/api/v1/';
|
rootUrl: '/',
|
||||||
}
|
apiUrl: '/api/v1/'
|
||||||
|
|
||||||
|
|
||||||
app.factory('auth', function($http,$routeParams, $q){
|
|
||||||
var _openid = '';
|
|
||||||
|
|
||||||
if(typeof g_openid !== 'undefined'){
|
|
||||||
_openid = g_openid;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(debug===true){
|
|
||||||
_openid = "orgVLv8TlS6e7FDiI6xdTGHRaaRo"; //guange的帐号
|
|
||||||
}
|
|
||||||
|
|
||||||
var getOpenId = function() {
|
|
||||||
var deferred = $q.defer();
|
|
||||||
if (typeof _openid !== 'undefined' && _openid.length > 0){
|
|
||||||
deferred.resolve(_openid);
|
|
||||||
} else {
|
|
||||||
var code = $routeParams.code;
|
|
||||||
$http({
|
|
||||||
url: '/wechat/get_open_id',
|
|
||||||
data: {code: code},
|
|
||||||
method: 'POST'
|
|
||||||
}).then(function successCallback(response) {
|
|
||||||
_openid = response.data.openid;
|
|
||||||
deferred.resolve(_openid);
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
deferred.reject(response);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return deferred.promise;
|
|
||||||
};
|
|
||||||
var openid = function(){
|
|
||||||
return _openid;
|
|
||||||
};
|
|
||||||
return {getOpenId: getOpenId, openid: openid};
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
app.factory('rms', function(){
|
|
||||||
var _saveStorage = {};
|
|
||||||
var save = function(key, value){
|
|
||||||
_saveStorage[key] = value;
|
|
||||||
};
|
|
||||||
|
|
||||||
var get = function(key){
|
|
||||||
return _saveStorage[key];
|
|
||||||
};
|
|
||||||
|
|
||||||
return {save: save, get: get};
|
|
||||||
});
|
|
||||||
|
|
||||||
app.controller('ActivityController',function($anchorScroll, $location,$scope, $http, $timeout, auth, rms, common){
|
|
||||||
$scope.replaceUrl = function(url){
|
|
||||||
return url;
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log("ActivityController load");
|
|
||||||
|
|
||||||
$scope.page = rms.get('page') || 0;
|
|
||||||
$scope.activities = rms.get("activities") || [];
|
|
||||||
$scope.has_more = rms.get("has_more");
|
|
||||||
|
|
||||||
$scope.loadActData = function(page){
|
|
||||||
|
|
||||||
$scope.page = page;
|
|
||||||
$http({
|
|
||||||
method: 'POST',
|
|
||||||
url: apiUrl+ "activities",
|
|
||||||
data: {openid: auth.openid(), page: page}
|
|
||||||
}).then(function successCallback(response) {
|
|
||||||
if(response.data.page >0) {
|
|
||||||
$scope.activities = $scope.activities.concat(response.data.data);
|
|
||||||
} else {
|
|
||||||
$scope.activities = response.data.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
rms.save("activities", $scope.activities);
|
|
||||||
$scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count;
|
|
||||||
rms.save('has_more', $scope.has_more);
|
|
||||||
rms.save('page', response.data.page);
|
|
||||||
|
|
||||||
console.log(response.data);
|
|
||||||
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if($scope.activities.length<=0){
|
|
||||||
auth.getOpenId().then(
|
|
||||||
function successCallback(response){
|
|
||||||
$scope.loadActData(0);
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
alert("获取openid出错:"+response);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$timeout(function(){
|
|
||||||
window.scrollTo(0, rms.get("yoffset"));
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//跳到详情页
|
|
||||||
$scope.goDetail = function(type, act_id,id){
|
|
||||||
rms.save("yoffset", window.document.body.scrollTop);
|
|
||||||
$location.path('/'+type+'/'+act_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.addPraise = function(act){
|
|
||||||
common.addCommonPraise(act);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.decreasePraise = function(act){
|
|
||||||
common.decreaseCommonPraise(act);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
app.factory('common', function($http, auth, $routeParams){
|
|
||||||
var addCommonReply = function(id, type, data, cb){
|
|
||||||
|
|
||||||
if(!data.comment || data.comment.length<=0){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var temp = data.comment.replace(/\n/g,'<br/>');
|
|
||||||
|
|
||||||
var userInfo = {
|
|
||||||
type: type,
|
|
||||||
content: temp,
|
|
||||||
openid: auth.openid()
|
|
||||||
};
|
|
||||||
//回复按钮禁用
|
|
||||||
data.disabled = true;
|
|
||||||
|
|
||||||
$http({
|
|
||||||
method: 'POST',
|
|
||||||
url: apiUrl+ "new_comment/"+id,
|
|
||||||
data: userInfo
|
|
||||||
}).then(function successCallback(response) {
|
|
||||||
//alert("提交成功");
|
|
||||||
//数据提交完成,回复按钮启用
|
|
||||||
data.disabled = false;
|
|
||||||
if(typeof cb === 'function'){
|
|
||||||
cb();
|
|
||||||
}
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var loadCommonData = function(id, type){
|
|
||||||
return $http({
|
|
||||||
method: 'GET',
|
|
||||||
url: apiUrl+ type + "/" + id+"?openid="+auth.openid()
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
var addCommonPraise = function(act){
|
|
||||||
act.praise_count += 1;
|
|
||||||
act.has_praise = true;
|
|
||||||
|
|
||||||
$http({
|
|
||||||
method: 'POST',
|
|
||||||
url: apiUrl + "praise/" + act.act_id,
|
|
||||||
data:{openid:auth.openid(),type:act.act_type}
|
|
||||||
}).then(function successCallback(response) {
|
|
||||||
console.log(response.data);
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
var decreaseCommonPraise = function(act){
|
|
||||||
act.praise_count -= 1;
|
|
||||||
act.has_praise = false;
|
|
||||||
|
|
||||||
$http({
|
|
||||||
method: 'POST',
|
|
||||||
url: apiUrl + "praise/" + act.act_id,
|
|
||||||
data:{openid:auth.openid(),type:act.act_type}
|
|
||||||
}).then(function successCallback(response) {
|
|
||||||
console.log(response.data);
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return {addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise};
|
|
||||||
});
|
|
||||||
|
|
||||||
app.controller('IssueController', function($scope, $http, $routeParams, auth, common){
|
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
|
|
||||||
var loadData = function(id){
|
|
||||||
common.loadCommonData(id, 'issues').then(function successCallback(response) {
|
|
||||||
console.log(response.data);
|
|
||||||
$scope.issue = response.data.data;
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
auth.getOpenId().then(
|
|
||||||
function successCallback(response){
|
|
||||||
loadData($routeParams.id);
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
alert("获取openid出错:"+response);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$scope.addIssueReply = function(data){
|
|
||||||
console.log(data.comment);
|
|
||||||
common.addCommonReply($routeParams.id, 'Issue', data, function(){
|
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
loadData($routeParams.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.addPraise = function(act){
|
|
||||||
common.addCommonPraise(act);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.decreasePraise = function(act){
|
|
||||||
common.decreaseCommonPraise(act);
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.controller('HomeworkController', function($scope, $http, $routeParams, auth, common){
|
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
|
|
||||||
var loadData = function(id){
|
app.run(['$rootScope', 'auth', '$location', '$routeParams', function($rootScope, auth, $location, $routeParams){
|
||||||
common.loadCommonData(id, 'whomeworks').then(function successCallback(response) {
|
|
||||||
console.log(response.data);
|
|
||||||
$scope.homework = response.data.data;
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
auth.getOpenId().then(
|
if(g_redirect_path && g_redirect_path.length>1){
|
||||||
function successCallback(response){
|
$location.path(g_redirect_path);
|
||||||
loadData($routeParams.id);
|
g_redirect_path = null;
|
||||||
}, function errorCallback(response) {
|
|
||||||
alert("获取openid出错:"+response);
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
$scope.addHomeworkReply = function(data){
|
|
||||||
console.log(data.comment);
|
|
||||||
common.addCommonReply($routeParams.id, 'HomeworkCommon', data, function(){
|
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
loadData($routeParams.id);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.addPraise = function(act){
|
|
||||||
common.addCommonPraise(act);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.decreasePraise = function(act){
|
|
||||||
common.decreaseCommonPraise(act);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth, common){
|
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
|
|
||||||
var loadData = function(id){
|
$rootScope.$on('$routeChangeError', function(event, next, current){
|
||||||
common.loadCommonData(id, 'newss').then(function successCallback(response) {
|
|
||||||
console.log(response.data);
|
|
||||||
$scope.news = response.data.data;
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
auth.getOpenId().then(
|
if(next && next.templateUrl){
|
||||||
function successCallback(response){
|
if(!next.templateUrl.endsWith("login.html") && !next.templateUrl.endsWith("reg.html")){
|
||||||
loadData($routeParams.id);
|
$location.path("/login");
|
||||||
}, function errorCallback(response) {
|
|
||||||
alert("获取openid出错:"+response);
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
$scope.addNoticeReply = function(data){
|
|
||||||
console.log(data.comment);
|
|
||||||
common.addCommonReply($routeParams.id, 'News', data, function(){
|
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
loadData($routeParams.id);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.addPraise = function(act){
|
|
||||||
common.addCommonPraise(act);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.decreasePraise = function(act){
|
|
||||||
common.decreaseCommonPraise(act);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
app.controller('DiscussionController', function($scope, $http, $routeParams, auth, common){
|
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
|
|
||||||
var loadData = function(id){
|
|
||||||
common.loadCommonData(id, 'messages').then(function successCallback(response) {
|
|
||||||
console.log(response.data);
|
|
||||||
$scope.discussion = response.data.data;
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
auth.getOpenId().then(
|
|
||||||
function successCallback(response){
|
|
||||||
loadData($routeParams.id);
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
alert("获取openid出错:"+response);
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
$scope.addDiscussionReply = function(data){
|
|
||||||
console.log(data.comment);
|
|
||||||
common.addCommonReply($routeParams.id, 'Message', data, function(){
|
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
loadData($routeParams.id);
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
$scope.addPraise = function(act){
|
|
||||||
common.addCommonPraise(act);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.decreasePraise = function(act){
|
|
||||||
common.decreaseCommonPraise(act);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
app.controller('JournalsController', function($scope, $http, $routeParams, auth, common){
|
$rootScope.$on('$routeChangeStart', function(event, next, current){
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
|
|
||||||
var loadData = function(id){
|
|
||||||
common.loadCommonData(id, 'journal_for_messages').then(function successCallback(response) {
|
|
||||||
console.log(response.data);
|
|
||||||
$scope.message = response.data.data;
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
]);
|
||||||
auth.getOpenId().then(
|
|
||||||
function successCallback(response){
|
|
||||||
loadData($routeParams.id);
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
alert("获取openid出错:"+response);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$scope.addJournalReply = function(data){
|
|
||||||
console.log(data.comment);
|
|
||||||
common.addCommonReply($routeParams.id, 'JournalsForMessage', data, function(){
|
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
loadData($routeParams.id);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.addPraise = function(act){
|
|
||||||
console.log(act);
|
|
||||||
common.addCommonPraise(act);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.decreasePraise = function(act){
|
|
||||||
console.log(act);
|
|
||||||
common.decreaseCommonPraise(act);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
app.controller('BlogController', function($scope, $http, $routeParams, auth, common){
|
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
|
|
||||||
var loadData = function(id){
|
|
||||||
common.loadCommonData(id, 'blog_comments').then(function successCallback(response) {
|
|
||||||
console.log(response.data);
|
|
||||||
$scope.blog = response.data.data;
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
auth.getOpenId().then(
|
|
||||||
function successCallback(response){
|
|
||||||
loadData($routeParams.id);
|
|
||||||
}, function errorCallback(response) {
|
|
||||||
alert("获取openid出错:"+response);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$scope.addBlogReply = function(data){
|
|
||||||
console.log(data.comment);
|
|
||||||
common.addCommonReply($routeParams.id, 'BlogComment', data, function(){
|
|
||||||
$scope.formData = {comment: ''};
|
|
||||||
loadData($routeParams.id);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.addPraise = function(act){
|
|
||||||
console.log(act);
|
|
||||||
common.addCommonPraise(act);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.decreasePraise = function(act){
|
|
||||||
console.log(act);
|
|
||||||
common.decreaseCommonPraise(act);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
app.filter('safeHtml', function ($sce) {
|
|
||||||
return function (input) {
|
|
||||||
return $sce.trustAsHtml(input);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//app.directive('textAutoHeight', function($timeout){
|
|
||||||
// return {
|
|
||||||
// restrict: 'A',
|
|
||||||
// scope: {},
|
|
||||||
// link: function(scope, element, attr){
|
|
||||||
// scope.text = '点击展开';
|
|
||||||
// $timeout(function(){
|
|
||||||
// var e = element.parent().children().eq(5);
|
|
||||||
// var height = e[0].scrollHeight;
|
|
||||||
// if(height>90){
|
|
||||||
// element.css('display', 'block');
|
|
||||||
// element.on('click', function(){
|
|
||||||
// if(element.text() == "点击展开"){
|
|
||||||
// e.css("height", height+'px');
|
|
||||||
// element.text("点击隐藏");
|
|
||||||
// } else {
|
|
||||||
// e.css("height", '90px');
|
|
||||||
// element.text("点击展开");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }, false);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//});
|
|
||||||
|
|
||||||
app.directive('inputAuto',function(){
|
|
||||||
return{
|
|
||||||
restrict: 'A',
|
|
||||||
scope: {},
|
|
||||||
link: function(scope, element){
|
|
||||||
var copyContainer = element.parent().children().eq(0);
|
|
||||||
var sendButton = element.parent().next();
|
|
||||||
element.on('input',function(){
|
|
||||||
console.log(sendButton);
|
|
||||||
copyContainer.html(element[0].value);
|
|
||||||
var textHeight = copyContainer[0].scrollHeight;
|
|
||||||
element.css('height', textHeight + 'px');
|
|
||||||
});
|
|
||||||
sendButton.on('click',function(){
|
|
||||||
element.css('height','28px');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
app.directive('loadingSpinner', ['$http', function ($http) {
|
|
||||||
return {
|
|
||||||
restrict: 'A',
|
|
||||||
replace: true,
|
|
||||||
template: '<div ng-show="activeCalls>0" class="loading-bg"><div class="loading-box"><img src="/images/loading.gif" alt=""/><span>加载中...</span></div></div>',
|
|
||||||
};
|
|
||||||
}]);
|
|
||||||
|
|
||||||
app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($routeProvider, $httpProvider, $locationProvider) {
|
|
||||||
var rootPath = '/assets/wechat/'
|
|
||||||
//$locationProvider.html5Mode(true);
|
|
||||||
$routeProvider
|
|
||||||
.when('/activites', {
|
|
||||||
templateUrl: rootPath + 'activities.html',
|
|
||||||
controller: 'ActivityController'
|
|
||||||
})
|
|
||||||
.when('/issues/:id', {
|
|
||||||
templateUrl: rootPath + 'issue_detail.html',
|
|
||||||
controller: 'IssueController'
|
|
||||||
})
|
|
||||||
.when('/project_discussion/:id', {
|
|
||||||
templateUrl: rootPath + 'project_discussion.html',
|
|
||||||
controller: 'DiscussionController'
|
|
||||||
})
|
|
||||||
.when('/homework/:id', {
|
|
||||||
templateUrl: rootPath + 'homework_detail.html',
|
|
||||||
controller: 'HomeworkController'
|
|
||||||
})
|
|
||||||
.when('/course_notice/:id', {
|
|
||||||
templateUrl: rootPath + 'course_notice.html',
|
|
||||||
controller: 'CourseNoticeController'
|
|
||||||
})
|
|
||||||
.when('/course_discussion/:id', {
|
|
||||||
templateUrl: rootPath + 'course_discussion.html',
|
|
||||||
controller: 'DiscussionController'
|
|
||||||
})
|
|
||||||
.when('/journal_for_message/:id', {
|
|
||||||
templateUrl: rootPath + 'jour_message_detail.html',
|
|
||||||
controller: 'JournalsController'
|
|
||||||
})
|
|
||||||
.when('/blog_comment/:id', {
|
|
||||||
templateUrl: rootPath + 'blog_detail.html',
|
|
||||||
controller: 'BlogController'
|
|
||||||
})
|
|
||||||
.otherwise({
|
|
||||||
redirectTo: '/activites'
|
|
||||||
});
|
|
||||||
|
|
||||||
//监听异步请求,实现加载中显隐标记
|
|
||||||
$httpProvider.interceptors.push(function ($q, $rootScope) {
|
|
||||||
if ($rootScope.activeCalls == undefined) {
|
|
||||||
$rootScope.activeCalls = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
request: function (config) {
|
|
||||||
$rootScope.activeCalls += 1;
|
|
||||||
return config;
|
|
||||||
},
|
|
||||||
requestError: function (rejection) {
|
|
||||||
$rootScope.activeCalls -= 1;
|
|
||||||
return rejection;
|
|
||||||
},
|
|
||||||
response: function (response) {
|
|
||||||
$rootScope.activeCalls -= 1;
|
|
||||||
return response;
|
|
||||||
},
|
|
||||||
responseError: function (rejection) {
|
|
||||||
$rootScope.activeCalls -= 1;
|
|
||||||
return rejection;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}]);
|
|
@ -1,36 +0,0 @@
|
|||||||
$(function(){
|
|
||||||
//获取url中的参数
|
|
||||||
function getUrlParam(name) {
|
|
||||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
|
|
||||||
var r = window.location.search.substr(1).match(reg); //匹配目标参数
|
|
||||||
if (r != null) return unescape(r[2]); return null; //返回参数值
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var debug = false;
|
|
||||||
|
|
||||||
var g_openid = "";
|
|
||||||
if(debug){
|
|
||||||
g_openid = "填写要调试的openid即可";
|
|
||||||
}
|
|
||||||
|
|
||||||
window.getOpenId = function(cb){
|
|
||||||
if (g_openid.length>0){
|
|
||||||
cb(g_openid);
|
|
||||||
}
|
|
||||||
var code = getUrlParam("code");
|
|
||||||
$.ajax({
|
|
||||||
url: '/wechat/get_open_id',
|
|
||||||
data: {code: code},
|
|
||||||
type: 'post',
|
|
||||||
dataType: 'json',
|
|
||||||
success: function(data){
|
|
||||||
g_openid = data.openid;
|
|
||||||
cb(g_openid);
|
|
||||||
},
|
|
||||||
error: function(xhr,err){
|
|
||||||
alert("认证失败: "+err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
app.controller('ActivityController',
|
||||||
|
['$anchorScroll', '$location','$scope', '$http', '$timeout', 'auth', 'rms', 'common','alertService',
|
||||||
|
function($anchorScroll, $location,$scope, $http, $timeout, auth, rms, common, alertService){
|
||||||
|
$scope.replaceUrl = function(url){
|
||||||
|
return url;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.alertService = alertService.create();
|
||||||
|
console.log("ActivityController load");
|
||||||
|
|
||||||
|
$scope.page = rms.get('page') || 0;
|
||||||
|
$scope.activities = rms.get("activities") || [];
|
||||||
|
$scope.has_more = rms.get("has_more");
|
||||||
|
|
||||||
|
$scope.loadActData = function(page){
|
||||||
|
|
||||||
|
$scope.page = page;
|
||||||
|
$http({
|
||||||
|
method: 'POST',
|
||||||
|
url: apiUrl+ "activities",
|
||||||
|
data: {token: auth.token(), page: page}
|
||||||
|
}).then(function successCallback(response) {
|
||||||
|
if(response.data.page >0) {
|
||||||
|
$scope.activities = $scope.activities.concat(response.data.data);
|
||||||
|
} else {
|
||||||
|
$scope.activities = response.data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
rms.save("activities", $scope.activities);
|
||||||
|
$scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count;
|
||||||
|
rms.save('has_more', $scope.has_more);
|
||||||
|
rms.save('page', response.data.page);
|
||||||
|
|
||||||
|
console.log(response.data);
|
||||||
|
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if($scope.activities.length<=0){
|
||||||
|
$scope.loadActData(0);
|
||||||
|
} else {
|
||||||
|
$timeout(function(){
|
||||||
|
window.scrollTo(0, rms.get("yoffset"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//跳到详情页
|
||||||
|
$scope.goDetail = function(type, act_id,id){
|
||||||
|
rms.save("yoffset", window.document.body.scrollTop);
|
||||||
|
$location.path('/'+type+'/'+act_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.addPraise = function(act){
|
||||||
|
common.addCommonPraise(act);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.decreasePraise = function(act){
|
||||||
|
common.decreaseCommonPraise(act);
|
||||||
|
};
|
||||||
|
}]);
|
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
app.controller('AddClassController', ['$scope',function($scope){
|
||||||
|
|
||||||
|
}]);
|
@ -0,0 +1,16 @@
|
|||||||
|
app.controller('BlogController',
|
||||||
|
['$scope', '$http', '$routeParams', 'auth', 'common',
|
||||||
|
function($scope, $http, $routeParams, auth, common){
|
||||||
|
|
||||||
|
common.init({
|
||||||
|
id: $routeParams.id,
|
||||||
|
scope: $scope,
|
||||||
|
type: 'blog_comments',
|
||||||
|
replyType: 'BlogComment',
|
||||||
|
loadCallback: function(data){
|
||||||
|
$scope.blog = data.data;
|
||||||
|
},
|
||||||
|
replyCallback: function(){
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}]);
|
@ -0,0 +1,16 @@
|
|||||||
|
app.controller('CourseNoticeController', ['$scope', '$http', '$routeParams', 'auth', 'common',
|
||||||
|
function($scope, $http, $routeParams, auth, common){
|
||||||
|
|
||||||
|
common.init({
|
||||||
|
id: $routeParams.id,
|
||||||
|
scope: $scope,
|
||||||
|
type: 'newss',
|
||||||
|
replyType: 'News',
|
||||||
|
loadCallback: function(data){
|
||||||
|
$scope.news = data.data;
|
||||||
|
},
|
||||||
|
replyCallback: function(){
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}]);
|
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
app.controller('DiscussionController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){
|
||||||
|
common.init({
|
||||||
|
id: $routeParams.id,
|
||||||
|
scope: $scope,
|
||||||
|
type: 'messages',
|
||||||
|
replyType: 'Message',
|
||||||
|
loadCallback: function(data){
|
||||||
|
$scope.discussion = data.data;
|
||||||
|
},
|
||||||
|
replyCallback: function(){
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}]);
|
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
app.controller('HomeworkController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){
|
||||||
|
common.init({
|
||||||
|
id: $routeParams.id,
|
||||||
|
scope: $scope,
|
||||||
|
type: 'whomeworks',
|
||||||
|
replyType: 'HomeworkCommon',
|
||||||
|
loadCallback: function(data){
|
||||||
|
console.log(data);
|
||||||
|
$scope.homework = data.data;
|
||||||
|
},
|
||||||
|
replyCallback: function(){
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}]);
|
@ -0,0 +1,15 @@
|
|||||||
|
app.controller('IssueController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){
|
||||||
|
|
||||||
|
common.init({
|
||||||
|
id: $routeParams.id,
|
||||||
|
scope: $scope,
|
||||||
|
type: 'issues',
|
||||||
|
replyType: 'Issue',
|
||||||
|
loadCallback: function(data){
|
||||||
|
console.log(data);
|
||||||
|
$scope.issue = data.data;
|
||||||
|
},
|
||||||
|
replyCallback: function(){
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}]);
|
@ -0,0 +1,13 @@
|
|||||||
|
app.controller('JournalsController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){
|
||||||
|
common.init({
|
||||||
|
id: $routeParams.id,
|
||||||
|
scope: $scope,
|
||||||
|
type: 'journal_for_messages',
|
||||||
|
replyType: 'JournalsForMessage',
|
||||||
|
loadCallback: function(data){
|
||||||
|
$scope.message = data.data;
|
||||||
|
},
|
||||||
|
replyCallback: function(){
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}]);
|
@ -0,0 +1,54 @@
|
|||||||
|
app.controller('MyClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams', function($scope, config, $http, auth, $location, $routeParams){
|
||||||
|
|
||||||
|
var vm = $scope;
|
||||||
|
var courseid = $routeParams.id;
|
||||||
|
|
||||||
|
vm.currentTab = 1;
|
||||||
|
vm.tab = function(index){
|
||||||
|
vm.currentTab = index;
|
||||||
|
vm.searchText = '';
|
||||||
|
console.log(vm.currentTab);
|
||||||
|
if(index == 2){
|
||||||
|
if(vm.students.length<=0){
|
||||||
|
$http.get(config.apiUrl + 'courses/students?token='+auth.token()+'&course_id='+courseid).then(
|
||||||
|
function(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
vm.students = response.data.data;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vm.course = {};
|
||||||
|
vm.students = [];
|
||||||
|
vm.teachers = [];
|
||||||
|
vm.resources = [];
|
||||||
|
|
||||||
|
vm.invite = function(){
|
||||||
|
$location.path("/invite_code").search({id: courseid});
|
||||||
|
};
|
||||||
|
|
||||||
|
$http.post(config.apiUrl + "courses/"+courseid+"/attachments",
|
||||||
|
{token: auth.token(), name: ''}
|
||||||
|
).then(function(response){
|
||||||
|
vm.resources = response.data.data;
|
||||||
|
});
|
||||||
|
|
||||||
|
$http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then(
|
||||||
|
function(response){
|
||||||
|
console.log(response.data);
|
||||||
|
vm.course = response.data.data;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
if(vm.teachers.length<=0){
|
||||||
|
$http.get(config.apiUrl + 'courses/teachers?token='+auth.token()+'&course_id='+courseid).then(
|
||||||
|
function(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
vm.teachers = response.data.data;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}]);
|
@ -0,0 +1,42 @@
|
|||||||
|
app.controller('RegController', ['$scope', '$http', '$location', 'alertService',
|
||||||
|
function ($scope, $http, $location, alertService) {
|
||||||
|
|
||||||
|
var vm = $scope;
|
||||||
|
vm.errDialog = alertService.create();
|
||||||
|
|
||||||
|
vm.goLogin = function () {
|
||||||
|
$location.path("/login");
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.isagreed = true;
|
||||||
|
vm.agreed = function (_isagreed) {
|
||||||
|
vm.isagreed = !_isagreed;
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.reg = function (frm, user) {
|
||||||
|
|
||||||
|
frm.$setSubmitted();
|
||||||
|
|
||||||
|
console.log(frm);
|
||||||
|
if (!frm.$valid) {
|
||||||
|
console.log(frm.$error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(user);
|
||||||
|
|
||||||
|
$http.post(
|
||||||
|
apiUrl + "users",
|
||||||
|
{login: user.username, password: user.password, mail: user.email}
|
||||||
|
).then(function (response) {
|
||||||
|
if (response.data.status != 0) {
|
||||||
|
vm.errDialog.showMessage('出错了',response.data.message);
|
||||||
|
} else {
|
||||||
|
vm.errDialog.showMessage("提示","注册且绑定微信成功");
|
||||||
|
}
|
||||||
|
}, function (response) {
|
||||||
|
vm.errDialo.showMessage('出错了',response.data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}]);
|
@ -0,0 +1,19 @@
|
|||||||
|
app.directive('myAlert', ['config', function(config){
|
||||||
|
return {
|
||||||
|
templateUrl: config.rootPath+ 'templates/alert.html',
|
||||||
|
scope: {
|
||||||
|
title: "=",
|
||||||
|
message: "=",
|
||||||
|
visible: "=",
|
||||||
|
cb: "="
|
||||||
|
},
|
||||||
|
link: function(scope){
|
||||||
|
scope.dismiss = function(){
|
||||||
|
scope.visible = false;
|
||||||
|
if(typeof scope.cb === 'function'){
|
||||||
|
scope.cb();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]);
|
@ -0,0 +1,10 @@
|
|||||||
|
app.directive('pwdconfirm', function(){
|
||||||
|
return {
|
||||||
|
require: 'ngModel',
|
||||||
|
link: function(scope, elm, attrs, ctrl){
|
||||||
|
ctrl.$validators.pwdconfirm = function(modelValue, viewValue) {
|
||||||
|
return scope.user && scope.user.password == viewValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,19 @@
|
|||||||
|
app.directive('inputAuto',function(){
|
||||||
|
return{
|
||||||
|
restrict: 'A',
|
||||||
|
scope: {},
|
||||||
|
link: function(scope, element){
|
||||||
|
var copyContainer = element.parent().children().eq(0);
|
||||||
|
var sendButton = element.parent().next();
|
||||||
|
element.on('input',function(){
|
||||||
|
console.log(sendButton);
|
||||||
|
copyContainer.html(element[0].value);
|
||||||
|
var textHeight = copyContainer[0].scrollHeight;
|
||||||
|
element.css('height', textHeight + 'px');
|
||||||
|
});
|
||||||
|
sendButton.on('click',function(){
|
||||||
|
element.css('height','28px');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,7 @@
|
|||||||
|
app.directive('loadingSpinner', ['$http', function ($http) {
|
||||||
|
return {
|
||||||
|
restrict: 'A',
|
||||||
|
replace: true,
|
||||||
|
template: '<div ng-show="activeCalls>0" class="loading-bg"><div class="loading-box"><img src="/images/loading.gif" alt=""/><span>加载中...</span></div></div>',
|
||||||
|
};
|
||||||
|
}]);
|
@ -0,0 +1,182 @@
|
|||||||
|
app.factory('alertService', function(){
|
||||||
|
function Alert(){
|
||||||
|
this.title = null;
|
||||||
|
this.message = null;
|
||||||
|
this.visible = null;
|
||||||
|
this.cb = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Alert.prototype.showMessage = function(title, msg, cb){
|
||||||
|
this.message = msg;
|
||||||
|
this.title = title;
|
||||||
|
this.visible = true;
|
||||||
|
this.cb = cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
Alert.prototype.dismiss = function(){
|
||||||
|
this.message = null;
|
||||||
|
this.title = null;
|
||||||
|
this.visible = false;
|
||||||
|
if(this.cb) {this.cb();}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
create: function(){
|
||||||
|
return new Alert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
app.factory('auth', ['$http','$routeParams', '$q', 'session', 'config',function($http,$routeParams, $q, session,config){
|
||||||
|
//是否已经绑定
|
||||||
|
var isBind = function(){
|
||||||
|
var defer = $q.defer();
|
||||||
|
|
||||||
|
var token = getToken();
|
||||||
|
if(token && token.length>10){
|
||||||
|
defer.resolve(token);
|
||||||
|
} else {
|
||||||
|
var code = window.g_code || $routeParams.code || session.get("code");
|
||||||
|
$http.post(
|
||||||
|
'/wechat/get_bind',
|
||||||
|
{} ///不用传code了,都由服务器来处理
|
||||||
|
).then(function(response){
|
||||||
|
if(response.data.status!=0){
|
||||||
|
defer.reject(response.data.message);
|
||||||
|
}else {
|
||||||
|
session.save("token", response.data.token);
|
||||||
|
defer.resolve(response.data.token);
|
||||||
|
}
|
||||||
|
}).catch(function(e){
|
||||||
|
defer.reject(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return defer.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
var getToken = function(){
|
||||||
|
return session.get("token");
|
||||||
|
}
|
||||||
|
return {get_bind: isBind, token: getToken};
|
||||||
|
}]);
|
||||||
|
|
||||||
|
app.factory("session", function(){
|
||||||
|
return {
|
||||||
|
save: function(key,value){
|
||||||
|
sessionStorage.setItem(key,value);
|
||||||
|
},
|
||||||
|
get: function(key){
|
||||||
|
return sessionStorage.getItem(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.factory('rms', function(){
|
||||||
|
var _saveStorage = {};
|
||||||
|
var save = function(key, value){
|
||||||
|
_saveStorage[key] = value;
|
||||||
|
};
|
||||||
|
|
||||||
|
var get = function(key){
|
||||||
|
return _saveStorage[key];
|
||||||
|
};
|
||||||
|
|
||||||
|
return {save: save, get: get};
|
||||||
|
});
|
||||||
|
|
||||||
|
app.factory('common', ['$http', 'auth', '$routeParams', function($http, auth, $routeParams){
|
||||||
|
var addCommonReply = function(id, type, data, cb){
|
||||||
|
|
||||||
|
if(!data.comment || data.comment.length<=0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var temp = data.comment.replace(/\n/g,'<br/>');
|
||||||
|
|
||||||
|
var userInfo = {
|
||||||
|
type: type,
|
||||||
|
content: temp,
|
||||||
|
token: auth.token()
|
||||||
|
};
|
||||||
|
//回复按钮禁用
|
||||||
|
data.disabled = true;
|
||||||
|
|
||||||
|
$http({
|
||||||
|
method: 'POST',
|
||||||
|
url: apiUrl+ "new_comment/"+id,
|
||||||
|
data: userInfo
|
||||||
|
}).then(function successCallback(response) {
|
||||||
|
//alert("提交成功");
|
||||||
|
//数据提交完成,回复按钮启用
|
||||||
|
data.disabled = false;
|
||||||
|
if(typeof cb === 'function'){
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var loadCommonData = function(id, type){
|
||||||
|
return $http({
|
||||||
|
method: 'GET',
|
||||||
|
url: apiUrl+ type + "/" + id+"?token="+auth.token()
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
var addCommonPraise = function(act){
|
||||||
|
act.praise_count += 1;
|
||||||
|
act.has_praise = true;
|
||||||
|
|
||||||
|
$http({
|
||||||
|
method: 'POST',
|
||||||
|
url: apiUrl + "praise/" + act.act_id,
|
||||||
|
data:{token:auth.token(),type:act.act_type}
|
||||||
|
}).then(function successCallback(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var decreaseCommonPraise = function(act){
|
||||||
|
act.praise_count -= 1;
|
||||||
|
act.has_praise = false;
|
||||||
|
|
||||||
|
$http({
|
||||||
|
method: 'POST',
|
||||||
|
url: apiUrl + "praise/" + act.act_id,
|
||||||
|
data:{token:auth.token(),type:act.act_type}
|
||||||
|
}).then(function successCallback(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var init = function(args){
|
||||||
|
args.scope.formData = {comment: ''};
|
||||||
|
var loadData = function(id){
|
||||||
|
loadCommonData(id, args.type).then(function successCallback(response) {
|
||||||
|
args.loadCallback(response.data);
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
loadData(args.id);
|
||||||
|
args.scope.addReply = function(data){
|
||||||
|
console.log(data.comment);
|
||||||
|
addCommonReply(args.id, args.replyType, data, function(){
|
||||||
|
args.scope.formData = {comment: ''};
|
||||||
|
loadData(args.id);
|
||||||
|
if(typeof args.replyCallback === 'function'){
|
||||||
|
args.replyCallback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
args.scope.addPraise = addCommonPraise;
|
||||||
|
args.scope.decreasePraise = decreaseCommonPraise;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise};
|
||||||
|
}]);
|
@ -0,0 +1,14 @@
|
|||||||
|
app.filter('safeHtml', ['$sce',function ($sce) {
|
||||||
|
return function (input) {
|
||||||
|
return $sce.trustAsHtml(input);
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
app.filter('identify', function () {
|
||||||
|
return function(input){
|
||||||
|
if (input == 'TeachingAsistant'){
|
||||||
|
return '教辅'
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,65 @@
|
|||||||
|
app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', function ($routeProvider, $httpProvider, $locationProvider, config) {
|
||||||
|
var rootPath = config.rootPath;
|
||||||
|
var resolve = {
|
||||||
|
delay: ['auth',function(auth){
|
||||||
|
return auth.get_bind();
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
var makeRoute = function(path, ctrl){
|
||||||
|
return {
|
||||||
|
templateUrl: rootPath + path,
|
||||||
|
controller: ctrl,
|
||||||
|
resolve: resolve
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//$locationProvider.html5Mode(true);
|
||||||
|
$routeProvider
|
||||||
|
.when('/login', {
|
||||||
|
templateUrl: rootPath + 'login.html',
|
||||||
|
controller: 'LoginController'
|
||||||
|
})
|
||||||
|
.when('/reg', {
|
||||||
|
templateUrl: rootPath + 'reg.html',
|
||||||
|
controller: 'RegController'
|
||||||
|
})
|
||||||
|
.when('/activites', makeRoute('activities.html', 'ActivityController'))
|
||||||
|
.when('/issues/:id', makeRoute('issue_detail.html', 'IssueController'))
|
||||||
|
.when('/project_discussion/:id', makeRoute('project_discussion.html', 'DiscussionController'))
|
||||||
|
.when('/homework/:id', makeRoute('homework_detail.html', 'HomeworkController'))
|
||||||
|
.when('/course_notice/:id', makeRoute('course_notice.html', 'CourseNoticeController'))
|
||||||
|
.when('/course_discussion/:id', makeRoute('course_discussion.html', 'DiscussionController'))
|
||||||
|
.when('/journal_for_message/:id', makeRoute('jour_message_detail.html', 'JournalsController'))
|
||||||
|
.when('/blog_comment/:id', makeRoute('blog_detail.html', 'BlogController'))
|
||||||
|
.when('/add_class', makeRoute('add_class.html', 'AddClassController'))
|
||||||
|
.when('/myclass', makeRoute('myclass.html', 'MyClassController'))
|
||||||
|
.when('/invite_code', makeRoute('invite_code.html', 'InviteCodeController'))
|
||||||
|
.otherwise({
|
||||||
|
redirectTo: '/activites'
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听异步请求,实现加载中显隐标记
|
||||||
|
$httpProvider.interceptors.push(['$q', '$rootScope', function ($q, $rootScope) {
|
||||||
|
if ($rootScope.activeCalls == undefined) {
|
||||||
|
$rootScope.activeCalls = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
request: function (config) {
|
||||||
|
$rootScope.activeCalls += 1;
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
requestError: function (rejection) {
|
||||||
|
$rootScope.activeCalls -= 1;
|
||||||
|
return rejection;
|
||||||
|
},
|
||||||
|
response: function (response) {
|
||||||
|
$rootScope.activeCalls -= 1;
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
responseError: function (rejection) {
|
||||||
|
$rootScope.activeCalls -= 1;
|
||||||
|
return rejection;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}]);
|
||||||
|
}]);
|
@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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);
|
|
||||||
});
|
|
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
cd public/javascripts/wechat && gulp && gulp minify
|