msgservice.js 2.7 KB

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