123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- <template>
- <view class="container">
- <!-- 服务评价标题(固定在最上方) -->
- <view class="evaluation-title">服务评价:</view>
- <!-- 图片和信息区域 -->
- <view class="info-section">
- <up-image :show-loading="true" :src="src" width="80px" height="80px" @click="click"
- class="info-image"></up-image>
- <view class="info-text">
- <text class="project-name">服务类型:{{ projectName }}</text>
- <text class="volunteer-name">姓名:{{ volunteerName }}</text>
- </view>
- </view>
- <!-- 评分区域 - 修改为星星和文字都在左边 -->
- <view class="rating-section">
- <view class="rating-item">
- <text class="rating-label">服务礼仪:</text>
- <up-rate :count="count" v-model="IfonForm.protocolScore" count="5" class="rating-stars"></up-rate>
- </view>
- <view class="rating-item">
- <text class="rating-label">着装整洁:</text>
- <up-rate :count="count" v-model="IfonForm.clothingScore" count="5" class="rating-stars"></up-rate>
- </view>
- <view class="rating-item">
- <text class="rating-label">专业能力:</text>
- <up-rate :count="count" v-model="IfonForm.abilityScore" count="5" class="rating-stars"></up-rate>
- </view>
- <view class="rating-item">
- <text class="rating-label">服务质量:</text>
- <up-rate :count="count" v-model="IfonForm.qualityScore" count="5" class="rating-stars"></up-rate>
- </view>
- </view>
- <!-- 图片上传区域 -->
- <view class="upload-section">
- <view class="upload-box">
- <view class="upload-img-item" v-for="(item, index) in fileList" :key="item.url">
- <view class="delete-icon" @click="deletePic(index)">
- <up-icon name="close-circle-fill" color="#f64a1f" size="18"></up-icon>
- </view>
- <img class="upload-img" :src="item.url" :alt="item.fileName">
- </view>
- <img src="/static/img/upload.png" alt="" class="upload-img" @click="uploadClick('img')"
- v-if="fileList.length < 10">
- </view>
- </view>
- <!-- 文本区域 -->
- <up-textarea v-model="IfonForm.userReview" placeholder="请输入评论内容" class="comment-textarea"></up-textarea>
- <!-- 发布按钮 -->
- <view class="button-section">
- <up-button type="error" text="发布" @click="handlButClick" class="submit-button"></up-button>
- </view>
- </view>
- </template>
- <script setup>
- import {
- onMounted,
- ref
- } from 'vue';
- import {
- usersUserFinishOrder
- } from "@/api/userList.js";
- import {
- onLoad,
- } from '@dcloudio/uni-app';
- import {
- wxUploadFile
- } from '@/utils/wxRequest.js'
- const count = ref(4);
- const fileList = ref([]);
- const src = ref('');
- const projectName = ref('');
- const volunteerName = ref('');
- const IfonForm = ref({
- protocolScore: 0, //服务礼仪
- clothingScore: 0, //服装整洁
- abilityScore: 0, //专业能力
- qualityScore: 0, //服务质量
- userReview: '',
- })
- // 删除图片
- const deletePic = (event) => {
- fileList.value.splice(event.index, 1);
- };
- const uploadClick = async (type) => {
- const res = await wxUploadFile(type);
- fileList.value = [...fileList.value, ...res];
- console.log('xxxxres', res, fileList.value);
- }
- const handlButClick = async () => {
- // 提取所有图片的 URL
- const imageUrls = fileList.value.map(item => item.url);
- const volunteerInfoId = IfonForm.value.volunteerInfoId;
- const secondOrderId = IfonForm.value.secondOrderId;
- try {
- const params = {
- ...IfonForm.value,
- images: imageUrls,
- volunteerInfoId: volunteerInfoId,
- secondOrderId: secondOrderId,
- }
- console.log(params, 'params>>>')
- const res = await usersUserFinishOrder(params)
- if (res.code == 200) {
- uni.showToast({
- title: '评价提交成功',
- icon: 'success'
- });
- setTimeout(() => {
- uni.navigateBack({
- delta: 1
- })
- }, 2000)
- } else {
- console.log('提交失败')
- }
- } catch (e) {
- uni.showToast({
- title: '提交失败,请重试',
- icon: 'error'
- });
- }
- }
- onLoad(async (options) => {
- // 使用 uni.getStorage 获取存储的数据,而不是从 URL 参数解析
- uni.getStorage({
- key: 'orderDetailsData',
- success: function(res) {
- const data = res.data;
- console.log(data, '》》》》》》 获取传递的 listData');
- // 设置图片
- if (data.volunteerPicture) {
- src.value = data.volunteerPicture;
- } else {
- src.value = '/static/default-avatar.png';
- }
- // 设置项目名称和志愿者姓名
- projectName.value = data.businessManagementName || '未知项目';
- volunteerName.value = data.volunteerName || '未知姓名';
- // 获取 secondOrderId 从 URL 参数
- const secondOrderId = options.secondOrderId;
- if (secondOrderId) {
- IfonForm.value.secondOrderId = secondOrderId;
- }
-
- // 获取 volunteerInfoId
- IfonForm.value.volunteerInfoId = data.volunteerInfoId || '';
- },
- fail: function(err) {
- console.error('获取存储数据失败:', err);
- uni.showToast({
- title: '获取数据失败',
- icon: 'error'
- });
- }
- });
- });
- </script>
- <style scoped>
- .container {
- display: flex;
- flex-direction: column;
- padding: 20rpx;
- }
- .evaluation-title {
- font-size: 32rpx;
- font-weight: bold;
- margin-bottom: 30rpx;
- }
- .info-section {
- display: flex;
- align-items: center;
- margin-bottom: 30rpx;
- }
- .info-image {
- margin-right: 20rpx;
- }
- .info-text {
- display: flex;
- flex-direction: column;
- flex: 1;
- }
- .project-name,
- .volunteer-name {
- font-size: 28rpx;
- margin-bottom: 10rpx;
- }
- .rating-section {
- margin-bottom: 30rpx;
- }
- .rating-item {
- display: flex;
- align-items: center;
- margin-bottom: 20rpx;
- }
- .rating-label {
- font-size: 28rpx;
- margin-right: 15rpx;
- min-width: 120rpx;
- /* 保持标签宽度一致 */
- }
- .rating-stars {
- margin-left: 0;
- /* 移除左边距,使星星紧贴文字 */
- }
- .comment-textarea {
- margin-bottom: 20rpx;
- }
- .upload-section {
- margin-bottom: 30rpx;
- }
- .upload-box {
- display: flex;
- flex-wrap: wrap;
- }
- .upload-img-item {
- position: relative;
- margin-right: 20rpx;
- margin-bottom: 20rpx;
- }
- .delete-icon {
- position: absolute;
- top: -10rpx;
- right: -10rpx;
- z-index: 1;
- }
- .upload-img {
- width: 150rpx;
- height: 150rpx;
- border-radius: 8rpx;
- }
- .button-section {
- display: flex;
- justify-content: flex-end;
- }
- .submit-button {
- width: 200rpx;
- }
- </style>
|