Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange

This commit is contained in:
yuanke 2016-07-25 17:02:52 +08:00
commit 4f803ce0de
12 changed files with 2350 additions and 2711 deletions

View File

@ -51,7 +51,7 @@ gem 'elasticsearch-rails'
### profile
gem 'oneapm_rpm'
# gem 'oneapm_rpm'
group :development do
gem 'grape-swagger'

View File

@ -27,7 +27,7 @@ module Mobile
format :json
content_type :json, "application/json;charset=UTF-8"
use ActionDispatch::Session::CookieStore
use Mobile::Middleware::ErrorHandler
use Middleware::ErrorHandler
helpers do
def logger
@ -43,9 +43,9 @@ module Mobile
end
def current_user
openid = params[:openid]
openid = session[:wechat_openid]
if openid
uw = UserWechat.find_by_openid(params[:openid])
uw = UserWechat.find_by_openid(openid)
return uw.user if uw
end

View File

@ -0,0 +1,13 @@
#coding=utf-8
#
module Mobile
module Exceptions
class AuthException < StandardError
attr_reader :err_code, :msg
def initialize(code, msg)
@err_code = code
@msg = msg
end
end
end
end

View File

@ -1,3 +1,6 @@
#coding=utf-8
module Mobile
module Middleware
class ErrorHandler < Grape::Middleware::Base
@ -6,7 +9,10 @@ module Mobile
begin
@app.call(@env)
rescue =>e
message = {status: 1, message: e.message }.to_json
code = 1
message = {status: code, message: e.message }.to_json
Rails.logger.error e.inspect
Rails.logger.error e.backtrace.join("\n")
status = 200

View File

@ -288,8 +288,7 @@ class WechatsController < ActionController::Base
session[:wechat_code] = params[:code] if params[:code]
openid = get_openid_from_code(params[:code])
@wechat_user = user_binded?(openid)
render 'wechats/login', layout: 'base_wechat'
render 'wechats/user_activities', layout: nil
end
def user_activities
@ -299,13 +298,18 @@ 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
unless user_binded?(open_id)
@path = '/login'
else
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
session[:wechat_openid] = open_id
if params[:code]
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
end
end
render 'wechats/user_activities', layout: nil
end

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@ module Redmine
def acts_as_watchable(options = {})
return if self.included_modules.include?(Redmine::Acts::Watchable::InstanceMethods)
class_eval do
has_many :watchers, :as => :watchable, :dependent => :delete_all
has_many :watchers, :dependent => :delete_all
has_many :watcher_users, :through => :watchers, :source => :user, :validate => false
scope :watched_by, lambda { |user_id|

View File

@ -11,7 +11,7 @@
<img src="/images/wechat/dot.png" width="15px" class="class-list-dot" />
<span class="fl ml10 class-list-name hidden">{{course.name}}</span>
<span class="fr c-grey4">&gt;</span>
<span class="students-amount f12 fr mt10">{{course.member_count}}人</span>
<span class="students-amount f12 fr mt10 mr5">{{course.member_count}}人</span>
</li>
</ul>
</div>
@ -26,7 +26,7 @@
<img src="/images/wechat/dot.png" width="15px" class="class-list-dot" />
<span class="fl ml10 class-list-name hidden">{{course.name}}</span>
<span class="fr c-grey4">&gt;</span>
<span class="students-amount f12 fr mt10">{{course.member_count}}人</span>
<span class="students-amount f12 fr mt10 mr5">{{course.member_count}}人</span>
</li>
</ul>
</div>

View File

@ -6,8 +6,9 @@
<div class="course-diff-row"><span class="c-blue f13 ml10">我创建的项目</span></div>
<div ng-repeat="project in projects" style="position:relative;">
<div ng-click="goProject(project.id)" ng-show="project.can_setting" class="course-list-row f13 c-grey3 border-top-none">
<span class="fl ml10 class-list-name hidden">{{project.name}}</span>
<span class="students-amount f12 fr mt10 mr10">{{project.member_count}}人&gt;</span>
<span class="fl ml15 class-list-name hidden">{{project.name}}</span>
<span class="fr c-grey4 mr10">&gt;</span>
<span class="students-amount f12 fr mt10 mr5">{{project.member_count}}人</span>
</div>
</div>
@ -18,8 +19,9 @@
<div class="course-diff-row mt10"><span class="c-blue f13 ml10">我参与的项目</span></div>
<div ng-click="goProject(project.id)" ng-repeat="project in projects" style="position:relative;">
<div ng-show="!project.can_setting" class="course-list-row f13 c-grey3 border-top-none">
<span class="fl ml10 class-list-name hidden">{{project.name}}</span>
<span class="students-amount f12 fr mt10 mr10">{{project.member_count}}人&gt;</span>
<span class="fl ml15 class-list-name hidden">{{project.name}}</span>
<span class="fr c-grey4 mr10">&gt;</span>
<span class="students-amount f12 fr mt10 mr5">{{project.member_count}}人</span>
</div>
</div>

View File

@ -1,17 +1,18 @@
/**
* Created by Tim on 7/22/16.
*/
app.directive('ellipsisShow',function(){
app.directive('ellipsisShow',["$timeout",function(timer){
return{
restrict: 'A',
scope: {},
link: function(scope, element){
var textWrap = element.children().eq(0);
var textHeight = textWrap[0].scrollHeight;
console.log(textWrap[0].innerHTML);
while (textHeight > 100) {
textWrap[0].innerTEXT = "replaced";
}
timer(function() {
var textContent = element.text();
console.log(textContent);
//while (textHeight > 100) {
// element.text(element.text().replace(/(\s)*([a-zA-Z0-9]+|\W)(\.\.\.)?$/, "..."));
//}
});
}
}
});
}]);

View File

@ -60,7 +60,7 @@ app.factory('auth', ['$http','$routeParams', '$q', 'session', 'config',function(
}
var getToken = function(){
return session.get("token");
return 'token';//session.get("token");
}
return {get_bind: isBind, token: getToken};
}]);
@ -300,4 +300,4 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config', function(
}
return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise};
}]);
}]);

View File

@ -8,8 +8,8 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
var makeRoute = function(path, ctrl){
return {
templateUrl: rootPath + path,
controller: ctrl,
resolve: resolve
controller: ctrl
//resolve: resolve
}
}
//$locationProvider.html5Mode(true);
@ -59,6 +59,14 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
return rejection;
},
response: function (response) {
// var data = response.data;
// if(data && data.status==405){
// var rootScope = $injector.get('$rootScope');
// var state = $injector.get('$rootScope').$state.current.name;
// rootScope.stateBeforLogin = state;
// rootScope.$state.go("login");
// return $q.reject(response);
// }
$rootScope.activeCalls -= 1;
return response;
},