Files
SmartParks_uniapp/pages/sys/user/myRepair/myRepair.vue

489 lines
11 KiB
Vue
Raw Normal View History

2025-07-24 16:00:29 +08:00
<template>
<view class="repair-container">
<!-- 可滚动内容区 -->
<scroll-view scroll-y class="repair-scroll-content" @scroll="handleScroll">
<!-- 空状态 -->
<view v-if="records.length === 0" class="repair-empty-box">
<view class="repair-empty-img-box">
<image src="/static/ic_my_repair_01.png" class="repair-empty-img" />
</view>
<view class="repair-add-btn-box">
<image src="/static/ic_my_repair_02.png" class="repair-add-btn" @click="addRepair" />
</view>
</view>
<!-- 有数据时 -->
<view v-else class="repair-list-box">
<view v-for="(item, idx) in records" :key="idx" class="repair-card" @click="showDetail(item)">
<view class="repair-row">
2025-07-27 15:52:39 +08:00
<view class="repair-no">工单号{{ item.orderNo }}</view>
<view class="repair-status" :class="getStatusColor(item.status)">
2025-08-08 11:31:41 +08:00
{{ getStatusLabel(item.status) }}
</view>
2025-07-24 16:00:29 +08:00
</view>
2025-07-27 15:52:39 +08:00
<image class="repair-line-image" src="/static/ic_my_repair_03.png" />
<view class="repair-info">建立时间{{ item.createTime }}</view>
<view class="repair-info">报事内容{{ item.typeName }}</view>
<view class="repair-info">报事位置{{ item.location }}</view>
2025-08-08 11:31:41 +08:00
<view v-if="getStatusLabel(item.status) === '已结束'" class="repair-eval-btn eval-btn-right">服务评价
</view>
2025-07-24 16:00:29 +08:00
</view>
<!-- 悬浮新增按钮 -->
2025-07-27 15:52:39 +08:00
<image src="/static/ic_my_repair_02.png" :class="['repair-add-btn-fixed', { 'hide': isAddBtnHidden }]"
@click="addRepair" />
2025-07-24 16:00:29 +08:00
</view>
</scroll-view>
<!-- 详情弹窗 -->
<view v-if="showDetailDialog" class="repair-detail-mask" @click.self="closeDetail">
<view class="repair-detail-dialog">
<view class="repair-detail-title">报事详情
<image src="/static/ic_close_01.png" class="repair-detail-close" @click.stop="closeDetail" />
</view>
<view class="repair-detail-progress-box">
<view class="repair-detail-progress">
<view v-for="(step, idx) in progressSteps" :key="idx" class="repair-detail-step">
2025-07-27 15:52:39 +08:00
<view
:class="['repair-detail-dot', detailStep >= idx ? 'active' : '', (detailStep === idx && detailStatus !== '已结束') ? 'current' : '']">
</view>
<view v-if="idx < progressSteps.length - 1"
:class="['repair-detail-line', detailStep > idx ? 'active' : '']"></view>
2025-07-24 16:00:29 +08:00
</view>
</view>
<view class="repair-detail-progress-labels">
2025-07-27 15:52:39 +08:00
<view v-for="(step, idx) in progressSteps" :key="idx" class="repair-detail-label">{{ step }}
</view>
2025-07-24 16:00:29 +08:00
</view>
</view>
2025-07-27 15:52:39 +08:00
<view class="repair-detail-info">建立时间{{ detailItem.createTime }}</view>
<view class="repair-detail-info">报事内容{{ detailItem.typeName }}</view>
<view class="repair-detail-info">报事位置{{ detailItem.location }}</view>
2025-08-08 11:31:41 +08:00
<button v-if="getStatusLabel(detailItem.status) === '已结束'" class="repair-detail-btn"
2025-07-27 15:52:39 +08:00
@click="goTEvaluate">评价服务</button>
2025-07-24 16:00:29 +08:00
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 空数组可切换空状态
2025-07-27 15:52:39 +08:00
records: [],
2025-07-24 16:00:29 +08:00
showDetailDialog: false,
detailItem: {},
detailStep: 0,
detailStatus: '',
2025-08-08 11:31:41 +08:00
progressSteps: ['创建工单', '已接单', '处理中', '已结束'],
2025-07-24 16:00:29 +08:00
lastScrollTop: 0,
isAddBtnHidden: false
}
},
2025-07-27 15:52:39 +08:00
onLoad() {
this.getOrders()
},
2025-08-08 11:31:41 +08:00
onShow() {
uni.$once('refreshData',s=> {
this.getOrders()
});
},
2025-07-24 16:00:29 +08:00
methods: {
goBack() {
uni.navigateBack();
},
addRepair() {
uni.navigateTo({
url: '/pages/sys/user/myRepair/addRepair'
});
},
2025-07-27 15:52:39 +08:00
async getOrders() {
2025-08-08 11:31:41 +08:00
let params = {
"type": "1952989217332658178"
}
let res = await this.$u.api.getOrderList(params);
2025-07-27 15:52:39 +08:00
if (res.code == '200') {
this.records = res.rows
}
},
getStatusColor(status) {
const statusMap = {
0: 'orange',
1: 'doing',
2: 'doing',
3: 'doing',
4: 'done'
};
return statusMap[status] || '';
},
2025-07-24 16:00:29 +08:00
showDetail(item) {
this.detailItem = item;
// 进度映射
2025-08-08 11:31:41 +08:00
if (item.status == 0) {
2025-07-27 15:52:39 +08:00
this.detailStep = 0;
2025-08-08 11:31:41 +08:00
this.detailStatus = '创建工单';
} else if (item.status == 4) {
2025-07-27 15:52:39 +08:00
this.detailStep = 3;
this.detailStatus = '已结束';
2025-08-08 11:31:41 +08:00
} else if (item.status == 3) {
2025-07-27 15:52:39 +08:00
this.detailStep = 2;
this.detailStatus = '处理中';
2025-08-08 11:31:41 +08:00
} else {
this.detailStep = 1;
this.detailStatus = '已接单';
2025-07-27 15:52:39 +08:00
}
2025-08-08 11:31:41 +08:00
2025-07-24 16:00:29 +08:00
this.showDetailDialog = true;
},
closeDetail() {
this.showDetailDialog = false;
},
2025-07-27 15:52:39 +08:00
getStatusLabel(status) {
const statusMap = {
0: '创建工单',
2025-08-08 11:31:41 +08:00
1: '已接单',
2: '已接单',
2025-07-27 15:52:39 +08:00
3: '处理中',
2025-08-08 11:31:41 +08:00
4: '已结束'
2025-07-27 15:52:39 +08:00
};
return statusMap[status] || '';
},
goTEvaluate() {
2025-08-08 11:31:41 +08:00
// 将detailItem转换为JSON字符串并进行编码以确保安全传输
const detailItemStr = encodeURIComponent(JSON.stringify(this.detailItem));
2025-07-24 16:00:29 +08:00
uni.navigateTo({
2025-08-08 11:31:41 +08:00
url: `/pages/sys/user/myRepair/repairEvaluate?detailItem=${detailItemStr}`
2025-07-24 16:00:29 +08:00
});
},
handleScroll(e) {
const scrollTop = e.detail.scrollTop;
// 为了避免过于频繁的触发,可以设置一个阈值
if (Math.abs(scrollTop - this.lastScrollTop) < 20) {
return;
}
if (scrollTop > this.lastScrollTop && scrollTop > 50) {
// 向下滚动,隐藏按钮
this.isAddBtnHidden = true;
} else {
// 向上滚动,显示按钮
this.isAddBtnHidden = false;
}
this.lastScrollTop = scrollTop;
}
}
}
</script>
<style scoped>
.repair-container {
height: 100vh;
background: #f7f7f7;
display: flex;
flex-direction: column;
}
.repair-navbar {
width: 100%;
height: 120rpx;
padding-top: 40rpx;
display: flex;
align-items: center;
justify-content: center;
position: relative;
background: #fff;
2025-07-27 15:52:39 +08:00
flex-shrink: 0;
/* 防止被压缩 */
2025-07-24 16:00:29 +08:00
}
.repair-back {
position: absolute;
left: 37rpx;
width: 15rpx;
height: 33rpx;
}
.repair-title {
font-size: 36rpx;
color: #000;
font-weight: 500;
}
.repair-scroll-content {
flex: 1;
overflow-y: auto;
padding-bottom: 40rpx;
}
.repair-empty-box {
margin: 48rpx 24rpx 0 24rpx;
position: relative;
}
.repair-empty-img-box {
border: 2rpx dashed #BDBDBD;
border-radius: 8rpx;
background: #fafbfc;
width: 100%;
min-height: 220rpx;
display: flex;
align-items: center;
justify-content: center;
}
.repair-empty-img {
width: 90%;
max-width: 400rpx;
height: 180rpx;
object-fit: contain;
margin: 24rpx auto;
}
.repair-add-btn-box {
position: absolute;
right: 24rpx;
bottom: -40rpx;
}
.repair-add-btn {
width: 80rpx;
height: 80rpx;
border: 2rpx dashed #BDBDBD;
border-radius: 50%;
background: #fff;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}
.repair-list-box {
margin: 32rpx 0 0 0;
padding: 0 24rpx;
position: relative;
}
.repair-card {
background: #fff;
border-radius: 12rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
padding-top: 25rpx;
padding-bottom: 32rpx;
}
.repair-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12rpx;
margin-top: 25rpx;
margin-left: 19rpx;
margin-right: 50rpx;
}
.repair-no {
font-size: 24rpx;
color: #0B0B0B;
font-weight: 500;
}
.repair-status {
font-size: 24rpx;
font-weight: 500;
}
2025-07-27 15:52:39 +08:00
.repair-line-image {
margin: left 29rpx;
2025-07-24 16:00:29 +08:00
margin-right: 39rpx;
height: 2rpx;
margin-bottom: 29rpx;
}
2025-07-27 15:52:39 +08:00
.repair-status.orange {
color: #F3AB44;
2025-07-24 16:00:29 +08:00
}
.repair-status.doing {
2025-07-27 15:52:39 +08:00
color: #00C9AA;
2025-07-24 16:00:29 +08:00
}
.repair-status.done {
2025-07-27 15:52:39 +08:00
color: #8A8A8A;
2025-07-24 16:00:29 +08:00
}
.repair-info {
font-size: 24rpx;
color: #888;
margin-bottom: 30rpx;
margin-left: 47rpx;
}
.repair-eval-btn {
margin-top: -20rpx;
margin-bottom: 0;
margin-left: auto;
margin-right: 44rpx;
display: flex;
justify-content: flex-end;
align-items: center;
padding: 0 18rpx;
height: 44rpx;
line-height: 44rpx;
border-radius: 8rpx;
border: 2rpx solid #2186FF;
color: #2186FF;
font-size: 24rpx;
background: #fff;
font-weight: 500;
width: fit-content;
}
.repair-add-btn-fixed {
position: fixed;
right: 40rpx;
bottom: 80rpx;
width: 100rpx;
height: 100rpx;
z-index: 100;
transition: transform 0.3s ease;
transform: translateX(0);
}
.repair-add-btn-fixed.hide {
transform: translateX(200%);
}
.repair-detail-mask {
position: fixed;
2025-07-27 15:52:39 +08:00
left: 0;
top: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.45);
2025-07-24 16:00:29 +08:00
z-index: 999;
display: flex;
align-items: flex-end;
justify-content: center;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-dialog {
width: 100vw;
background: #fff;
border-radius: 18rpx 18rpx 0 0;
2025-07-27 15:52:39 +08:00
box-shadow: 0 -2rpx 24rpx rgba(0, 0, 0, 0.10);
2025-07-24 16:00:29 +08:00
padding: 52rpx 56rpx 69rpx 56rpx;
margin-bottom: 0;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-title {
font-size: 36rpx;
color: #000;
text-align: center;
position: relative;
margin-bottom: 48rpx;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-close {
width: 32rpx;
height: 32rpx;
position: absolute;
right: 0;
top: 0;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-progress-box {
height: 107rpx;
margin-bottom: 41rpx;
background: #F7F7F7;
border-radius: 10rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: stretch;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-progress {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 5rpx;
2025-08-08 11:31:41 +08:00
margin-left: 75rpx;
2025-07-24 16:00:29 +08:00
width: 100%;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-step {
display: flex;
align-items: center;
flex: 1;
position: relative;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-dot {
width: 22rpx;
height: 22rpx;
border-radius: 50%;
background: #BDBDBD;
border: 2rpx solid #BDBDBD;
position: relative;
z-index: 2;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-dot.active {
background: #2186FF;
border-color: #2186FF;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-dot.current {
background: #EF8D00;
border-color: #EF8D00;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-line {
flex: 1;
height: 4rpx;
background: #BDBDBD;
margin: 0 2rpx;
z-index: 1;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-line.active {
background: #2186FF;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-progress-labels {
display: flex;
justify-content: space-between;
margin-left: 0;
width: 100%;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-label {
font-size: 22rpx;
color: #888;
text-align: center;
flex: 1;
position: relative;
top: 8rpx;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-info {
font-size: 26rpx;
color: #222;
margin-bottom: 30rpx;
}
2025-07-27 15:52:39 +08:00
2025-07-24 16:00:29 +08:00
.repair-detail-btn {
2025-07-27 15:52:39 +08:00
width: 445rpx;
2025-07-24 16:00:29 +08:00
height: 73rpx;
background: linear-gradient(90deg, #005DE9 0%, #4B9BFF 100%);
color: #fff;
font-size: 32rpx;
border: none;
border-radius: 30rpx;
margin-top: 32rpx;
font-weight: 600;
margin-top: 100rpx;
}
</style>
/* 让服务评价按钮靠右 */
.eval-btn-right {
2025-07-27 15:52:39 +08:00
margin-left: auto;
display: block;
width: fit-content;
2025-07-24 16:00:29 +08:00
}