userComment.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="container">
  3. <!-- 服务评价标题(固定在最上方) -->
  4. <view class="evaluation-title">服务评价:</view>
  5. <!-- 图片和信息区域 -->
  6. <view class="info-section">
  7. <up-image :show-loading="true" :src="src" width="80px" height="80px" @click="click"
  8. class="info-image"></up-image>
  9. <view class="info-text">
  10. <text class="project-name">服务类型:{{ projectName }}</text>
  11. <text class="volunteer-name">姓名:{{ volunteerName }}</text>
  12. </view>
  13. </view>
  14. <!-- 评分区域 - 修改为星星和文字都在左边 -->
  15. <view class="rating-section">
  16. <view class="rating-item">
  17. <text class="rating-label">服务礼仪:</text>
  18. <up-rate :count="count" v-model="IfonForm.protocolScore" count="5" class="rating-stars"></up-rate>
  19. </view>
  20. <view class="rating-item">
  21. <text class="rating-label">着装整洁:</text>
  22. <up-rate :count="count" v-model="IfonForm.clothingScore" count="5" class="rating-stars"></up-rate>
  23. </view>
  24. <view class="rating-item">
  25. <text class="rating-label">专业能力:</text>
  26. <up-rate :count="count" v-model="IfonForm.abilityScore" count="5" class="rating-stars"></up-rate>
  27. </view>
  28. <view class="rating-item">
  29. <text class="rating-label">服务质量:</text>
  30. <up-rate :count="count" v-model="IfonForm.qualityScore" count="5" class="rating-stars"></up-rate>
  31. </view>
  32. </view>
  33. <!-- 图片上传区域 -->
  34. <view class="upload-section">
  35. <view class="upload-box">
  36. <view class="upload-img-item" v-for="(item, index) in fileList" :key="item.url">
  37. <view class="delete-icon" @click="deletePic(index)">
  38. <up-icon name="close-circle-fill" color="#f64a1f" size="18"></up-icon>
  39. </view>
  40. <img class="upload-img" :src="item.url" :alt="item.fileName">
  41. </view>
  42. <img src="/static/img/upload.png" alt="" class="upload-img" @click="uploadClick('img')"
  43. v-if="fileList.length < 10">
  44. </view>
  45. </view>
  46. <!-- 文本区域 -->
  47. <up-textarea v-model="IfonForm.userReview" placeholder="请输入评论内容" class="comment-textarea"></up-textarea>
  48. <!-- 发布按钮 -->
  49. <view class="button-section">
  50. <up-button type="error" text="发布" @click="handlButClick" class="submit-button"></up-button>
  51. </view>
  52. </view>
  53. </template>
  54. <script setup>
  55. import {
  56. onMounted,
  57. ref
  58. } from 'vue';
  59. import {
  60. usersUserFinishOrder
  61. } from "@/api/userList.js";
  62. import {
  63. onLoad,
  64. } from '@dcloudio/uni-app';
  65. import {
  66. wxUploadFile
  67. } from '@/utils/wxRequest.js'
  68. const count = ref(4);
  69. const fileList = ref([]);
  70. const src = ref('');
  71. const projectName = ref('');
  72. const volunteerName = ref('');
  73. const IfonForm = ref({
  74. protocolScore: 0, //服务礼仪
  75. clothingScore: 0, //服装整洁
  76. abilityScore: 0, //专业能力
  77. qualityScore: 0, //服务质量
  78. userReview: '',
  79. })
  80. // 删除图片
  81. const deletePic = (event) => {
  82. fileList.value.splice(event.index, 1);
  83. };
  84. const uploadClick = async (type) => {
  85. const res = await wxUploadFile(type);
  86. fileList.value = [...fileList.value, ...res];
  87. console.log('xxxxres', res, fileList.value);
  88. }
  89. const handlButClick = async () => {
  90. // 提取所有图片的 URL
  91. const imageUrls = fileList.value.map(item => item.url);
  92. const volunteerInfoId = IfonForm.value.volunteerInfoId;
  93. const secondOrderId = IfonForm.value.secondOrderId;
  94. try {
  95. const params = {
  96. ...IfonForm.value,
  97. images: imageUrls,
  98. volunteerInfoId: volunteerInfoId,
  99. secondOrderId: secondOrderId,
  100. }
  101. console.log(params, 'params>>>')
  102. const res = await usersUserFinishOrder(params)
  103. if (res.code == 200) {
  104. uni.navigateTo({
  105. url: '/pages/classify'
  106. })
  107. uni.showToast({
  108. title: '评价提交成功',
  109. icon: 'success'
  110. });
  111. } else {
  112. console.log('提交失败')
  113. }
  114. } catch (e) {
  115. uni.showToast({
  116. title: '提交失败,请重试',
  117. icon: 'error'
  118. });
  119. }
  120. }
  121. onLoad(async (options) => {
  122. const data = JSON.parse(decodeURIComponent(options.data));
  123. console.log(data, '》》》》》》 获取传递的 listData');
  124. // 设置图片
  125. if (data.volunteerInfo?.volunteerPicture) {
  126. src.value = data.volunteerInfo.volunteerPicture;
  127. } else {
  128. src.value = '/static/default-avatar.png';
  129. }
  130. // 设置项目名称和志愿者姓名
  131. projectName.value = data.volunteerInfo?.projectName || '未知项目';
  132. volunteerName.value = data.volunteerInfo?.name || '未知姓名';
  133. const secondOrderList = data.secondOrderList || [];
  134. // 获取第一个 secondOrderId
  135. const secondOrderId = secondOrderList.length > 0 ? secondOrderList[0].secondOrderId : null;
  136. // 如果 secondOrderId 存在,则设置到 IfonForm 中
  137. if (secondOrderId) {
  138. IfonForm.value.secondOrderId = secondOrderId;
  139. }
  140. // 获取 volunteerInfoId
  141. const volunteerInfoId = data.volunteerInfo?.volunteerInfoId || data.volunteerInfoId;
  142. IfonForm.value.volunteerInfoId = volunteerInfoId;
  143. });
  144. </script>
  145. <style scoped>
  146. .container {
  147. display: flex;
  148. flex-direction: column;
  149. padding: 20rpx;
  150. }
  151. .evaluation-title {
  152. font-size: 32rpx;
  153. font-weight: bold;
  154. margin-bottom: 30rpx;
  155. }
  156. .info-section {
  157. display: flex;
  158. align-items: center;
  159. margin-bottom: 30rpx;
  160. }
  161. .info-image {
  162. margin-right: 20rpx;
  163. }
  164. .info-text {
  165. display: flex;
  166. flex-direction: column;
  167. flex: 1;
  168. }
  169. .project-name,
  170. .volunteer-name {
  171. font-size: 28rpx;
  172. margin-bottom: 10rpx;
  173. }
  174. .rating-section {
  175. margin-bottom: 30rpx;
  176. }
  177. .rating-item {
  178. display: flex;
  179. align-items: center;
  180. margin-bottom: 20rpx;
  181. }
  182. .rating-label {
  183. font-size: 28rpx;
  184. margin-right: 15rpx;
  185. min-width: 120rpx;
  186. /* 保持标签宽度一致 */
  187. }
  188. .rating-stars {
  189. margin-left: 0;
  190. /* 移除左边距,使星星紧贴文字 */
  191. }
  192. .comment-textarea {
  193. margin-bottom: 20rpx;
  194. }
  195. .upload-section {
  196. margin-bottom: 30rpx;
  197. }
  198. .upload-box {
  199. display: flex;
  200. flex-wrap: wrap;
  201. }
  202. .upload-img-item {
  203. position: relative;
  204. margin-right: 20rpx;
  205. margin-bottom: 20rpx;
  206. }
  207. .delete-icon {
  208. position: absolute;
  209. top: -10rpx;
  210. right: -10rpx;
  211. z-index: 1;
  212. }
  213. .upload-img {
  214. width: 150rpx;
  215. height: 150rpx;
  216. border-radius: 8rpx;
  217. }
  218. .button-section {
  219. display: flex;
  220. justify-content: flex-end;
  221. }
  222. .submit-button {
  223. width: 200rpx;
  224. }
  225. </style>