mrr.sj.front/pages/home/components/workOrderCard.vue

304 lines
6.3 KiB
Vue
Raw Normal View History

2026-03-25 13:29:04 +08:00
<template>
<view class="order-card" @click="goDetail">
<!-- 订单编号 -->
<view class="orderNumBox">
<view class="order-id white-space-nowrap">订单编号{{ dataItem.number }}</view>
<view class="stateText" :class="{
stateText2: dataItem.state > 4 && dataItem.state !== 7, // 排除已取消
stateText3: dataItem.state === 7 // 已取消状态单独处理
2026-05-06 13:25:33 +08:00
}" v-if="showState">
2026-03-25 13:29:04 +08:00
{{ stateText }}
</view>
</view>
<!-- 服务信息区域 -->
<view class="service-container" @click="$emit('goOrderDetail', dataItem)">
<image class="service-img" :src="photo[0]" mode="aspectFill"></image>
<view class="service-info">
<view class="topInfo">
<view class="price_title">
<view class="service-type white-space-nowrap">{{
2026-05-06 13:25:33 +08:00
dataItem.title
}}</view>
2026-03-25 13:29:04 +08:00
</view>
<view class="service-address">下单时间{{ dataItem.add_time }}</view>
</view>
<view class="service-price"><text style="font-size: 24rpx;"></text>{{ Number(dataItem.order_money) }}
</view>
</view>
</view>
<!-- 时间信息 -->
<view class="time-info"><text style="color:#999999 ;">服务时段</text>{{ useTime }}</view>
<!-- 操作按钮 -->
<view class="button-group" v-if="dataItem.state > 1 && dataItem.state < 5">
<view class="btn cancel-btn" v-if="dataItem.state == 2 || dataItem.state == 3" @click.stop="emitCancel">取消订单
</view>
<view class="btn accept-btn" @click.stop="emitAccept" v-if="dataItem.state == 2">接单</view>
<view class="btn accept-btn" @click.stop="emitStart" v-if="dataItem.state == 3">开始订单</view>
<view class="btn accept-btn" @click.stop="emitDone" v-if="dataItem.state == 4">完成订单</view>
</view>
</view>
</template>
<script>
2026-05-06 13:25:33 +08:00
export default {
name: "OrderCard",
props: {
dataItem: {
type: Object,
2026-03-25 13:29:04 +08:00
},
2026-05-06 13:25:33 +08:00
typeId: {
type: Number,
2026-03-25 13:29:04 +08:00
},
2026-05-06 13:25:33 +08:00
showState: {
type: Boolean,
default: true,
}
},
computed: {
photo() {
return this.dataItem.photo ? JSON.parse(this.dataItem.photo) : "";
},
useTime() {
const start = this.dataItem.reserve_start_time;
const end = this.dataItem.reserve_end_time;
if (!start || !end) return "未设置";
const startDate = new Date(start.replace(/-/g, '/'));
const endDate = new Date(end.replace(/-/g, '/'));
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) return "时间格式错误";
const pad = (n) => String(n).padStart(2, "0");
const fmt = (d) => `${pad(d.getMonth() + 1)}.${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
return `${fmt(startDate)}-${fmt(endDate)}`;
},
stateText() {
const textList = [
"",
"待支付",
"待接单",
"待开始",
"进行中",
"已完成",
"已评价",
"已取消",
];
return textList[this.dataItem.state];
},
},
methods: {
// 触发取消事件
emitCancel() {
this.$emit("cancel", this.dataItem);
},
// 触发接单事件
emitAccept() {
this.$emit("accept", this.dataItem);
},
emitStart() {
this.$emit("start", this.dataItem);
},
emitDone() {
this.$emit("done", this.dataItem);
2026-03-25 13:29:04 +08:00
},
2026-05-06 13:25:33 +08:00
goDetail() {
this.$emit("goDetail", this.dataItem);
},
emitGoPay() {
this.$emit("goPay", this.dataItem);
},
emitRefund() {
this.$emit("goRefund", this.dataItem);
}
},
};
2026-03-25 13:29:04 +08:00
</script>
<style lang="less" scoped>
2026-05-06 13:25:33 +08:00
.order-card {
position: relative; // 必须加,确保父容器有定位
padding: 24rpx 20rpx 0rpx;
margin: 0rpx 30rpx 20rpx 30rpx;
background-color: #fff;
border-radius: 12px;
/* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
}
.orderNumBox {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 40rpx;
.stateText {
font-weight: 400;
font-size: 26rpx;
2026-06-02 11:39:23 +08:00
color: #FF4767;
2026-05-06 13:25:33 +08:00
text-align: left;
font-style: normal;
position: absolute;
right: 0;
top: 0;
background-image: url("/static/images/icons/tabBj.png");
background-size: 100% auto;
background-position: center top;
background-repeat: no-repeat;
width: 128rpx;
height: 49rpx;
2026-03-25 13:29:04 +08:00
display: flex;
align-items: center;
2026-05-06 13:25:33 +08:00
justify-content: center;
2026-03-25 13:29:04 +08:00
}
2026-05-06 13:25:33 +08:00
.stateText2 {
background-image: url("/static/images/icons/tabBj2.png");
color: #333;
2026-03-25 13:29:04 +08:00
}
2026-05-06 13:25:33 +08:00
.stateText3 {
background-image: url("/static/images/icons/tabBj2.png");
color: #999999 !important;
2026-03-25 13:29:04 +08:00
}
2026-05-06 13:25:33 +08:00
}
/* 订单编号 */
.order-id {
width: 530rpx;
font-size: 28rpx;
color: #333333;
}
/* 服务信息容器 */
.service-container {
display: flex;
align-items: center;
padding-bottom: 24rpx;
border-bottom: 1px solid #f6f5f5;
width: 100%;
}
/* 服务图片 */
.service-img {
width: 172rpx;
height: 168rpx;
border-radius: 24rpx;
margin-right: 30rpx;
flex-shrink: 0;
}
/* 服务信息 */
.service-info {
display: flex;
flex-direction: column;
justify-content: space-between;
width: 100%;
height: 168rpx;
.topInfo {
2026-03-25 13:29:04 +08:00
display: flex;
flex-direction: column;
2026-05-06 13:25:33 +08:00
.price_title {
2026-03-25 13:29:04 +08:00
display: flex;
2026-05-06 13:25:33 +08:00
align-items: center;
justify-content: space-between;
margin-bottom: 20rpx;
.service-type {
font-weight: 500;
font-size: 30rpx;
color: #333333;
line-height: 34rpx;
max-width: 300rpx;
2026-03-25 13:29:04 +08:00
}
}
}
2026-05-06 13:25:33 +08:00
.service-price {
font-family: DINPro, DINPro;
font-weight: 500;
font-size: 36rpx;
2026-06-02 11:39:23 +08:00
color: #FF4767;
2026-03-25 13:29:04 +08:00
line-height: 34rpx;
text-align: left;
font-style: normal;
}
2026-05-06 13:25:33 +08:00
}
.service_subTitle {
font-size: 26rpx;
line-height: 26rpx;
color: #666666;
margin-top: 18rpx;
}
.service-address {
font-weight: 400;
font-size: 26rpx;
color: #999999;
line-height: 33rpx;
text-align: left;
font-style: normal;
}
/* 时间信息 */
.time-info {
font-weight: 400;
font-size: 26rpx;
color: #333333;
line-height: 34rpx;
text-align: left;
font-style: normal;
padding-bottom: 20rpx;
margin-top: 28rpx;
}
/* 按钮组 */
.button-group {
display: flex;
justify-content: flex-end;
gap: 30rpx;
padding-bottom: 30rpx;
}
/* 通用按钮样式 */
.btn {
white-space: nowrap;
width: 100rpx;
height: 32rpx;
display: flex;
align-items: center;
justify-content: center;
padding: 10px 20px;
border-radius: 64rpx;
// box-sizing: border-box;
//height: 64rpx;
//border-radius: 32rpx;
border: 2rpx solid #979797;
font-weight: 400;
font-size: 26rpx;
color: #333333;
line-height: 64rpx;
// padding: 0 28rpx;
}
/* 取消按钮 */
.cancel-btn {
border: 2rpx solid #979797;
color: #333333;
}
/* 接单按钮 */
.accept-btn {
2026-06-02 11:39:23 +08:00
border: 2rpx solid #FF4767;
color: #FF4767;
2026-05-06 13:25:33 +08:00
}
2026-03-25 13:29:04 +08:00
</style>