(function (app) { app.factory('userService', ['$http', 'config', "util", 'data', '$q', function ($http, config, util, data, $q) { return { login:function (username,password) { return $http({ url: config.server + 'api/auth/login', method: "post", data: { phone: username, password: password } }) }, getVerifyCode: function (mobile) { return $http({ url: config.server + 'api/auth/code?phone=' + mobile, method: "get" }) }, update:function (model) { return $http({ url: config.server + 'api/user', method: "post", data: model }) }, 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'); //}); }, getUser:function () { return $http({ url: config.server + 'api/user', method: "get" }) }, 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'); }); }, resetPassword: function (model) { return $http({ url: config.server + 'api/auth/reset', method: "post", data: model }) } }; }]); })(angular.module('app.services'));