cancellationCtrl.js 1.84 KB
(function (angular) {
  function cancellationCtrl($scope, $rootScope, $window, systemService, $uibModal, $state,SweetAlertX) {
    $scope.loginUser = $rootScope.loginUser
    console.log($scope.loginUser)

    $scope.reasonList = [{'id':1,'text':'这是多余的账号'},{'id':2,'text':'暂不需要使用'},{'id':3,'text':'安全隐私考虑'}]
    $scope.agreeRemind = false
    $scope.next_two = false
    $scope.selected = []


    $scope.showDialog = function(){
      $uibModal.open({
          templateUrl: 'biz/system/view/cancellationRemind.html',
          controller: 'cancellationRemindCtrl',
          size: 'lg'
      })
    }

    $scope.next = function(){
      if($scope.next_two){
        if($scope.selected.length == 0){
          SweetAlertX.alert('请选择注销原因', '', 'info');
          return 
        }
        systemService.updateUserEnabledFlag({enabledFlag:'C'}, function(data) {
            if (data.returnCode == '0') {
              swal({type: 'success',title: '注销成功',text: '',showConfirmButton:true},function(){
                  $window.location.href = 'logout';
                  localStorageService.set('isLogout', true);
              });
            } else {
                SweetAlertX.alert(data.message,'注销失败','error');
            }
        });
      }else{
        if(!$scope.agreeRemind){
          SweetAlertX.alert('请阅读并同意勾选重要提醒', '', 'info');
        }else{
          $scope.next_two = true
        }
      }
    }

    $scope.changeReason = function(item){
      console.log(item);
      if(item.checked){
        $scope.selected.push(item.id);
      }else{
        var idx = $scope.selected.indexOf(item.id);
        $scope.selected.splice(idx, 1);
      }
      console.log($scope.selected)
    }

  }

  angular.module('system').controller('cancellationCtrl', cancellationCtrl)
})(angular);