modal.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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(content, title) {
  29. uni.showModal({
  30. title: title || '系统提示',
  31. content: content,
  32. showCancel: false
  33. })
  34. },
  35. // 确认窗体
  36. confirm(content, title) {
  37. return new Promise((resolve, reject) => {
  38. uni.showModal({
  39. title: title || '系统提示',
  40. content: content,
  41. cancelText: '取消',
  42. confirmText: '确定',
  43. success: function(res) {
  44. resolve(res.confirm)
  45. }
  46. })
  47. })
  48. },
  49. // 提示信息
  50. showToast(option) {
  51. if (typeof option === "object") {
  52. uni.showToast(option)
  53. } else {
  54. uni.showToast({
  55. title: option,
  56. icon: "none",
  57. duration: 2500
  58. })
  59. }
  60. },
  61. // 打开遮罩层
  62. loading(content) {
  63. uni.showLoading({
  64. title: content,
  65. icon: 'none'
  66. })
  67. },
  68. // 关闭遮罩层
  69. closeLoading() {
  70. uni.hideLoading()
  71. }
  72. }