userservice.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. (function (app) {
  2. app.factory('userService', ['$http', 'config', "util", 'storage', function ($http, config, util, storage) {
  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, type:2 }
  9. })
  10. },
  11. register: function (data) {
  12. return $http({
  13. url: config.server + 'api/auth/register',
  14. method: "post",
  15. data: data
  16. })
  17. },
  18. getVerifyCode:function (mobile) {
  19. return $http({
  20. url: config.server + 'api/auth/code',
  21. method: "post",
  22. data: { phone: mobile, type:2}
  23. })
  24. },
  25. getRegisterCode:function (mobile) {
  26. return $http({
  27. url: config.server + 'api/auth/code',
  28. method: "post",
  29. data: { phone: mobile, type:3}
  30. })
  31. },
  32. resetPassword: function (data) {
  33. return $http({
  34. url: config.server + 'api/auth/reset',
  35. method: "post",
  36. data: data
  37. })
  38. },
  39. isLogin: function () {
  40. return $http({
  41. url: config.server + 'api/auth/is_login',
  42. method: "get",
  43. })
  44. // return !util.empty(storage.get("token")) && storage.getObject("user");
  45. }
  46. };
  47. }]);
  48. })(angular.module('app.services'));