filter.wxs 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var formatNumber = function (n) {
  2. n = n.toString()
  3. return n[1] ? n : '0' + n
  4. }
  5. /**
  6. * 将时间戳(1570550400)格式转为 yyyy-MM-dd格式
  7. */
  8. var formatDate = function (datetime) {
  9. var time = datetime * 1
  10. var date = getDate(time);
  11. var year = date.getFullYear();
  12. var month = date.getMonth() + 1;
  13. var day = date.getDate();
  14. return year + '年' + month + '月' + day + '日';
  15. }
  16. function gradeFilter(grade) {
  17. if (!grade) {
  18. return '暂无'
  19. }
  20. var gradeObj = {
  21. "PRIMARY_FIRST_GRADE": "一年级",
  22. "PRIMARY_SECOND_GRADE": "二年级",
  23. "PRIMARY_THREE_GRADE": "三年级",
  24. "PRIMARY_SENIOR_GRADE": "四年级",
  25. "PRESCHOOL": "学前班",
  26. }
  27. return gradeObj[grade]
  28. }
  29. // 数字满万补w
  30. function numFilter(num) {
  31. if (!num || num < 10000) {
  32. return num
  33. }
  34. return Math.floor(num / 100) / 100 + 'w'
  35. }
  36. module.exports = {
  37. formatDate: formatDate,
  38. gradeFilter: gradeFilter,
  39. numFilter: numFilter
  40. }