|
|
@@ -69,8 +69,8 @@ define([ 'app/app' ], function(app) {
|
|
|
}]);
|
|
|
|
|
|
// 身份认证
|
|
|
- app.controller('AuthenticationCtrl', ['$scope', '$window', 'AuthenticationService', '$rootScope', 'SessionService', 'collectionService', '$modal', 'toaster','$q', 'Cart',
|
|
|
- function($scope, $window, AuthenticationService, $rootScope, SessionService, collectionService, $modal, toaster, $q, Cart) {
|
|
|
+ app.controller('AuthenticationCtrl', ['$scope', '$window', 'AuthenticationService', '$rootScope', 'SessionService', 'collectionService', '$modal', 'toaster','$q', 'Cart', '$http',
|
|
|
+ function($scope, $window, AuthenticationService, $rootScope, SessionService, collectionService, $modal, toaster, $q, Cart, $http) {
|
|
|
$scope.user = {
|
|
|
j_username : "",
|
|
|
j_password : "",
|
|
|
@@ -120,10 +120,34 @@ define([ 'app/app' ], function(app) {
|
|
|
location.href = './';
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
+ var Ajax={
|
|
|
+ get: function(url, fn) {
|
|
|
+ // XMLHttpRequest对象用于在后台与服务器交换数据
|
|
|
+ var xhr = new XMLHttpRequest();
|
|
|
+ xhr.open('GET', url, false);
|
|
|
+ xhr.onreadystatechange = function() {
|
|
|
+ // readyState == 4说明请求已完成
|
|
|
+ if (xhr.readyState == 4 && xhr.status == 200 || xhr.status == 304) {
|
|
|
+ // 从服务器获得数据
|
|
|
+ fn.call(this, xhr.responseText);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ xhr.send();
|
|
|
+ }
|
|
|
+ }
|
|
|
// 是否已经登录
|
|
|
$scope.isAuthed = AuthenticationService.isAuthed();
|
|
|
$scope.userInfo = {};
|
|
|
+ Ajax.get('/user/authentication',function(data) {
|
|
|
+ $scope.userInfo = data
|
|
|
+ })
|
|
|
+ // $http({
|
|
|
+ // method: 'get',
|
|
|
+ // url: '/user/authentication',
|
|
|
+ // dataType: 'json',
|
|
|
+ // }).success(function(data) {
|
|
|
+ // $scope.userInfo = data
|
|
|
+ // })
|
|
|
|
|
|
// 获取已登录的用户信息
|
|
|
var getAuthentication = function() {
|