userservice.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. (function (app) {
  2. app.factory('userService', ['$http', 'config', "util", 'data', '$q', function ($http, config, util, data, $q) {
  3. return {
  4. login:function (username,password) {
  5. return $http({
  6. url: config.server + 'api/auth/login',
  7. method: "post",
  8. data: { phone: username, password: password }
  9. })
  10. },
  11. getVerifyCode: function (mobile) {
  12. return $http({
  13. url: config.server + 'api/auth/code?phone=' + mobile,
  14. method: "get"
  15. })
  16. },
  17. update:function (model) {
  18. return $http({
  19. url: config.server + 'api/user',
  20. method: "post",
  21. data: model
  22. })
  23. },
  24. register: function (model) {
  25. return $http({
  26. url: config.server + 'api/auth/register',
  27. method: "post",
  28. data: model
  29. })
  30. //return new Promise(function (resolve, reject) {
  31. // data.setObject('user', { mobile: model.mobile });
  32. // data.set('token', '111111');
  33. // resolve('ok');
  34. // // reject('654878');
  35. //});
  36. },
  37. getUser:function () {
  38. return $http({
  39. url: config.server + 'api/user',
  40. method: "get"
  41. })
  42. },
  43. isLogin: function () {
  44. return !util.empty(data.get("token")) && data.getObject("user");
  45. },
  46. //获取身份信息
  47. getApplyProfile: function () {
  48. return new Promise(function (resolve, reject) {
  49. resolve({});
  50. });
  51. },
  52. //身份信息
  53. saveApplyProfile: function (model) {
  54. return new Promise(function (resolve, reject) {
  55. resolve('ok');
  56. });
  57. },
  58. resetPassword: function (model) {
  59. return $http({
  60. url: config.server + 'api/auth/reset',
  61. method: "post",
  62. data: model
  63. })
  64. }
  65. };
  66. }]);
  67. })(angular.module('app.services'));