'use strict';
require('../modules');
require('../../warrant/services/WarrantService');

/**
 * 授权信息过期提示
 */
var module = angular.module('notice.directives');

module.directive('sinoOutDeadline', function($state, WarrantService) {
  return {
    restrict: 'E',
    scope: true,
    templateUrl: 'views/notice/sinoOutDeadline.tpl.html',
    link: function(scope, element, attrs) {
      scope.title = attrs.outDeadlineTitle || '当前试用期已结束，请您及时购买授权！';

      scope.$watch(function() {
        return WarrantService.warrantStatus;
      }, function() {
        WarrantService.getIsOutDeadline().then(function(data) {
          scope.isOutDeadline = data;
        });
      });

      /**
       * 查看授权信息
       */
      scope.goToWarrantStatus = function() {
        $state.go('warrant');
      };

    }
  };
});
