|
|
@@ -1,6 +1,5 @@
|
|
|
define([ 'app/app' ], function(app) {
|
|
|
'use strict';
|
|
|
-
|
|
|
app.config(['$httpProvider', function($httpProvider) {
|
|
|
// 设置http拦截器
|
|
|
$httpProvider.interceptors.push('httpInterceptor');
|
|
|
@@ -48,22 +47,27 @@ 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('AuthCtrl', ['$scope', '$window', 'AuthenticationService', '$rootScope', 'SessionService', '$modal', 'toaster', '$http', 'BaseService',
|
|
|
+ function($scope, $window, AuthenticationService, $rootScope, SessionService, $modal, toaster, $http, BaseService) {
|
|
|
$scope.user = {
|
|
|
j_username : "",
|
|
|
j_password : "",
|
|
|
loginType : 'uu'
|
|
|
};
|
|
|
+ var rootPath = BaseService.getRootPath();
|
|
|
|
|
|
// 登录
|
|
|
$scope.login = function(user) {
|
|
|
- AuthenticationService.login(user).success(function(responseText, status) {
|
|
|
- if (status == 200) {
|
|
|
- }
|
|
|
- }).error(function(response) {
|
|
|
- toaster.pop('error', response);
|
|
|
- });
|
|
|
+ // AuthenticationService.login(user).success(function(responseText, status) {
|
|
|
+ // if (status == 200) {
|
|
|
+ // }
|
|
|
+ // }).error(function(response) {
|
|
|
+ // toaster.pop('error', response);
|
|
|
+ // });
|
|
|
+ AuthenticationService.redirectSignin();
|
|
|
+ // $.getJSON(rootPath + "/sso/login", {}, function (data) {
|
|
|
+ // window.location.href = data.content;
|
|
|
+ // })
|
|
|
};
|
|
|
|
|
|
// 退出
|
|
|
@@ -72,94 +76,31 @@ define([ 'app/app' ], function(app) {
|
|
|
SessionService.removeCookie($rootScope.userInfo.userUU);
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
- // 企业换企业开关
|
|
|
- $scope.toggleSwitch = function () {
|
|
|
- $scope.switching = !$scope.switching;
|
|
|
- };
|
|
|
-
|
|
|
- // 切换企业
|
|
|
- $scope.switchto = function(enUU) {
|
|
|
- AuthenticationService.reSignin(enUU).success(function(){
|
|
|
- $window.location.reload();
|
|
|
- });
|
|
|
- };
|
|
|
+ // $scope.logout = function () {
|
|
|
+ // $modal.open({
|
|
|
+ // templateUrl: 'static/view/common/logout.html',
|
|
|
+ // controller: 'LogOutCtrl'
|
|
|
+ // }).result.then(function (s) {
|
|
|
+ // if (s) {
|
|
|
+ // AuthenticationService.logout();
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // };
|
|
|
|
|
|
// 是否已经登录
|
|
|
$scope.isAuthed = AuthenticationService.isAuthed();
|
|
|
$scope.userInfo = {};
|
|
|
|
|
|
// 获取已登录的用户信息
|
|
|
- var getAuthentication = function() {
|
|
|
- return AuthenticationService.getAuthentication().success(function(data) {
|
|
|
- if(data && data.enterprises) {
|
|
|
- //data.enterprise = data.enterprises[data.enterprises.length - 1];
|
|
|
- if(data.enterprises.length > 1) {
|
|
|
- var enSelect = [];
|
|
|
- angular.forEach(data.enterprises, function(e){
|
|
|
- if(e.current)
|
|
|
- data.enterprise = e;
|
|
|
- else
|
|
|
- enSelect.push(e);
|
|
|
- });
|
|
|
- data.enSelect = enSelect;
|
|
|
- }
|
|
|
- }
|
|
|
- $scope.userInfo = data;
|
|
|
- // 增加收藏功能的代码
|
|
|
- $rootScope.userInfo = data;
|
|
|
- $rootScope.brandCount = 0;
|
|
|
- $rootScope.componentCount = 0;
|
|
|
- // 以用户的身份进入系统
|
|
|
- if(SessionService.get('authenticated')) {
|
|
|
- collectionService.getStoreByUU({}, function(data) {
|
|
|
- var store = [];
|
|
|
- var brandCount = 0;
|
|
|
- var componentCount = 0;
|
|
|
- for(var i = 0; i < data.length; i++) {
|
|
|
- if(data[i].kind == 1) {
|
|
|
- brandCount++;
|
|
|
- }else if (data[i].kind == 2){
|
|
|
- componentCount++;
|
|
|
- }
|
|
|
- store.push(data[i]);
|
|
|
- }
|
|
|
- $rootScope.brandCount = brandCount;
|
|
|
- $rootScope.componentCount = componentCount;
|
|
|
- SessionService.setCookie($rootScope.userInfo.enterprise ? $rootScope.userInfo.userUU +"-"+ $rootScope.userInfo.enterprise.uu : $rootScope.userInfo.userUU, angular.toJson(store));
|
|
|
- // 默认在登录界面游客收藏的数据已传输成功,删除游客的数据
|
|
|
- SessionService.removeCookie('visitor');
|
|
|
- }, function(response) {
|
|
|
- });
|
|
|
- }else { // 以游客身份登录系统
|
|
|
- // 获取本地的数据
|
|
|
- var arrs = angular.fromJson(SessionService.getCookie('visitor'));
|
|
|
- angular.forEach(arrs, function(store) {
|
|
|
- if(store.kind == 2) {
|
|
|
- $rootScope.componentCount++;
|
|
|
- }else {
|
|
|
- $rootScope.brandCount++;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- $scope.isAuthed = data != null && data.userUU;
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- //根据用户的信息
|
|
|
- $q.all([getAuthentication()]).then(function () {
|
|
|
- if(AuthenticationService.isAuthed()) {
|
|
|
- Cart.getCount({}, function(data){
|
|
|
- $rootScope.countCart = data.count;
|
|
|
- }, function(res){
|
|
|
- toaster.pop('error', '系统错误', '获取购物车失败');
|
|
|
- });
|
|
|
+ AuthenticationService.getAuthentication().success(function(data) {
|
|
|
+ if(data && data.content) {
|
|
|
+ $scope.userInfo = data.content;
|
|
|
+ console.log(data.content);
|
|
|
}
|
|
|
- }, function () {
|
|
|
+ $scope.isAuthed = data !== null && !angular.isUndefined(data.content);
|
|
|
});
|
|
|
|
|
|
- // 打开登录模态框
|
|
|
+ // 登录
|
|
|
$scope.signinModal = function() {
|
|
|
// var modalInstance = $modal.open({
|
|
|
// templateUrl : 'static/view/common/modal/signin.html',// 指向上面创建的视图
|
|
|
@@ -185,6 +126,15 @@ define([ 'app/app' ], function(app) {
|
|
|
};
|
|
|
}]);
|
|
|
|
|
|
+ /**
|
|
|
+ * 登出
|
|
|
+ */
|
|
|
+ app.controller('LogOutCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
|
|
+ $scope.close = function (confirm) {
|
|
|
+ $modalInstance.close(confirm);
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
// 登录模态框
|
|
|
app.controller('SigninModalCtrl', ['$scope', '$modalInstance', 'AuthenticationService', 'toaster', function($scope, $modalInstance, AuthenticationService, toaster) {
|
|
|
$scope.user = {
|
|
|
@@ -224,32 +174,19 @@ define([ 'app/app' ], function(app) {
|
|
|
};
|
|
|
}]);
|
|
|
|
|
|
- // 跳至顶部
|
|
|
- app.controller('ScrollToTopCtrl', ['$scope', 'SmoothScroll', 'toaster', 'CommonGoodsBrowsingHistory', 'AuthenticationService', function($scope, SmoothScroll, toaster, CommonGoodsBrowsingHistory, AuthenticationService){
|
|
|
- $scope.scrollToTop = function(){
|
|
|
- SmoothScroll.scrollTo(null, 'site-nav');
|
|
|
- };
|
|
|
-
|
|
|
- AuthenticationService.getAuthentication().success(function(data){
|
|
|
- $scope.userInfo = data;
|
|
|
- if(data){
|
|
|
- loadData();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- // // 获取浏览历史
|
|
|
- // var loadData = function(){
|
|
|
- // CommonGoodsBrowsingHistory.getAllHistory({ }, { }, function (response) {
|
|
|
- // $scope.inithistory = response;
|
|
|
- // $scope.history = [];
|
|
|
- // angular.forEach($scope.inithistory, function(data){
|
|
|
- // if(data.isDelete == 1){
|
|
|
- // $scope.history.push(data);
|
|
|
- // }
|
|
|
- // })
|
|
|
- // })
|
|
|
- // }
|
|
|
-
|
|
|
- }]);
|
|
|
-
|
|
|
+ // // 跳至顶部
|
|
|
+ // app.controller('ScrollToTopCtrl', ['$scope', 'SmoothScroll', 'toaster', 'CommonGoodsBrowsingHistory', 'AuthenticationService', function($scope, SmoothScroll, toaster, CommonGoodsBrowsingHistory, AuthenticationService){
|
|
|
+ // $scope.scrollToTop = function(){
|
|
|
+ // SmoothScroll.scrollTo(null, 'site-nav');
|
|
|
+ // };
|
|
|
+ //
|
|
|
+ // AuthenticationService.getAuthentication().success(function(data){
|
|
|
+ // $scope.userInfo = data;
|
|
|
+ // if(data){
|
|
|
+ // loadData();
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }]);
|
|
|
+
|
|
|
+ return app;
|
|
|
});
|