index.js 2.0 KB
Newer Older
Y
Your Name 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
(function() {
    'use strict';
    angular.module('eolinker')
        .config(['$stateProvider', 'RouteHelpersProvider', function($stateProvider, helper) {
            $stateProvider
                .state('index', {
                    url: '/',
                    auth: true,
                    template: '<login></login>'
                });
        }])
        .component('login', {
            templateUrl: 'app/ui/content/login/index.html',
            controller: indexController
        })

    indexController.$inject = ['$scope', 'CommonResource', '$state', 'CODE', 'md5', '$rootScope'];

    function indexController($scope, CommonResource, $state, CODE, md5, $rootScope) {

        var vm = this;
        vm.data = {
            submitted: false,
                password: {
                    isShow: false
                }
        }
        vm.ajaxRequest={
            loginCall: '',
            loginPassword: '',
            verifyCode: ''
        }
        vm.fun={};
        vm.fun.confirm = function() {
            var tmpAjaxRequest={
                loginCall: vm.ajaxRequest.loginCall,
                loginPassword: md5.createHash(vm.ajaxRequest.loginPassword||''),
            }
            if(tmpAjaxRequest.loginCall&&tmpAjaxRequest.loginPassword){
                CommonResource.Guest.Login(tmpAjaxRequest).$promise.then(function(response) {
                    switch (response.statusCode) {
                        case CODE.COMMON.SUCCESS:
                            {
                                window.localStorage.setItem('LOGINCALL', tmpAjaxRequest.loginCall);
                                $state.go('home.panel');
                                break;
                            }
                    }
                })
            }else{
                vm.data.submitted=true;
            }
            
        }
        vm.fun.changeView = function() {
            if (vm.ajaxRequest.loginPassword) {
                vm.data.password.isShow = !vm.data.password.isShow;
            }
        }
    }
})();