12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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 + '日';
- }
- var formatDate2 = function (datetime) {
- var time = datetime * 1
- var date = getDate(time);
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var day = date.getDate();
- var tf = function (i) {
- return (i < 10 ? '0' : '') + i
- };
- var hour = tf(date.getHours());
- var minute = tf(date.getMinutes());
- return year + '-' + month + '-' + day + ' ' + hour + ':' + minute;
- }
- 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,
- formatDate2: formatDate2,
- gradeFilter: gradeFilter,
- numFilter: numFilter
- }
|