From 622d71c47654b12f310a85231fe350b14ed2a4c5 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 27 May 2016 22:14:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E7=BB=91=E5=AE=9A=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E7=9A=84=EF=BC=8C=E7=9B=B4=E6=8E=A5=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 4 +++- app/views/wechats/login.html.erb | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 43bab082a..30a39e86e 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -162,7 +162,6 @@ class WechatsController < ActionController::Base code = params[:code] || session[:wechat_code] openid = get_openid_from_code(code) - raise "无法获取到微信openid" unless openid render :json => {status:0, openid: openid} rescue Exception=>e @@ -197,6 +196,9 @@ class WechatsController < ActionController::Base def login session[:wechat_code] = params[:code] if params[:code] + openid = get_openid_from_code(code) + @wechat_user = user_binded?(openid) + render 'wechats/login', layout: 'base_wechat' end diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index dc39b9f23..6de7b9bd8 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -1,4 +1,22 @@ +<% if @wechat_user %> +
+
+
+
+

操作成功

+

您已经绑定过微信了,用户名: (<%= @wechat_user.user.login %>)

+
+
+

+ 确定 +

+
+ +
+
+ +<% else %>

@@ -63,4 +81,7 @@ }) }); - \ No newline at end of file + + + +<% end %> \ No newline at end of file