factory.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. console.log(data)
  11. var url = formatFilter('{0}joinin/', cfg.api);
  12. return Tool.post(url, data);
  13. },
  14. getUserAuditstatus: function (auditstatus, compid) {
  15. var url = formatFilter('{0}joinin/?auditstatus={1}&compid={2}', cfg.api, auditstatus, compid);
  16. return Tool.get(url);
  17. },
  18. auditUser: function (user, status, compid) {
  19. var url = formatFilter('{0}joinin/{1}/?status={2}&compid={3}', cfg.api, user.user_id, status, compid);
  20. return Tool.put(url);
  21. },
  22. get_Compdata: function () {
  23. var url = formatFilter('{0}comps/', cfg.api);
  24. return Tool.get(url, true, 'complist');
  25. },
  26. getComplist: function () {
  27. complist = Tool.getTempData('complist');
  28. return complist;
  29. },
  30. editComp: function (data) {
  31. var url = formatFilter('{0}comps/{1}/', cfg.api, data.id);
  32. return Tool.put(url, data);
  33. },
  34. post_authcheck: function (imid, compid) {
  35. var url = formatFilter('{0}authcheck/', cfg.api);
  36. var d = $filter('format')("imid={0}&compid={1}&password={2}", imid, compid, global.user.password);
  37. return Tool.post(url, d, false);
  38. },
  39. store_user: function () {
  40. var deferred = $q.defer();
  41. var user = Tool.cloneObj(global.user);
  42. user.cfg = {'api': global.api};
  43. $cordovaPreferences.store('user', ionic.Platform.isAndroid() ? JSON.stringify(user) : user)
  44. .success(function (value) {
  45. deferred.resolve(value);
  46. // alert("store Success: " + value);
  47. })
  48. .error(function (error) {
  49. deferred.reject(err);
  50. alert("store Error: " + error);
  51. });
  52. return deferred.promise;
  53. },
  54. leave_comp: function (compid) {
  55. var url = formatFilter('{0}comps/{1}/?type={2}', cfg.api, compid, "leave");
  56. var d = $filter('format')("imid={0}&compid={1}", global.user.im_usrid, compid);
  57. return Tool.put(url, d);
  58. },
  59. dismiss_comp: function (compid) {
  60. var url = formatFilter('{0}comps/{1}/?type={2}', cfg.api, compid, "dismiss");
  61. var d = $filter('format')("compid={0}", compid);
  62. return Tool.put(url, d);
  63. }
  64. };
  65. })