modal.plugins.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. export default {
  2. // 消息提示
  3. msg(content) {
  4. uni.showToast({
  5. title: content,
  6. icon: "none",
  7. });
  8. },
  9. // 错误消息
  10. msgError(content) {
  11. uni.showToast({
  12. title: content,
  13. icon: "error",
  14. });
  15. },
  16. // 成功消息
  17. msgSuccess(content) {
  18. uni.showToast({
  19. title: content,
  20. icon: "success",
  21. });
  22. },
  23. // 隐藏消息
  24. hideMsg(content) {
  25. uni.hideToast();
  26. },
  27. // 弹出提示
  28. alert(title, content) {
  29. uni.showModal({
  30. title: title,
  31. content: content,
  32. showCancel: false,
  33. mask: true,
  34. });
  35. },
  36. // 确认窗体
  37. confirm(content) {
  38. return new Promise((resolve, reject) => {
  39. uni.showModal({
  40. title: "系统提示",
  41. content: content,
  42. cancelText: "取消",
  43. confirmText: "确定",
  44. success: function (res) {
  45. if (res.confirm) {
  46. resolve(res.confirm);
  47. }
  48. },
  49. });
  50. });
  51. },
  52. // 确认窗体带输入框
  53. confirmInput(content,placeholderText) {
  54. return new Promise((resolve, reject) => {
  55. uni.showModal({
  56. title: content,
  57. editable: true,
  58. inputType: "text",
  59. placeholderText: placeholderText,
  60. cancelText: "取消",
  61. confirmText: "确定",
  62. success: function (res) {
  63. if (res.confirm) {
  64. resolve(res);
  65. }
  66. },
  67. });
  68. });
  69. },
  70. // 提示信息
  71. showToast(option) {
  72. if (typeof option === "object") {
  73. uni.showToast(option);
  74. } else {
  75. uni.showToast({
  76. title: option,
  77. icon: "none",
  78. duration: 2500,
  79. });
  80. }
  81. },
  82. // 打开遮罩层
  83. loading(content) {
  84. uni.showLoading({
  85. title: content,
  86. icon: "none",
  87. mask: true,
  88. });
  89. },
  90. // 关闭遮罩层
  91. closeLoading() {
  92. uni.hideLoading();
  93. },
  94. };