modal.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const modal = {
  4. // 消息提示
  5. msg(content) {
  6. common_vendor.index.showToast({
  7. title: content,
  8. icon: "none"
  9. });
  10. },
  11. // 错误消息
  12. msgError(content) {
  13. common_vendor.index.showToast({
  14. title: content,
  15. icon: "error"
  16. });
  17. },
  18. // 成功消息
  19. msgSuccess(content) {
  20. common_vendor.index.showToast({
  21. title: content,
  22. icon: "success"
  23. });
  24. },
  25. // 隐藏消息
  26. hideMsg(content) {
  27. common_vendor.index.hideToast();
  28. },
  29. // 弹出提示
  30. alert(content) {
  31. common_vendor.index.showModal({
  32. title: "提示",
  33. content,
  34. showCancel: false
  35. });
  36. },
  37. // 确认窗体
  38. confirm(content) {
  39. return new Promise((resolve, reject) => {
  40. common_vendor.index.showModal({
  41. title: "系统提示",
  42. content,
  43. cancelText: "取消",
  44. confirmText: "确定",
  45. success: function(res) {
  46. if (res.confirm) {
  47. resolve(res.confirm);
  48. }
  49. }
  50. });
  51. });
  52. },
  53. // 提示信息
  54. showToast(option) {
  55. if (typeof option === "object") {
  56. common_vendor.index.showToast(option);
  57. } else {
  58. common_vendor.index.showToast({
  59. title: option,
  60. icon: "none",
  61. duration: 2500
  62. });
  63. }
  64. },
  65. // 打开遮罩层
  66. loading(content) {
  67. common_vendor.index.showLoading({
  68. title: content,
  69. icon: "none"
  70. });
  71. },
  72. // 关闭遮罩层
  73. closeLoading() {
  74. common_vendor.index.hideLoading();
  75. }
  76. };
  77. exports.modal = modal;