modal.js 1.5 KB

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