首页活动,报事报修评价
Some checks failed
Uniapp 自动化打包 CI/CD / 打包 Uniapp 项目 (push) Has been cancelled

This commit is contained in:
2025-09-09 17:21:35 +08:00
parent fb02715afb
commit 400e95c81b
7 changed files with 199 additions and 71 deletions

View File

@@ -71,14 +71,33 @@
this.selectedType = item;
},
async getOrderType() {
this.repairTypes = []
let params = {
parentId: '1952989217332658178'
}
let res = await this.$u.api.getRepairTypes(params);
let res = await this.$u.api.getRepairTypes2(params);
if (res.code == '200') {
this.repairTypes = res.data
this.repairInfo.type = res.data[0].id;
this.selectType(res.data[0].orderTypeName)
// 只处理前两条数据
const types = [];
const data = res.data.slice(0, 2); // 只取前两条数据
// 遍历前两个父级分类
data.forEach(parent => {
// 如果没有children或者children为空则添加父级数据
if (!parent.children || parent.children.length === 0) {
types.push(parent);
} else {
// 如果有children则添加所有children数据
types.push(...parent.children);
}
});
this.repairTypes = types;
if (this.repairTypes.length > 0) {
this.repairInfo.type = this.repairTypes[0].id;
this.selectType(this.repairTypes[0].orderTypeName)
}
}
},
// 删除图片
@@ -122,7 +141,7 @@
uni.showToast({
title: '上传失败',
icon: 'none'
});
});
uni.hideLoading();
return;
}
@@ -136,21 +155,21 @@
async realSubmit() {
let res = await this.$u.api.addOrder2(this.repairInfo);
if (res.code == '200') {
if (res.code == '200') {
uni.hideLoading();
// 关闭页面前发送事件通知前页面刷新
uni.$emit('refreshData', '');
// 返回上一页
uni.navigateBack();
const itemStr = encodeURIComponent(JSON.stringify(this.repairInfo));
uni.navigateTo({
url: "/pages/sys/user/myRepair/addSuc?item=" + itemStr,
uni.navigateBack();
const itemStr = encodeURIComponent(JSON.stringify(this.repairInfo));
uni.navigateTo({
url: "/pages/sys/user/myRepair/addSuc?item=" + itemStr,
});
}else{
uni.showToast({
title: res.msg,
icon: 'none'
});
}else{
uni.showToast({
title: res.msg,
icon: 'none'
});
}
},

View File

@@ -34,7 +34,7 @@
<view class="repair-info">建立时间{{ item.createTime }}</view>
<view class="repair-info">工单类型{{ item.typeName }}</view>
<view class="repair-info">报事位置{{ item.location }}</view>
<view v-if="getStatusLabel(item.status) === '已结束'" class="repair-eval-btn eval-btn-right">服务评价</view>
<view v-if="getStatusLabel(item.status) === '已结束'" class="repair-eval-btn eval-btn-right" @click.stop="goTEvaluate(item)">服务评价</view>
</view>
<!-- 加载提示 -->
@@ -138,7 +138,7 @@
pageNum: this.pageNum,
pageSize: this.pageSize
};
let res = await this.$u.api.getOrderList(params);
let res = await this.$u.api.getOrderList2(params);
if (res.code == '200') {
const rows = res.rows || [];
if (reset) {
@@ -212,10 +212,10 @@
};
return statusMap[status] || '';
},
goTEvaluate() {
const detailItemStr = encodeURIComponent(JSON.stringify(this.detailItem));
goTEvaluate(item) {
const itemStr = encodeURIComponent(JSON.stringify(item));
uni.navigateTo({
url: `/pages/sys/user/myRepair/repairEvaluate?detailItem=${detailItemStr}`
url: "/pages/sys/user/myRepair/repairEvaluate?item=" + itemStr
});
},
handleScroll(e) {

View File

@@ -1,6 +1,5 @@
<template>
<view class="evaluate-container">
<!-- 评分项 -->
<view class="evaluate-list">
<view class="evaluate-row">
@@ -8,23 +7,34 @@
<view class="evaluate-stars">
<image v-for="i in 5" :key="i"
:src="detailItem.serviceEvalua >= i ? '/static/ic_evaluate_select.png' : '/static/ic_evaluate_disselect.png'"
class="evaluate-star" @click="detailItem.serviceEvalua = i" />
class="evaluate-star" :class="{'disabled': isViewMode}" @click="!isViewMode && setRating(i)" />
</view>
</view>
</view>
<!-- 输入框 -->
<textarea class="evaluate-textarea" placeholder="说点什么吧..." v-model="detailItem.serviceEvaluaText" />
<textarea class="evaluate-textarea" placeholder="说点什么吧..." v-model="detailItem.serviceEvaluaText"
:disabled="isViewMode" />
<!-- 上传照片 -->
<!-- 上传照片 -->
<view class="repair-evaluate-section">
<view class="repair-evaluate-section" v-if="!isViewMode">
<view class="add-repair-label">上传照片 <text class="add-repair-optional">(非必填最多三张)</text></view>
<u-upload :fileList="selectedImages" @delete="deletePic" name="upload" multiple maxCount="3" width="180"
height="180" :autoUpload="false"></u-upload>
<u-upload :fileList="selectedImages" @on-list-change="onListChange" @delete="deletePic" name="upload"
multiple maxCount="3" width="180" height="180" :autoUpload="false"></u-upload>
</view>
<!-- 查看图片 -->
<view class="repair-evaluate-section" v-else>
<view class="add-repair-label">评价图片</view>
<view class="image-preview-container" v-if="imageList.length > 0">
<image v-for="(img, index) in imageList" :key="index" :src="img" class="preview-image"
@click="previewImage(index)"></image>
</view>
<view class="no-image" v-else>暂无图片</view>
</view>
<!-- 提交按钮 -->
<button class="evaluate-btn" @click="submit">提交</button>
<button class="evaluate-btn" @click="submit" v-if="!isViewMode">提交</button>
</view>
</template>
@@ -41,48 +51,98 @@
return {
comment: '',
selectedImages: [], // 存储已选图片
detailItem: null // 接收传递的详情项
imageList: [], // 查看模式下的图片列表
detailItem: {
serviceEvalua: 0,
serviceEvaluaText: ''
}, // 接收传递的详情项
isViewMode: false // 是否为查看模式
}
},
onLoad(options) {
// 接收传递的detailItem参数
if (options.detailItem) {
// 接收传递的参数
if (options.item) {
try {
this.detailItem = JSON.parse(decodeURIComponent(options.detailItem));
const item = JSON.parse(decodeURIComponent(options.item));
this.detailItem = {
...this.detailItem,
...item
};
console.log(this.detailItem)
this.isViewMode = this.detailItem.serviceEvalua
if (this.isViewMode) {
this.getImageUrl()
}
} catch (e) {
console.error('解析detailItem参数失败', e);
console.error('解析item参数失败', e);
}
}
},
methods: {
async getImageUrl() {
if (!this.detailItem.imgUrl) return;
const imgIds = this.detailItem.imgUrl.split(',');
const res = await this.$u.api.getImageUrl({}, imgIds.join(','));
if (res.code == 200 && res.data) this.imageList = res.data.map(item => item.url);
},
// 设置评分
setRating(rating) {
this.$set(this.detailItem, 'serviceEvalua', rating);
},
// 删除图片
deletePic(event) {
this.selectedImages.splice(event.index, 1);
},
// 图片列表变化处理
onListChange(list) {
this.selectedImages = list;
},
// 预览图片
previewImage(index) {
uni.previewImage({
current: index,
urls: this.imageList
});
},
async submit() {
console.log(this.selectedImages)
if (this.selectedImages.length <= 0) {
this.realSubmit()
return
}
// 遍历selectedImages数组并处理图片路径
const images = this.selectedImages.map(item => item.path.replace('file://', ''));
const result = await uploadFiles({
files: images,
url: this.vuex_config.baseUrl + '/resource/oss/upload',
name: 'file',
vm: this // 关键:用于注入 token 等
const images = this.selectedImages
.map(item => item?.path?.replace('file://', '') || item?.url || null)
.filter(path => path !== null);
uni.showLoading({
title: '加载中...'
});
const result = await uploadFiles({
files: images,
url: this.vuex_config.baseUrl + '/resource/oss/upload',
name: 'file',
vm: this // 关键:用于注入 token 等
});
if (result.code == '200') {
// 遍历result获取data.url加上,分割
const urls = result.map(item => item.data?.url || '').filter(url => url !== '');
this.detailItem.imgUrl = urls.join(',');
this.realSubmit()
}
const allSuccess = result.every(item => item.code == 200);
if (!allSuccess) {
uni.showToast({
title: '上传失败',
icon: 'none'
});
uni.hideLoading();
return;
}
// 遍历result获取data.url加上,分割
const urls = result.map(item => item.data?.ossId || '').filter(ossId => ossId !== '');
this.detailItem.imgUrl = urls.join(',');
this.realSubmit()
},
async realSubmit() {
let res = await this.$u.api.updateOrder(this.detailItem);
let res = await this.$u.api.updateOrder2(this.detailItem);
if (res.code == '200') {
// 关闭页面前发送事件通知前页面刷新
uni.$emit('refreshData', '');
@@ -133,6 +193,10 @@
margin-right: 36rpx;
}
.evaluate-star.disabled {
opacity: 1;
}
.evaluate-tag {
flex: 0 0 calc((100% - 60rpx) / 4);
@@ -164,6 +228,10 @@
display: block;
}
.evaluate-textarea[disabled] {
background-color: #f0f0f0;
}
.evaluate-btn {
width: 80vw;
height: 88rpx;
@@ -198,4 +266,23 @@
font-size: 24rpx;
font-weight: 400;
}
.image-preview-container {
display: flex;
flex-wrap: wrap;
}
.preview-image {
width: 180rpx;
height: 180rpx;
margin-right: 20rpx;
margin-bottom: 20rpx;
}
.no-image {
color: #888;
font-size: 28rpx;
text-align: center;
padding: 20rpx 0;
}
</style>

View File

@@ -13,7 +13,7 @@
{{info.content}}
</view>
<image src="/static/ic_q_d_01.png" class="question-img" mode="widthFix" />
<image src="info.img" class="question-img" mode="widthFix" />
<view class="question-time">{{info.time}}</view>
</view>
</view>