util.js 876 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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 simleInfo = msg => {
  15. wx.showModal({
  16. title: '提示',
  17. content: msg,
  18. showCancel: false,
  19. success(res) {
  20. }
  21. })
  22. }
  23. const simleInfoWithBack = msg => {
  24. wx.showModal({
  25. title: '提示',
  26. content: msg,
  27. showCancel: false,
  28. success(res) {
  29. wx.navigateBack({})
  30. }
  31. })
  32. }
  33. module.exports = {
  34. simleInfo: simleInfo,
  35. simleInfoWithBack: simleInfoWithBack,
  36. formatNumber: formatNumber,
  37. formatTime: formatTime,
  38. }