1234567891011121314151617181920212223242526272829303132333435363738394041 |
- var formatNumber = function (n) {
- n = n.toString()
- return n[1] ? n : '0' + n
- }
- /**
- * 将时间戳(1570550400)格式转为 yyyy-MM-dd格式
- */
- var formatDate = function (datetime) {
- var time = datetime * 1
- var date = getDate(time);
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var day = date.getDate();
- return year + '年' + month + '月' + day + '日';
- }
- function gradeFilter(grade) {
- if (!grade) {
- return '暂无'
- }
- var gradeObj = {
- "PRIMARY_FIRST_GRADE": "一年级",
- "PRIMARY_SECOND_GRADE": "二年级",
- "PRIMARY_THREE_GRADE": "三年级",
- "PRIMARY_SENIOR_GRADE": "四年级",
- "PRESCHOOL": "学前班",
- }
- return gradeObj[grade]
- }
- // 数字满万补w
- function numFilter(num) {
- if (!num || num < 10000) {
- return num
- }
- return Math.floor(num / 100) / 100 + 'w'
- }
- module.exports = {
- formatDate: formatDate,
- gradeFilter: gradeFilter,
- numFilter: numFilter
- }
|