code获取修改

weixin_login
guange 9 years ago
parent 3f98562c0f
commit b7230333dc

@ -215,7 +215,8 @@ class WechatsController < ActionController::Base
# redirect_to login_wechat_path
# return
# end
session[:wechat_code] = params[:code] if params[:code]
@code = params[:code] || session[:wechat_code]
render 'wechats/user_activities', layout: nil
end

@ -12,7 +12,7 @@
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" />
<script type="text/javascript">
// window.g_openid = '<%= @wechat_user.openid %>';
window.g_code = <%= @code %>;
window.g_debug = false; //调试标志,如果在本地请置为true
window.apiUrl = '/api/v1/';
</script>

@ -7,7 +7,7 @@ app.constant('config', {
});
app.run(['$rootScope', 'auth', '$location', function($rootScope, auth, $location){
app.run(['$rootScope', 'auth', '$location', '$routeParams', function($rootScope, auth, $location, $routeParams){
$rootScope.$on('$routeChangeError', function(event, next, current){
if(next && next.templateUrl){
@ -18,6 +18,7 @@ app.run(['$rootScope', 'auth', '$location', function($rootScope, auth, $location
});
$rootScope.$on('$routeChangeStart', function(event, next, current){
console.log($routeParams);
if(next && next.templateUrl){
if(!next.templateUrl.endsWith("login.html") && !next.templateUrl.endsWith("reg.html")){
}

File diff suppressed because one or more lines are too long

@ -73,7 +73,7 @@ app.factory('auth', ['$http','$routeParams', '$q', 'session', 'config',function(
if (typeof _openid !== 'undefined' && _openid && _openid.length > 0){
deferred.resolve(_openid);
} else {
var code = $routeParams.code || session.get("code");
var code = window.g_code || $routeParams.code || session.get("code");
$http({
url: '/wechat/get_open_id',
data: {code: code},

Loading…
Cancel
Save