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