home.js 3.39 KB
(function(){
     angular.module("app.home")
        .controller("homeCtrl",["$scope","OptionService","UtilService","$interval","HttpService","$rootScope","ToolService","$interval",homeCtrl]);

    function homeCtrl($scope,OptionService,UtilService,$interval,HttpService,$rootScope,ToolService,$interval){
        //loading加载
        $scope.showLoading = function(){
            document.getElementById("sysLoad").style.display = "block";
        }
        $scope.hideLoading = function(){
            document.getElementById("sysLoad").style.display = "none";
        }

        var Uuser = UtilService.getUser();
        $scope.Homename = Uuser.email;
        if($scope.Homename == undefined || $scope.Homename == null){
            $scope.Homename = "";
        }
        $scope.HomeId = UtilService.getUser().id;
        if($scope.HomeId == undefined || $scope.HomeId == null){
            $scope.HomeId = "";
        }
        $scope.Logout = function(){
            HttpService.logOutCookie();
            window.location.href = "home.html";
        }
        $scope.goSet = function(){
            UtilService.setCookie("ryioHome",true);
            window.location.href = "index.html#/manage/userinfo";
        }

        $scope.HomeDemo = function(){
            UtilService.setCookie("ryioDemoapk",'e31caee07ebedf8c172267e73204802f',7);
            window.location.href = "demo.html";
        }

        $scope.channelMoreType = true;
        $scope.clickMore = function(){
            $scope.channelMoreType = false;
        }

        $scope.isSuper = UtilService.getCookie("ryioIsSuper")=='true' || UtilService.getCookie("ryioIsSuper")==true;
        var ryioRole = Uuser.roleCategory;
        if(ryioRole && ryioRole == 1){ //管理员
            $scope.isManage = true;
        }

        $scope.companyMoreType = true;
        $scope.companyMore = function(){
            $scope.companyMoreType = false;
        }
        $scope.UserEmail= Uuser.email;
        $scope.userNow = function(){
            var status = Uuser.status;
            var statusPM = HttpService.getInfo("reged/findbyemail?email="+$scope.UserEmail);
            ToolService.showLoading();
            statusPM.then(function(data){
                ToolService.hideLoading();
                if(data.status == 1){
                    if(data.appSize == 0 && data.isChannelPerson == true){
                        ToolService.showTips("没有控制权限");
                        $scope.time= 2000;
                        $one_minute = $interval(function(){
                            $scope.time -= 1000;
                            if($scope.time == 0){
                                window.location.href = "login.html";
                            }
                        },1000);
                    }else{
                        UUser.status = data.status;
                        UUser.pastDate = data.pastDate;
                        ToolService.setUser(UUser);
                        window.location.href = "index.html#/manage/app";
                    }
                }else{
                    UUser.status = data.status;
                    UUser.pastDate = data.pastDate;
                    ToolService.setUser(UUser);
                    window.location.href = "index.html#/active/product";
                }
            });
        }

        $scope.goApp = function(){
            window.location.href = "index.html#/manage/app";
        }
    }
})();