工位订单日期时间显示修改
This commit is contained in:
parent
665ca23d3b
commit
659ec0f473
|
|
@ -45,7 +45,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "OrderCard",
|
name: "OrderCard",
|
||||||
props: {
|
props: {
|
||||||
dataItem: {
|
dataItem: {
|
||||||
|
|
@ -61,57 +61,18 @@
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
photo() {
|
photo() {
|
||||||
return this.dataItem.photo? JSON.parse(this.dataItem.photo):"";
|
return this.dataItem.photo ? JSON.parse(this.dataItem.photo) : "";
|
||||||
},
|
},
|
||||||
useTime() {
|
useTime() {
|
||||||
const start = this.dataItem.reserve_start_time;
|
const start = this.dataItem.reserve_start_time;
|
||||||
const endTime = this.dataItem.reserve_end_time;
|
const end = this.dataItem.reserve_end_time;
|
||||||
|
if (!start || !end) return "未设置";
|
||||||
function formatTimeRange(startTimeStr, endTimeStr) {
|
const startDate = new Date(start.replace(/-/g, '/'));
|
||||||
if (!startTimeStr || !endTimeStr) return "未设置";
|
const endDate = new Date(end.replace(/-/g, '/'));
|
||||||
|
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) return "时间格式错误";
|
||||||
// 解析开始时间为Date对象
|
const pad = (n) => String(n).padStart(2, "0");
|
||||||
const startTime = new Date(startTimeStr.replace(/-/g, '/'));
|
const fmt = (d) => `${pad(d.getMonth() + 1)}.${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
||||||
const endTime = new Date(endTimeStr.replace(/-/g, '/'));
|
return `${fmt(startDate)}-${fmt(endDate)}`;
|
||||||
|
|
||||||
if (isNaN(startTime.getTime()) || isNaN(endTime.getTime())) {
|
|
||||||
console.error("无效的时间格式");
|
|
||||||
return "时间格式错误";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 格式化年份:YYYY年
|
|
||||||
const formatYear = (date) => {
|
|
||||||
return date.getFullYear() + '年';
|
|
||||||
};
|
|
||||||
|
|
||||||
// 格式化月份和日期:MM月DD
|
|
||||||
const formatMonthDay = (date) => {
|
|
||||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
||||||
const day = String(date.getDate()).padStart(2, "0");
|
|
||||||
return `${month}月${day}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 格式化时间部分:HH:MM
|
|
||||||
const formatTimePart = (date) => {
|
|
||||||
const hours = String(date.getHours()).padStart(2, "0");
|
|
||||||
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
||||||
return `${hours}:${minutes}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 判断是否同一天
|
|
||||||
const isSameDay = startTime.getFullYear() === endTime.getFullYear() &&
|
|
||||||
startTime.getMonth() === endTime.getMonth() &&
|
|
||||||
startTime.getDate() === endTime.getDate();
|
|
||||||
|
|
||||||
if (isSameDay) {
|
|
||||||
// 同一天:2025年05月29 12:30-13:30
|
|
||||||
return `${formatYear(startTime)}${formatMonthDay(startTime)} ${formatTimePart(startTime)}-${formatTimePart(endTime)}`;
|
|
||||||
} else {
|
|
||||||
// 跨天:2025年05月29 12:30-2025年05月30 13:30
|
|
||||||
return `${formatYear(startTime)}${formatMonthDay(startTime)} ${formatTimePart(startTime)}-${formatYear(endTime)}${formatMonthDay(endTime)} ${formatTimePart(endTime)}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return formatTimeRange(start, endTime);
|
|
||||||
},
|
},
|
||||||
stateText() {
|
stateText() {
|
||||||
const textList = [
|
const textList = [
|
||||||
|
|
@ -152,20 +113,20 @@
|
||||||
this.$emit("goRefund", this.dataItem);
|
this.$emit("goRefund", this.dataItem);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.order-card {
|
.order-card {
|
||||||
position: relative; // 必须加,确保父容器有定位
|
position: relative; // 必须加,确保父容器有定位
|
||||||
padding: 24rpx 20rpx 0rpx;
|
padding: 24rpx 20rpx 0rpx;
|
||||||
margin: 0rpx 30rpx 20rpx 30rpx;
|
margin: 0rpx 30rpx 20rpx 30rpx;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
/* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
|
/* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
|
||||||
}
|
}
|
||||||
|
|
||||||
.orderNumBox {
|
.orderNumBox {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
@ -200,35 +161,35 @@
|
||||||
background-image: url("/static/images/icons/tabBj2.png");
|
background-image: url("/static/images/icons/tabBj2.png");
|
||||||
color: #999999 !important;
|
color: #999999 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 订单编号 */
|
/* 订单编号 */
|
||||||
.order-id {
|
.order-id {
|
||||||
width: 530rpx;
|
width: 530rpx;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 服务信息容器 */
|
/* 服务信息容器 */
|
||||||
.service-container {
|
.service-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-bottom: 24rpx;
|
padding-bottom: 24rpx;
|
||||||
border-bottom: 1px solid #f6f5f5;
|
border-bottom: 1px solid #f6f5f5;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 服务图片 */
|
/* 服务图片 */
|
||||||
.service-img {
|
.service-img {
|
||||||
width: 172rpx;
|
width: 172rpx;
|
||||||
height: 168rpx;
|
height: 168rpx;
|
||||||
border-radius: 24rpx;
|
border-radius: 24rpx;
|
||||||
margin-right: 30rpx;
|
margin-right: 30rpx;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 服务信息 */
|
/* 服务信息 */
|
||||||
.service-info {
|
.service-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
@ -267,28 +228,28 @@
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.service_subTitle {
|
.service_subTitle {
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
line-height: 26rpx;
|
line-height: 26rpx;
|
||||||
color: #666666;
|
color: #666666;
|
||||||
margin-top: 18rpx;
|
margin-top: 18rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.service-address {
|
.service-address {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: #999999;
|
color: #999999;
|
||||||
line-height: 33rpx;
|
line-height: 33rpx;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 时间信息 */
|
/* 时间信息 */
|
||||||
.time-info {
|
.time-info {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
|
|
@ -297,18 +258,18 @@
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
padding-bottom: 20rpx;
|
padding-bottom: 20rpx;
|
||||||
margin-top: 28rpx;
|
margin-top: 28rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 按钮组 */
|
/* 按钮组 */
|
||||||
.button-group {
|
.button-group {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
gap: 30rpx;
|
gap: 30rpx;
|
||||||
padding-bottom: 30rpx;
|
padding-bottom: 30rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 通用按钮样式 */
|
/* 通用按钮样式 */
|
||||||
.btn {
|
.btn {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
width: 100rpx;
|
width: 100rpx;
|
||||||
height: 32rpx;
|
height: 32rpx;
|
||||||
|
|
@ -327,17 +288,17 @@
|
||||||
line-height: 64rpx;
|
line-height: 64rpx;
|
||||||
// padding: 0 28rpx;
|
// padding: 0 28rpx;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 取消按钮 */
|
/* 取消按钮 */
|
||||||
.cancel-btn {
|
.cancel-btn {
|
||||||
border: 2rpx solid #979797;
|
border: 2rpx solid #979797;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 接单按钮 */
|
/* 接单按钮 */
|
||||||
.accept-btn {
|
.accept-btn {
|
||||||
border: 2rpx solid #E8101E;
|
border: 2rpx solid #E8101E;
|
||||||
color: #E8101E;
|
color: #E8101E;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Loading…
Reference in New Issue