diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 9231bb77c..75fba6082 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -124,9 +124,11 @@ class WechatsController < ActionController::Base article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' end else + openid = request[:FromUserName] + puts wechat.user(request[:openid]) news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: login_wechat_path + article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: login_wechat_url end end end @@ -137,7 +139,7 @@ class WechatsController < ActionController::Base user, last_login_on = User.try_to_login(params[:username], params[:password]) raise "用户名或密码错误,请重新登录" unless user #补全用户信息 - puts wechat.user(request[:openid]) + user.user_wechat = UserWechat.new(openid: params[:openid]) user.save! rescue Exception=>e