mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-12 12:26:44 +08:00
提交时间的格式化处理
This commit is contained in:
@@ -156,6 +156,29 @@ export function formatDate(date){
|
||||
|
||||
}
|
||||
|
||||
export function formatDateByFmt(date,fmt) {
|
||||
if(/(y+)/.test(fmt)){
|
||||
fmt = fmt.replace(RegExp.$1,(date.getFullYear()+'').substr(4-RegExp.$1.length));
|
||||
}
|
||||
let o = {
|
||||
'M+':date.getMonth() + 1,
|
||||
'd+':date.getDate(),
|
||||
'h+':date.getHours(),
|
||||
'm+':date.getMinutes(),
|
||||
's+':date.getSeconds()
|
||||
};
|
||||
|
||||
// 遍历这个对象
|
||||
for(let k in o){
|
||||
if(new RegExp(`(${k})`).test(fmt)){
|
||||
// console.log(`${k}`)
|
||||
let str = o[k] + '';
|
||||
fmt = fmt.replace(RegExp.$1,(RegExp.$1.length===1)?str:('00'+str).substr(str.length));
|
||||
}
|
||||
}
|
||||
return fmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把日期格式化为显示时间,yyyy-MM-dd
|
||||
* @param {Object} date
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
|
||||
<div class="couresstartTime">
|
||||
<div v-if="cinfo.type == 30">
|
||||
<span v-if="startTime">授课时间:{{ cinfo.startTime }}</span>
|
||||
<span v-if="cinfo.startTime">授课时间:{{ cinfo.startTime }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -321,7 +321,7 @@ import scene from "@/api/modules/scene.js";
|
||||
import apiUserGroup from "@/api/modules/usergroup.js";
|
||||
import interactBar from "@/components/Portal/interactBar.vue";
|
||||
import courseImage from "@/components/Course/courseImage.vue";
|
||||
import { courseType, getType, toScore,formatDate,formatUserNumber } from "@/utils/tools.js";
|
||||
import { courseType, getType, toScore,formatDate,formatUserNumber,formatDateByFmt } from "@/utils/tools.js";
|
||||
import { deepClone, param } from "../../../utils";
|
||||
import apiSearchterm from "@/api/modules/searchterm.js";
|
||||
import apiPlace from "@/api/phase2/place.js"
|
||||
@@ -806,6 +806,11 @@ export default {
|
||||
}
|
||||
},
|
||||
async search() {
|
||||
//测试时间格式化
|
||||
// let s=1650973801;
|
||||
// var d = new Date(1650973801*1000);
|
||||
// console.log(formatDateByFmt(d,'yyyy-MM-dd hh:mm'),'data');
|
||||
|
||||
let that = this;
|
||||
if (this.keyword) {
|
||||
apiSearchterm.save({ keyword: this.course.keyword, type: 1 });
|
||||
@@ -857,9 +862,10 @@ export default {
|
||||
res.result.list.forEach(item => {
|
||||
// item.startTime
|
||||
if(item.startTime != '') {
|
||||
let time = item.startTime.split('-');
|
||||
item.startTime = `${time[0]}年${time[1]}月${time[2]}日`
|
||||
}
|
||||
item.startTime=formatDateByFmt(new Date(item.startTime*1000),'yyyy-MM-dd hh:mm')
|
||||
//let time = item.startTime.split('-');
|
||||
//item.startTime = `${time[0]}年${time[1]}月${time[2]}日`
|
||||
}
|
||||
//教师转化
|
||||
if(item.teacher){
|
||||
let dotIdx=item.teacher.indexOf(',');
|
||||
|
||||
Reference in New Issue
Block a user