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