Mike 7 jaren geleden
bovenliggende
commit
b03d370441
2 gewijzigde bestanden met toevoegingen van 24 en 30 verwijderingen
  1. 23 29
      miaomiao/www/js/controllers/my.js
  2. 1 1
      server/app/Http/Controllers/Api/V1/AuthController.php

+ 23 - 29
miaomiao/www/js/controllers/my.js

xqd xqd xqd
@@ -1,6 +1,6 @@
 (function (app) {
-    app.controller('myCtrl', ["$scope","$ionicTabsDelegate", "$state", "$http", "storage", "myService", "common", "config", "msg","$timeout"
-        , function ($scope,$ionicTabsDelegate, $state, $http, storage, myService, common, config, msg, $timeout) {
+    app.controller('myCtrl', ["$scope","$ionicTabsDelegate", "$state", "$http", "storage", "myService", "common", "config", "msg"
+        , function ($scope,$ionicTabsDelegate, $state, $http, storage, myService, common, config, msg) {
         $scope.$on('$ionicView.beforeEnter', function (viewResult) {
             $ionicTabsDelegate.showBar(true);
             myService.myInfo().then(function(result){ 
@@ -11,23 +11,35 @@
             common.setAvator().then(function (result) {
                 var response = JSON.parse(result.response);
                 console.log(response.data.file);
-                $timeout(function () {
-                    $scope.user.avatar = config.imgServer + response.data.file;
-                });
+                $scope.user.avatar = config.imgServer + response.data.file;
             });
         };
     }]);
-    app.controller('profileCtrl', ["$scope", "$timeout","$ionicTabsDelegate","$state","$filter", "storage", "myService", "msg", "common"
-      , function ($scope, $timeout, $ionicTabsDelegate, $state, $filter, storage, myService, msg, common) {
+    app.controller('profileCtrl', ["$scope","$ionicTabsDelegate","$state","$filter", "storage", "myService", "msg", "config", "common"
+      , function ($scope, $ionicTabsDelegate, $state, $filter, storage, myService, msg, config, common) {
             $scope.$on('$ionicView.beforeEnter', function () {
                 $ionicTabsDelegate.showBar(false);
+                msg.loading();
+                myService.myInfo().then(function(result){
+                  // alert(JSON.stringify(result.data.data));
+                  $scope.vm = result.data.data;
+                    console.log($scope.vm.avatar)
+                  $scope.vm.sex = $scope.vm.sex+'';
+                  $scope.vm.emotion = $scope.vm.emotion+'';
+                  if($scope.vm.birthday){
+                      var arr1 = $scope.vm.birthday.split("-");
+                      $scope.vm.birthday1 = new Date(arr1[0],parseInt(arr1[1])-1,arr1[2]); 
+                  }
+                  msg.hide();
+                },function(error){
+                  msg.hide();
+                  // msg.error(error.data.message);
+                })
             });
             $scope.setAvator = function () {
                 common.setAvator().then(function (result) {
                     var response = JSON.parse(result.response);
-                    $timeout(function () {
-                        $scope.user.avatar = config.imgServer + response.data.file;
-                    });
+                    $scope.vm.avatar = config.imgServer + response.data.file;
                 });
             };
           
@@ -41,25 +53,7 @@
                 tall:"",
                 nickname:"",
                 birthday1:""
-            };
-            $scope.$on('$ionicView.beforeEnter', function () {
-                msg.loading();
-                myService.myInfo().then(function(result){
-                  // alert(JSON.stringify(result.data.data));
-                  $scope.vm = result.data.data;
-                  $scope.vm.sex = $scope.vm.sex+'';
-                  $scope.vm.emotion = $scope.vm.emotion+'';
-                  if($scope.vm.birthday){
-                      var arr1 = $scope.vm.birthday.split("-");
-                      $scope.vm.birthday1 = new Date(arr1[0],parseInt(arr1[1])-1,arr1[2]); 
-                  }
-                  msg.hide();
-
-                },function(error){
-                  msg.hide();
-                  // msg.error(error.data.message);
-                })
-            });
+            }; 
  
             $scope.saveMaterial = function(){
                 var data = {

+ 1 - 1
server/app/Http/Controllers/Api/V1/AuthController.php

xqd
@@ -352,7 +352,7 @@ class AuthController extends Controller
             $result = array_shift($result);
         }
         if (is_string($result)) {
-            $user->avatar = config('app.url')."api/attachment/download/".$result;
+            $user->avatar = config('app.url')."/attachment/".$result;
             if (!$user->save()) {
                 return $this->error(ErrorCode::SAVE_USER_FAILED);
             }