msgservice.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. (function (app) {
  2. app.factory("msg", ["$ionicLoading", "$ionicPopup", "$timeout", function ($ionicLoading, $ionicPopup) {
  3. return {
  4. text: function (template, noBackdrop) {
  5. template = template || "";
  6. var n = {
  7. template: template,
  8. duration:2000
  9. };
  10. if (noBackdrop) n["noBackdrop"] = true;
  11. $ionicLoading.show(n);
  12. },
  13. success: function (template, noBackdrop) {
  14. template = template || "";
  15. var n = {
  16. template: '<i class="icon ion-ios-checkmark-outline pop-msg"></i><br>' + template,
  17. duration: 3000
  18. };
  19. if (noBackdrop) n["noBackdrop"] = true;
  20. $ionicLoading.show(n);
  21. },
  22. error: function (template, noBackdrop) {
  23. template = template || "";
  24. var n = {
  25. template: '<i class="icon ion-ios-close-outline pop-msg"></i><br>' + template,
  26. duration: 3000
  27. };
  28. if (noBackdrop) n["noBackdrop"] = true;
  29. $ionicLoading.show(n);
  30. },
  31. hide: function () {
  32. $ionicLoading.hide()
  33. },
  34. loading: function (template) {
  35. template = template || "正在加载数据...";
  36. $ionicLoading.show({
  37. template: '<ion-spinner class="nerve-loading"></ion-spinner><br>' + template
  38. })
  39. },
  40. alert: function (title, template) {
  41. var o = {
  42. okText: "确定"
  43. };
  44. if (title && template) {
  45. o["title"] = title;
  46. o["template"] = template
  47. } else {
  48. o["title"] = title;
  49. o["cssClass"] = "pop-alert"
  50. }
  51. $ionicPopup.alert(o)
  52. },
  53. confirm: function (title, template, okText) {
  54. var n = {
  55. okText: okText || "确定",
  56. cancelText: "取消"
  57. };
  58. if (title && template) {
  59. n["title"] = title;
  60. n["template"] = template
  61. } else {
  62. n["title"] = title;
  63. n["cssClass"] = "pop-alert"
  64. }
  65. return $ionicPopup.confirm(n)
  66. }
  67. }
  68. }]);
  69. })(angular.module('app.services'));