(function(){
     angular.module("app.login")
        .controller("failureCtrl",["$scope","UtilService","$http","$interval","$location",failureCtrl]);

    function failureCtrl($scope,UtilService,$http,$interval,$location){
        //loading加载
        $scope.showLoading = function(){
            document.getElementById("sysLoad").style.display = "block";
        }
        $scope.hideLoading = function(){
            document.getElementById("sysLoad").style.display = "none";
        }
        $scope.hasReged = true;
        $scope.failureType =1;
        $scope.registerMessage = $location.search().message;
        $scope.registerFlag = $scope.registerMessage.substring(0,1);
        $scope.registerId = $scope.registerMessage.substring(1,100);
        $http.get("api/reged/find/"+$scope.registerId).success(function(data){
            $scope.registerEmail = data.content.email;
        });

        $scope.sendAgain = function(){
            $scope.failureType = 2;
        	$http.get("api/reged/sendeactivemail/"+$scope.registerId+"/"+$scope.registerFlag).success(function(data){
                $scope.hideLoading();
                if(data.content == "success"){
                    UtilService.setCookie("regId",$scope.registerId,7);
                    UtilService.setCookie("regFlag",$scope.registerFlag,7);
                    UtilService.setCookie("regEmail",$scope.registerEmail,7);
                    window.location.href = "activation.html";
                }
                else{
                    $scope.failureText = "重新激活发送失败";
                }
            });
           
        }
          
    }
})();