util.js 803 B

12345678910111213141516171819202122232425262728293031323334
  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 getTypeSn = url => {
  15. let type_sn = ''
  16. if (url.indexOf('type_sn') != -1 && url.indexOf('bonusex') != -1) {
  17. let arr = url.split('&')
  18. arr.some(item => {
  19. if (item.indexOf('type_sn') != -1) {
  20. type_sn = item.split('=')[1]
  21. return true
  22. }
  23. })
  24. }
  25. return type_sn
  26. }
  27. module.exports = {
  28. getTypeSn: getTypeSn,
  29. formatTime: formatTime
  30. }