(function (app) {
    app.factory('userService', ['$http', 'config', "util", 'storage', function ($http, config, util, storage) {
        return {
            login: function (phone, verify_code) {
                return $http({
                    url: config.server + 'api/auth/login',
                    method: "post",
                    data: { phone: phone, verify_code: verify_code}
                })
            },
            getVerifyCode:function (mobile) {
                return $http({
                    url: config.server + 'api/auth/code',
                    method: "post",
                    data: { phone: mobile}
                })
            },

            isLogin: function () {
             return !util.empty(storage.get("token")) && storage.getObject("user");
            }
        };
    }]);
})(angular.module('app.services'));