modal.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(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. if (res.confirm) {
  45. resolve(res.confirm)
  46. } else {
  47. reject(res.confirm)
  48. }
  49. }
  50. })
  51. })
  52. },
  53. // 提示信息
  54. showToast(option) {
  55. if (typeof option === "object") {
  56. uni.showToast(option)
  57. } else {
  58. uni.showToast({
  59. title: option,
  60. icon: "none",
  61. duration: 2500
  62. })
  63. }
  64. },
  65. // 打开遮罩层
  66. loading(content) {
  67. uni.showLoading({
  68. title: content,
  69. icon: 'none'
  70. })
  71. },
  72. // 关闭遮罩层
  73. closeLoading() {
  74. uni.hideLoading()
  75. }
  76. }