common.js 549 B

12345678910111213141516171819202122232425262728293031
  1. import { DRIVER, ADMIN } from '@/config/constants'
  2. export const clone = (obj) => {
  3. return JSON.parse(JSON.stringify(obj))
  4. }
  5. export const validate = (field, message) => {
  6. if (!field || !field.trim()) {
  7. uni.showToast({
  8. title: message,
  9. icon: 'error',
  10. })
  11. return false
  12. }
  13. return true
  14. }
  15. export const showErr = (err) => {
  16. uni.showToast({
  17. title: err,
  18. icon: 'error'
  19. })
  20. }
  21. export const isDriver = () => {
  22. return getApp().globalData.userType === DRIVER
  23. }
  24. export const isAdmin = () => {
  25. return getApp().globalData.userType === ADMIN
  26. }