修改openid路由

This commit is contained in:
guange 2016-04-02 07:49:36 +08:00
parent a25fe6cef8
commit 1926f0ba53
3 changed files with 4 additions and 10 deletions

View File

@ -211,13 +211,6 @@ class WechatsController < ActionController::Base
render 'wechats/login', layout: 'base_wechat'
end
def get_openid
code = params[:code]
openid = get_openid_from_code(code)
render :text => {openid: openid}.to_json
end
private
def get_openid_from_code(code)
url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{Wechat.config.appid}&secret=#{Wechat.config.secret}&code=#{code}&grant_type=authorization_code"

View File

@ -1165,7 +1165,7 @@ RedmineApp::Application.routes.draw do
collection do
get :login
post :bind
get :get_open_id
post :get_open_id
end
end

View File

@ -20,8 +20,9 @@ $(function(){
}
var code = getUrlParam("code");
$.ajax({
url: '/wechat/get_open_id?code='+code,
type: 'get',
url: '/wechat/get_open_id',
data: {code: code},
type: 'post',
dataType: 'json',
success: function(data){
g_openid = data.openid;