Mike hace 7 años
padre
commit
981d23cb8a

+ 4 - 3
miaomiao/www/js/controllers/account.js

xqd xqd
@@ -5,9 +5,10 @@
             $scope.loginbywx = function(){
                 var scope = "snsapi_userinfo", state = "_" + (+new Date());
                 Wechat.auth(scope, state, function (response) {
-                    alert("response:"+JSON.stringify(response));
+                    // alert("response:"+JSON.stringify(response));
                     // response.code;
                     if(response.code){
+                        msg.loading('登录中...');
                         userService.loginbywx(response.code).then(function(result){
                             alert("loginbywx success: " + JSON.stringify(result));
                             msg.hide();
@@ -17,8 +18,8 @@
                             $scope.user=storage.getObject('user');
                             $state.go('app.home');
                         },function(error){
-                            alert("loginbywx Failed: " + JSON.stringify(error));
-                            $state.go("loginAccount",{wechat:$scope.wecaht})
+                            // alert("loginbywx Failed: " + JSON.stringify(error));
+                            $state.go("loginAccount",{wechat:response.code})
                             //window.location.href="#/account/loginAccount?wechat=$scope.wecaht";
                         });
                     }

+ 1 - 1
miaomiao/www/js/services/userservice.js

xqd
@@ -4,7 +4,7 @@
             loginbywx:function(wechat){
                 return $http({
                     url: config.server + 'api/auth/wechat_login',
-                    method: "post",
+                    method: "get",
                     data: { wechat: wechat}
                 })
             },

+ 1 - 1
server/routes/api.php

xqd
@@ -56,7 +56,7 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'auth.login',
         'uses' => 'AuthController@login',
     ]);
-    $api->post('auth/wechat_login', [
+    $api->get('auth/wechat_login', [
         'as' => 'auth.wechat_login',
         'uses' => 'AuthController@wechatLogin',
     ]);