邀请码页面

This commit is contained in:
guange 2016-06-24 09:01:12 +08:00
parent d466b09f3f
commit 52d4d36097
12 changed files with 99 additions and 10 deletions

1
.gitignore vendored
View File

@ -34,3 +34,4 @@ vendor/cache
/config/initializers/gitlab_config.rb
1234567
public/javascripts/wechat/node_modules/
.ruby-version

View File

@ -81,7 +81,7 @@ group :assets do
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end

View File

@ -196,6 +196,7 @@ module Mobile
end
route_param :id do
get do
authenticate!
cs = CoursesService.new
course = cs.show_course(params,(current_user.nil? ? User.find(2):current_user))
#course = Course.find(params[:id])

View File

@ -45,6 +45,7 @@ module Mobile
course_expose :tea_id
course_expose :term
course_expose :time
course_expose :invite_code
course_expose :updated_at
course_expose :course_student_num
expose :teacher, using: Mobile::Entities::User do |c, opt|

View File

@ -260,7 +260,14 @@ class WechatsController < ActionController::Base
unless open_id
render 'wechats/open_wechat', layout: nil and return
end
if params[:state] == 'myclass'
@course_id = params[:id];
end
session[:wechat_openid] = open_id
if params[:code]
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
end
render 'wechats/user_activities', layout: nil
end

View File

@ -16,6 +16,9 @@
window.g_debug = false; //调试标志,如果在本地请置为true
window.apiUrl = '/api/v1/';
window.g_redirect_path = '<%= @path %>';
<% if @course_id %>
window.g_courseid = <%= @course_id %>;
<% end %>
</script>
</head>
@ -34,6 +37,7 @@
<script src="/javascripts/wechat/directives/input_auto.js"></script>
<script src="/javascripts/wechat/directives/loading_spinner.js"></script>
<script src="/javascripts/wechat/controllers/reg.js"></script>
<script src="/javascripts/wechat/controllers/invite_code.js"></script>
<script src="/javascripts/wechat/controllers/login.js"></script>
<script src="/javascripts/wechat/controllers/activity.js"></script>
<script src="/javascripts/wechat/controllers/add_class.js"></script>

View File

@ -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 src="/images/wechat/QR-code.jpg" width="152" class="qr-code-img" /></div>
<div class="invitation-code-wrap">邀请码:{{course.invite_code}}</div>
</div>
</div>
<div class="share-code-wrap">
<a href="javascript:void(0);" class="share-code-btn">分享邀请码</a>
<div class="share-code-instruction"> 1.将此页面分享给好友,邀请好友加入班级<br />
2.通过微信扫一扫加入班级<br />
3.输入邀请码加入班级</div>
</div>
</div>

View File

@ -1,5 +1,6 @@
<div class="post-container">
<div class="class-detail-name">分布式计算环境A班<span class="f13 blue-title-sub">邀请码</span></div>
<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">
@ -10,7 +11,7 @@
<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" placeholder="输入关键词进行搜索" />
<input class="class-detail-search" ng-model="searchText" placeholder="输入关键词进行搜索" />
</div>
</div>
<div ng-class="{'undis': currentTab!=1}">
@ -23,10 +24,14 @@
</div>
<div ng-class="{'undis': currentTab!=2}">
<div class="member-banner f13 c-grey3">授课老师</div>
<div class="class-detail-row f13 c-grey3"><img src="/images/wechat/male.jpg" width="30" class="fl ml10 img-circle mt4" /><span class="fl ml10">jacknudt</span><img src="/images/wechat/male.png" width="15" class="fl ml10 mt10" /></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.realname}}</span><span class="fr mr10 c-grey2">教辅</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"><img src="/images/wechat/male.jpg" width="30" class="fl ml10 img-circle mt4" /><span class="fl ml10">jingquan</span><span class="fr mr10 c-grey2">教辅</span><img src="/images/wechat/male.png" width="15" class="fl ml10 mt10" /></div>
<div class="class-detail-row f13 c-grey3"><img src="/images/wechat/male.jpg" width="30" class="fl ml10 img-circle mt4" /><span class="fl ml10">yuanke</span><img src="/images/wechat/male.png" width="15" class="fl ml10 mt10" /></div>
<div class="class-detail-row f13 c-grey3"><img src="/images/wechat/female.jpg" width="30" class="fl ml10 img-circle mt4" /><span class="fl ml10">sasameimei</span><img src="/images/wechat/female.png" width="15" class="fl ml10 mt10" /></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.realname}}</span><img ng-src="/images/wechat/{{student.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt10" />
</div>
</div>
</div>

View File

@ -9,7 +9,7 @@ app.constant('config', {
app.run(['$rootScope', 'auth', '$location', '$routeParams', function($rootScope, auth, $location, $routeParams){
if(g_redirect_path && g_redirect_path.length>0){
if(g_redirect_path && g_redirect_path.length>1){
$location.path(g_redirect_path);
g_redirect_path = null;
}

View File

@ -0,0 +1,18 @@
/**
* Created by guange on 16/6/22.
*/
app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config','auth', function($scope, $http, $routeParams, config, auth){
var vm = $scope;
vm.course = {};
var courseid = $routeParams.id;
$http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then(
function(response){
console.log(response.data);
vm.course = response.data.data;
}
);
}]);

View File

@ -1,11 +1,47 @@
app.controller('MyClassController', ['$scope', function($scope){
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;
console.log(vm.currentTab);
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.invite = function(){
$location.path("/invite_code").search({id: courseid});
};
$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;
}
)
}
}]);

View File

@ -32,6 +32,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
.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'
});