util.js 574 B

12345678910111213141516171819202122232425262728
  1. function formatTime(date) {
  2. var year = date.getFullYear()
  3. var month = date.getMonth() + 1
  4. var day = date.getDate()
  5. var hour = date.getHours()
  6. var minute = date.getMinutes()
  7. var second = date.getSeconds()
  8. return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
  9. }
  10. function formatNumber(n) {
  11. n = n.toString()
  12. return n[1] ? n : '0' + n
  13. }
  14. module.exports = {
  15. formatTime: formatTime
  16. }
  17. const toastError = (content) => {
  18. wx.showToast({
  19. title: content,
  20. icon: 'none',
  21. duration: 3000
  22. })
  23. }