modal.plugins.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. showToast(option) {
  54. if (typeof option === "object") {
  55. uni.showToast(option);
  56. } else {
  57. uni.showToast({
  58. title: option,
  59. icon: "none",
  60. duration: 2500,
  61. });
  62. }
  63. },
  64. // 打开遮罩层
  65. loading(content) {
  66. uni.showLoading({
  67. title: content,
  68. icon: "none",
  69. mask: true,
  70. });
  71. },
  72. // 关闭遮罩层
  73. closeLoading() {
  74. uni.hideLoading();
  75. },
  76. };