From 0bb5c8b5fb14c9e852d3b7cf742791569add4a69 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 29 Jun 2016 21:09:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=BB=91=E5=AE=9A=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/users.rb | 12 ++++- app/views/wechats/user_activities.html.erb | 46 ++++++++++---------- public/assets/wechat/reg.html | 3 +- public/javascripts/wechat/controllers/reg.js | 11 +++-- 4 files changed, 43 insertions(+), 29 deletions(-) diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index b5ee14d19..a6536e73e 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -53,10 +53,20 @@ module Mobile requires :password, type: String, desc: 'password' end post do + + openid = session[:wechat_openid] + logger.debug "openid ============== #{openid}" + raise "无法获取到openid,请在微信中打开本页面" unless openid + + us = UsersService.new user = us.register params.merge(:password_confirmation => params[:password], :should_confirmation_password => true) - raise "该邮箱已经被注册过了" if user.new_record? + raise user.errors.full_messages.first if user.new_record? + UserWechat.create!( + openid: openid, + user: user + ) present :data, user, with: Mobile::Entities::User present :status, 0 diff --git a/app/views/wechats/user_activities.html.erb b/app/views/wechats/user_activities.html.erb index 1e3957ea9..7b7cb95e5 100644 --- a/app/views/wechats/user_activities.html.erb +++ b/app/views/wechats/user_activities.html.erb @@ -28,29 +28,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/assets/wechat/reg.html b/public/assets/wechat/reg.html index 9184fd0ed..c39eb1619 100644 --- a/public/assets/wechat/reg.html +++ b/public/assets/wechat/reg.html @@ -40,4 +40,5 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/reg.js b/public/javascripts/wechat/controllers/reg.js index dfa010ad7..44c2e098b 100644 --- a/public/javascripts/wechat/controllers/reg.js +++ b/public/javascripts/wechat/controllers/reg.js @@ -1,8 +1,9 @@ -app.controller('RegController', ['$scope', '$http', '$location', 'alertService', - function ($scope, $http, $location, alertService) { +app.controller('RegController', ['$scope', '$http', '$location', 'alertService','$location', + function ($scope, $http, $location, alertService, $location) { var vm = $scope; vm.errDialog = alertService.create(); + vm.successDialog = alertService.create(); vm.goLogin = function () { $location.path("/login"); @@ -32,10 +33,12 @@ app.controller('RegController', ['$scope', '$http', '$location', 'alertService', if (response.data.status != 0) { vm.errDialog.showMessage('出错了',response.data.message); } else { - vm.errDialog.showMessage("提示","注册且绑定微信成功"); + vm.successDialog.showMessage("提示","注册且绑定微信成功", function(){ + $location.path("/activities"); + }); } }, function (response) { - vm.errDialo.showMessage('出错了',response.data); + vm.errDialog.showMessage('出错了',response.data); }); }