util.js 918 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const app = getApp()
  2. export default {
  3. loading (title) {
  4. wx.showLoading({
  5. title: title || '加载中...',
  6. mask: true
  7. })
  8. },
  9. errorToast (title) {
  10. wx.showToast({
  11. title: title || '请先登录',
  12. icon: 'error'
  13. })
  14. },
  15. navigateTo (url,permissionTitle) {
  16. if (url) {
  17. if (app.globalData.userInfo.login) {
  18. wx.navigateTo({
  19. url: 'url'
  20. })
  21. } else {
  22. wx.showToast({
  23. title: permissionTitle || '请先登录',
  24. icon: 'error'
  25. })
  26. }
  27. } else {
  28. wx.showToast({
  29. title: '地址错误',
  30. icon: 'error'
  31. })
  32. }
  33. },
  34. loginAuth () {
  35. return app.globalData.userInfo.login
  36. },
  37. // UUID
  38. getUUID () {
  39. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
  40. return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
  41. })
  42. }
  43. }