factory.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. starter.factory('CompManage', function ($http, $q, $filter, $ionicPlatform, $cordovaPreferences, cfg, formatFilter, global, Tool) {
  2. var complist = [];
  3. return {
  4. post_Register: function (data) {
  5. console.log(data)
  6. var url = formatFilter('{0}register/', cfg.api);
  7. return Tool.post(url, data);
  8. },
  9. post_Joinin: function (data) {
  10. var url = formatFilter('{0}joinin/', cfg.api);
  11. var deferred = $q.defer();
  12. $http.post(url, data).then(function (res) {
  13. deferred.resolve(res);
  14. },
  15. function (err) {
  16. deferred.reject(err);
  17. });
  18. return deferred.promise;
  19. },
  20. getUserAuditstatus: function (auditstatus, compid) {
  21. var url = formatFilter('{0}joinin/?auditstatus={1}&compid={2}', cfg.api, auditstatus, compid);
  22. return Tool.get(url);
  23. },
  24. auditUser: function (user, status, compid) {
  25. var url = formatFilter('{0}joinin/{1}/?status={2}&compid={3}', cfg.api, user.user_id, status, compid);
  26. return Tool.put(url);
  27. },
  28. get_Compdata: function () {
  29. var url = formatFilter('{0}comps/', cfg.api);
  30. return Tool.get(url, true, 'complist');
  31. },
  32. getComplist: function () {
  33. complist = Tool.getTempData('complist');
  34. return complist;
  35. },
  36. editComp: function (data) {
  37. var url = formatFilter('{0}comps/{1}/', cfg.api, data.id);
  38. return Tool.put(url, data);
  39. },
  40. post_authcheck: function (imid, compid) {
  41. var url = formatFilter('{0}authcheck/', cfg.api);
  42. var d = $filter('format')("imid={0}&compid={1}&password={2}", imid, compid, global.user.password);
  43. return Tool.post(url, d, false);
  44. },
  45. store_user: function () {
  46. var deferred = $q.defer();
  47. var user = angular.copy(global.user);
  48. user.cfg = {'api': global.api};
  49. $cordovaPreferences.store('user', ionic.Platform.isAndroid() ? JSON.stringify(user) : user)
  50. .success(function (value) {
  51. deferred.resolve(value);
  52. // alert("store Success: " + value);
  53. })
  54. .error(function (error) {
  55. deferred.reject(err);
  56. alert("store Error: " + error);
  57. });
  58. return deferred.promise;
  59. },
  60. leave_comp: function (compid) {
  61. var url = formatFilter('{0}comps/{1}/?type={2}', cfg.api, compid, "leave");
  62. var d = $filter('format')("imid={0}&compid={1}", global.user.im_usrid, compid);
  63. return Tool.put(url, d);
  64. },
  65. dismiss_comp: function (compid) {
  66. var url = formatFilter('{0}comps/{1}/?type={2}', cfg.api, compid, "dismiss");
  67. var d = $filter('format')("compid={0}", compid);
  68. return Tool.put(url, d);
  69. }
  70. };
  71. })