util.js 743 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. const formatTime = date => {
  2. const year = date.getFullYear()
  3. const month = date.getMonth() + 1
  4. const day = date.getDate()
  5. const hour = date.getHours()
  6. const minute = date.getMinutes()
  7. const second = date.getSeconds()
  8. return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
  9. }
  10. const formatNumber = n => {
  11. n = n.toString()
  12. return n[1] ? n : '0' + n
  13. }
  14. const startLoading = ()=>{
  15. wx.showLoading({
  16. title: '加载中...',
  17. })
  18. }
  19. const endLoading = ()=>{
  20. wx.hideLoading()
  21. }
  22. const myShowToast = (title) => {
  23. wx.showToast({
  24. title: title,
  25. icon: 'none',
  26. mask: true
  27. })
  28. }
  29. export default {
  30. formatTime,
  31. startLoading,
  32. endLoading,
  33. myShowToast
  34. }