diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 4228a5c7d..0713a48a3 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -19,11 +19,14 @@ module Mobile unless current_user #如果当前用户不存在 openid = session[:wechat_openid] - raise "请在微信中关注Trustie创新实践平台后再打开本页面" unless openid + raise "无法获取到openid,请在微信中打开本页面" unless openid us = UsersService.new #login mail password - user = us.register ({:login=>openid, :mail=>openid+"@163.com", + + login = openid[0..3]+"***"+openid.last + + user = us.register ({:login=>login, :mail=>login+"@163.com", :password=>"12345678", :password_confirmation=>"12345678", :should_confirmation_password => true}) raise user.errors.full_messages.first if user.new_record? UserWechat.create!( diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 3a0526a52..30e4cc1f9 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -27,8 +27,7 @@ module Mobile post 'wxbind' do openid = session[:wechat_openid] logger.debug "openid ============== #{openid}" - # raise "无法获取到openid,请在微信中打开本页面" unless openid - raise "请在微信中关注公众号'Trustie创新实践平台'后再打开本页面" unless openid + raise "无法获取到openid,请在微信中打开本页面" unless openid uw = UserWechat.where(openid: openid).first raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw @@ -56,8 +55,7 @@ module Mobile post do openid = session[:wechat_openid] logger.debug "openid ============== #{openid}" - # raise "无法获取到openid,请在微信中打开本页面" unless openid - raise "请在微信中关注Trustie创新实践平台后再打开本页面" unless openid + raise "无法获取到openid,请在微信中打开本页面" unless openid uw = UserWechat.where(openid: openid).first if uw diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 5c2b0bade..75ac7aba5 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -424,7 +424,13 @@ class WechatsController < ActionController::Base session[:wechat_openid] = open_id if params[:code] - redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}&userid=#{params[:userid]}" and return + if params[:userid] + redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}&userid=#{params[:userid]}" and return + elsif params[:id] + redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return + else + redirect_to "/wechat/user_activities##{@path}" and return + end end # end render 'wechats/user_activities', layout: nil diff --git a/public/javascripts/wechat/controllers/project.js b/public/javascripts/wechat/controllers/project.js index d1a641546..3c487eeb5 100644 --- a/public/javascripts/wechat/controllers/project.js +++ b/public/javascripts/wechat/controllers/project.js @@ -117,7 +117,8 @@ app.controller('ProjectController', ['$scope', 'config','$http','$timeout', 'aut rms.save("project_activities",vm.project_activities); rms.save('project_has_more', vm.project_has_more); rms.save("project",vm.project); - $location.path('/'+type+'/'+act_id); +// $location.path('/'+type+'/'+act_id); + $location.path("/"+type).search({id: act_id}); }; //切换 按钮