dlg.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //常用对话框
  2. export const success = (title : string, duration = 1500, mask = false) => {
  3. return toast(title, duration, mask, 'success');
  4. }
  5. export const toast = function (title : string, duration : number, mask : boolean, icon : any) {
  6. return new Promise((resolve, reject) => {
  7. uni.showToast({
  8. title, duration, mask, icon,
  9. success: res => {
  10. setTimeout(function () {
  11. resolve(res);
  12. }, duration);
  13. },
  14. fail: err => {
  15. reject(err)
  16. }
  17. });
  18. });
  19. }
  20. //获取 错误提示
  21. export const error = (title : string) => {
  22. let duration = 2000;
  23. let mask = false;
  24. return new Promise((resolve, reject) => {
  25. uni.showToast({
  26. title, duration, mask,
  27. icon: "none",
  28. success: res => {
  29. setTimeout(function () {
  30. resolve(res);
  31. }, duration);
  32. },
  33. fail: err => {
  34. reject(err)
  35. }
  36. });
  37. });
  38. }
  39. //顶部信息
  40. export const tip = (title : string) => {
  41. uni.showToast({
  42. title,
  43. position: 'top',
  44. duration: 1500,
  45. mask: false,
  46. icon: 'none'
  47. });
  48. }
  49. export default {
  50. success, toast, error, tip,
  51. }