From 79004e1328829288543d16ebb59752f55e708e3d Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 3 Mar 2016 23:27:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=91=E5=AE=9A=E6=B5=81?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 14 +++++++++----- config/menu.yml | 10 +++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 77c737359..ac744106a 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -24,7 +24,7 @@ class WechatsController < ActionController::Base end on :event, with: 'subscribe' do |request| - sendBind(request) + default_msg(request) end # When unsubscribe user scan qrcode qrscene_xxxxxx to subscribe in public account @@ -125,6 +125,10 @@ class WechatsController < ActionController::Base end on :click, with: 'MY_NEWS' do |request, key| + default_msg(req) + end + + def default_msg(request) uw = user_binded?(request[:FromUserName]) if uw && uw.user @@ -137,9 +141,9 @@ class WechatsController < ActionController::Base activity = process_activity(a) if activity news << {title: activity[0], - content: activity[1], - picurl: "#{i == 1 ? logo : 'https://www.trustie.net/'+activity[2]}", - url: activity[3] + content: activity[1], + picurl: "#{i == 1 ? logo : 'https://www.trustie.net/'+activity[2]}", + url: activity[3] } end @@ -172,7 +176,7 @@ class WechatsController < ActionController::Base raise "非法操作, code不存在" unless params[:code] openid = get_openid(params[:code]) raise "无法获取到openid" unless openid - raise "此微信号已绑定用户, 不能得复绑定" if UserWechat.where(openid: openid).first + raise "此微信号已绑定用户, 不能得复绑定" if user_binded?(openid) user, last_login_on = User.try_to_login(params[:username], params[:password]) raise "用户名或密码错误,请重新登录" unless user diff --git a/config/menu.yml b/config/menu.yml index 95bc50cc5..c88e94ec4 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -3,11 +3,11 @@ button: type: "click" name: "最新动态" key: "MY_NEWS" - - - type: "view" - name: "进入网站" - url: "http://www.trustie.net/" - type: "click" name: "意见返馈" - key: "FEEDBACK" \ No newline at end of file + key: "FEEDBACK" + - + type: "view" + name: "进入网站" + url: "http://www.trustie.net/" \ No newline at end of file