'use strict';

var angular = require('angular');
require('../modules');
require('../services/SetUrlService');
require('../../login/services/LoginService');

var module = angular.module('initializeset');

/**
* 省份选择控制器
*/
module.controller('SetUrlSetCtrl', function($scope, SetUrlService, LoginService, $ionicActionSheet) {
  $scope.config = {
    canConfirm: true
  };

  $scope.confirm = function() { // 点击确定跳转到下个环节
    $ionicActionSheet.show({
      buttons: [{
        text: '<i class="icon ion-help sino-edit-province-icon"></i>是否确定切换服务器'
      }],
      cancelText: '取消',
      cancel: function() {
      },
      buttonClicked: function() {
        return SetUrlService.saveConfig($scope.config.selectItem)
          .then(SetUrlService.goNext)
          .then(LoginService.logout);
      }
    });
  };
});
