msgservice.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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:1000
  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: 1000
  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: 1000
  27. };
  28. if (noBackdrop) n["noBackdrop"] = true;
  29. $ionicLoading.show(n);
  30. },
  31. hide: function () {
  32. $ionicLoading.hide()
  33. },
  34. loading: function (template) {
  35. $ionicLoading.show({
  36. template: '<ion-spinner class="nerve-loading"></ion-spinner>'
  37. });
  38. //超时退出
  39. setTimeout(function() {
  40. $ionicLoading.hide();
  41. }, 11000);
  42. },
  43. alert: function (title, template) {
  44. var o = {
  45. okText: "确定"
  46. };
  47. if (title && template) {
  48. o["title"] = title;
  49. o["template"] = template
  50. } else {
  51. o["title"] = title;
  52. o["cssClass"] = "pop-alert calm"
  53. }
  54. $ionicPopup.alert(o)
  55. },
  56. confirm: function (title, template, okText) {
  57. var n = {
  58. okText: okText || "确定",
  59. cancelText: "取消"
  60. };
  61. if (title && template) {
  62. n["title"] = title;
  63. n["template"] = template
  64. } else {
  65. n["title"] = title;
  66. n["cssClass"] = "pop-alert"
  67. }
  68. return $ionicPopup.confirm(n)
  69. }
  70. }
  71. }]);
  72. })(angular.module('app.services'));