提交
This commit is contained in:
1
package-lock.json
generated
1
package-lock.json
generated
@@ -10,6 +10,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.1",
|
"@element-plus/icons-vue": "^2.3.1",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
|
"dayjs": "^1.11.13",
|
||||||
"echarts": "^5.6.0",
|
"echarts": "^5.6.0",
|
||||||
"element-plus": "^2.4.4",
|
"element-plus": "^2.4.4",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.1",
|
"@element-plus/icons-vue": "^2.3.1",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
|
"dayjs": "^1.11.13",
|
||||||
"echarts": "^5.6.0",
|
"echarts": "^5.6.0",
|
||||||
"element-plus": "^2.4.4",
|
"element-plus": "^2.4.4",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
|||||||
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
||||||
import NProgress from 'nprogress'
|
import NProgress from 'nprogress'
|
||||||
import 'nprogress/nprogress.css'
|
import 'nprogress/nprogress.css'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
@@ -29,6 +30,9 @@ app.use(ElementPlus, {
|
|||||||
locale: zhCn,
|
locale: zhCn,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 全局注册dayjs
|
||||||
|
app.config.globalProperties.$dayjs = dayjs
|
||||||
|
|
||||||
// 应用初始化后检查用户状态
|
// 应用初始化后检查用户状态
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|
||||||
|
|||||||
@@ -467,6 +467,7 @@ import {
|
|||||||
Warning,
|
Warning,
|
||||||
Check
|
Check
|
||||||
} from '@element-plus/icons-vue'
|
} from '@element-plus/icons-vue'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
import { use } from 'echarts/core'
|
import { use } from 'echarts/core'
|
||||||
import { CanvasRenderer } from 'echarts/renderers'
|
import { CanvasRenderer } from 'echarts/renderers'
|
||||||
import { LineChart, PieChart } from 'echarts/charts'
|
import { LineChart, PieChart } from 'echarts/charts'
|
||||||
@@ -827,17 +828,17 @@ const getTransferTypeText = (type) => {
|
|||||||
const formatDateTime = (date) => {
|
const formatDateTime = (date) => {
|
||||||
if (!date) return ''
|
if (!date) return ''
|
||||||
|
|
||||||
// 尝试转换为日期对象
|
// 使用dayjs进行格式化
|
||||||
const dateObj = new Date(date)
|
const dayjsDate = dayjs(date)
|
||||||
|
|
||||||
// 检查是否为有效日期
|
// 检查是否为有效日期
|
||||||
if (isNaN(dateObj.getTime())) {
|
if (!dayjsDate.isValid()) {
|
||||||
// 如果不是有效日期,返回原文本
|
// 如果不是有效日期,返回原文本
|
||||||
return date
|
return date
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果是有效日期,进行格式化
|
// 如果是有效日期,进行格式化
|
||||||
return dateObj.toLocaleString('zh-CN')
|
return dayjsDate.format('YYYY-MM-DD HH:mm:ss')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -982,8 +983,8 @@ const updateChartOptions = () => {
|
|||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
data: chartData.value.commissionTrend.map(item => {
|
data: chartData.value.commissionTrend.map(item => {
|
||||||
const date = new Date(item.date)
|
const date = dayjs(item.date)
|
||||||
return `${date.getMonth() + 1}/${date.getDate()}`
|
return date.format('M/D')
|
||||||
}),
|
}),
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
fontSize: 10
|
fontSize: 10
|
||||||
|
|||||||
@@ -644,7 +644,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
formatDate(dateString) {
|
formatDate(dateString) {
|
||||||
return new Date(dateString).toLocaleString('zh-CN')
|
return this.$dayjs(dateString).format('YYYY-MM-DD HH:mm:ss')
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -654,24 +654,17 @@ export default {
|
|||||||
*/
|
*/
|
||||||
formatDeadline(dateString) {
|
formatDeadline(dateString) {
|
||||||
if (!dateString) return ''
|
if (!dateString) return ''
|
||||||
const date = new Date(dateString)
|
const date = this.$dayjs(dateString)
|
||||||
const now = new Date()
|
const now = this.$dayjs()
|
||||||
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate())
|
|
||||||
const targetDate = new Date(date.getFullYear(), date.getMonth(), date.getDate())
|
|
||||||
|
|
||||||
const timeStr = date.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' })
|
const timeStr = date.format('HH:mm')
|
||||||
|
|
||||||
if (targetDate.getTime() === today.getTime()) {
|
if (date.isSame(now, 'day')) {
|
||||||
return `今天${timeStr}`
|
return `今天${timeStr}`
|
||||||
} else if (targetDate.getTime() === today.getTime() + 24 * 60 * 60 * 1000) {
|
} else if (date.isSame(now.add(1, 'day'), 'day')) {
|
||||||
return `明天${timeStr}`
|
return `明天${timeStr}`
|
||||||
} else {
|
} else {
|
||||||
return date.toLocaleString('zh-CN', {
|
return date.format('MM-DD HH:mm')
|
||||||
month: '2-digit',
|
|
||||||
day: '2-digit',
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ import { ref, computed, onMounted } from 'vue'
|
|||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
import {
|
import {
|
||||||
ArrowLeft,
|
ArrowLeft,
|
||||||
ShoppingBag,
|
ShoppingBag,
|
||||||
@@ -272,13 +273,7 @@ const getPointsText = (type, points) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const formatDateTime = (date) => {
|
const formatDateTime = (date) => {
|
||||||
return new Date(date).toLocaleString('zh-CN', {
|
return dayjs(date).format('YYYY-MM-DD HH:mm:ss')
|
||||||
year: 'numeric',
|
|
||||||
month: '2-digit',
|
|
||||||
day: '2-digit',
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const viewOrder = (orderId) => {
|
const viewOrder = (orderId) => {
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ import { ref, reactive, computed, onMounted } from 'vue'
|
|||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
import {
|
import {
|
||||||
ArrowLeft,
|
ArrowLeft,
|
||||||
ShoppingBag,
|
ShoppingBag,
|
||||||
@@ -303,13 +304,7 @@ const getPointsText = (type, points) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const formatDateTime = (date) => {
|
const formatDateTime = (date) => {
|
||||||
return new Date(date).toLocaleString('zh-CN', {
|
return dayjs(date).format('YYYY-MM-DD HH:mm:ss')
|
||||||
year: 'numeric',
|
|
||||||
month: '2-digit',
|
|
||||||
day: '2-digit',
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const viewOrder = (orderId) => {
|
const viewOrder = (orderId) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user