modal.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const modal = {
  4. /**
  5. * 消息提示
  6. * @param content 消息内容
  7. */
  8. msg(content) {
  9. common_vendor.index.showToast({
  10. title: content,
  11. icon: "none"
  12. });
  13. },
  14. /**
  15. * 错误消息
  16. * @param content 消息内容
  17. */
  18. msgError(content) {
  19. common_vendor.index.showToast({
  20. title: content,
  21. icon: "error"
  22. });
  23. },
  24. /**
  25. * 成功消息
  26. * @param content 消息内容
  27. */
  28. msgSuccess(content) {
  29. common_vendor.index.showToast({
  30. title: content,
  31. icon: "success"
  32. });
  33. },
  34. /**
  35. * 隐藏消息
  36. */
  37. hideMsg() {
  38. common_vendor.index.hideToast();
  39. },
  40. /**
  41. * 弹出提示
  42. * @param content 提示内容
  43. */
  44. alert(content) {
  45. common_vendor.index.showModal({
  46. title: "提示",
  47. content,
  48. showCancel: false
  49. });
  50. },
  51. /**
  52. * 确认窗体
  53. * @param content 提示内容
  54. * @returns
  55. */
  56. confirm(content) {
  57. return new Promise((resolve, reject) => {
  58. common_vendor.index.showModal({
  59. title: "系统提示",
  60. content,
  61. cancelText: "取消",
  62. confirmText: "确定",
  63. success: function(res) {
  64. if (res.confirm) {
  65. resolve(res.confirm);
  66. }
  67. }
  68. });
  69. });
  70. },
  71. /**
  72. * 提示信息
  73. * @param option 提示内容或者提示框配置
  74. */
  75. showToast(option) {
  76. if (typeof option === "object") {
  77. common_vendor.index.showToast(option);
  78. } else {
  79. common_vendor.index.showToast({
  80. title: option,
  81. icon: "none",
  82. duration: 2500
  83. });
  84. }
  85. },
  86. /**
  87. * 打开遮罩层,需要手动关闭遮罩层
  88. * @param content 遮罩层内容
  89. */
  90. loading(content) {
  91. common_vendor.index.showLoading({
  92. title: content
  93. });
  94. },
  95. /**
  96. * 关闭遮罩层
  97. */
  98. closeLoading() {
  99. common_vendor.index.hideLoading();
  100. }
  101. };
  102. exports.modal = modal;