(function (app) {
    app.factory('userService', ['$http', 'config', "util",'data', function ($http, config, util,data) {
        return {
            login:function (username,password) {
                return $http({
                    url: config.server + 'api/auth/login',
                    method: "post",
                    data: { phone: username, password: password }
                })
            },
            getVerifyCode: function (mobile) {
                return new Promise(function (resolve, reject) {
                    resolve('123456');
                   // reject('654878');
                 });
            },
            register: function (model) {
                return $http({
                    url: config.server + 'api/auth/register',
                    method: "post",
                    data: model
                })
                //return new Promise(function (resolve, reject) {
                //    data.setObject('user', { mobile: model.mobile });
                //    data.set('token', '111111');
                //    resolve('ok');
                //    // reject('654878');
                //});
            },
            isLogin: function () {
                return !util.empty(data.get("token")) && data.getObject("user");
            },
            //获取身份信息
            getApplyProfile: function () {
                return new Promise(function (resolve, reject) {
                    resolve({});
                });
            },
            //身份信息
            saveApplyProfile: function (model) {
                return new Promise(function (resolve, reject) {
                    resolve('ok');
                });
            }
        };
    }]);
})(angular.module('app.services'));