'use strict';

var angular = require('angular'),
  _ = require('jsUtil');
require('../modules');
require('../services/WarrantService');

angular
  .module('warrant')
  .controller('WarrantStatusCtrl', WarrantStatusCtrl);

function WarrantStatusCtrl($scope, WarrantService) {
  (function() {
    init();
  })();

  function init() {
    WarrantService.getWarrantStatus().then(function(warrant) {
      if(warrant.type === 'forever') { // 永久授权
        $scope.type = '永久授权型';
      } else if(warrant.type === 'brief'){
        $scope.type = '试用型';
        $scope.deadline = warrant.date;
      } else {
        $scope.type = '永久授权型'; // 获取失败的话，默认为永久授权类型
      }
    });
  }
}
