(function (app) {
    app.factory('userService', ['$http', 'config', "util", 'storage', function ($http, config, util, storage) {
        return {
            login:function (username,password) {
                return $http({
                    url: config.server + 'api/auth/login',
                    method: "post",
                    data: { phone: username, password: password, type:2 }
                })
            },
            register: function (data) {
                return $http({
                    url: config.server + 'api/auth/register',
                    method: "post",
                    data: data
                })
            },
           
            getVerifyCode:function (mobile) {
                return $http({
                    url: config.server + 'api/auth/code',
                    method: "post",
                    data: { phone: mobile, type:2}
                })
            },
            getRegisterCode:function (mobile) {
                return $http({
                    url: config.server + 'api/auth/code',
                    method: "post",
                    data: { phone: mobile, type:3}
                })
            },
            resetPassword: function (data) {
                return $http({
                    url: config.server + 'api/auth/reset',
                    method: "post",
                    data: data
                })
            },
            isLogin: function () {
                return $http({
                    url: config.server + 'api/auth/is_login',
                    method: "get",
                })
                // return !util.empty(storage.get("token")) && storage.getObject("user");
            } 
        };
    }]);
})(angular.module('app.services'));