dialog.js 684 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. let dialog = {};
  2. /**
  3. * 封装模态框
  4. */
  5. dialog.showModal=(content,isShowCancel=true,title='提示',)=>{
  6. return new Promise((resolve,reject)=>{
  7. uni.showModal({
  8. title: title,
  9. content: content,
  10. showCancel:isShowCancel,
  11. success: (res)=>{
  12. if (res.confirm) {
  13. resolve(res)
  14. }
  15. }
  16. });
  17. })
  18. }
  19. dialog.showModalAndBack=(content)=>{
  20. uni.showModal({
  21. title: "提示",
  22. content: content,
  23. showCancel:false,
  24. success: (res)=>{
  25. if (res.confirm) {
  26. uni.navigateBack({
  27. delta:1
  28. })
  29. }
  30. }
  31. });
  32. }
  33. dialog.showLoading=(title='加载中...')=>{
  34. uni.showLoading({
  35. title
  36. })
  37. }
  38. export default dialog