util.js 883 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* 常用工具函数 */
  2. export const msg = (title, duration = 1500, mask = true, icon = 'none') => {
  3. //统一提示方便全局修改
  4. if (Boolean(title) === false) {
  5. return
  6. }
  7. uni.showToast({
  8. title,
  9. duration,
  10. mask,
  11. icon
  12. })
  13. }
  14. export const modal = (title, content, confirmText, cancelText, showCancel = false, callBack) => {
  15. uni.showModal({
  16. title,
  17. content,
  18. confirmText,
  19. cancelText,
  20. confirmColor: '#E15616',
  21. showCancel,
  22. success: function(res) {
  23. if (res.confirm) {
  24. callBack()
  25. }
  26. }
  27. })
  28. }
  29. export const json = type => {
  30. //模拟异步请求数据
  31. return new Promise(resolve => {
  32. setTimeout(() => {
  33. // console.log(resolve+'======='+type);
  34. resolve(Json[type])
  35. }, 500)
  36. })
  37. }
  38. export const prePage = () => {
  39. let pages = getCurrentPages()
  40. let prePage = pages[pages.length - 2]
  41. // #ifdef H5
  42. return prePage
  43. // #endif
  44. return prePage.$vm
  45. }