userComment.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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.showToast({
  105. title: '评价提交成功',
  106. icon: 'success'
  107. });
  108. setTimeout(() => {
  109. uni.navigateBack({
  110. delta: 1
  111. })
  112. }, 2000)
  113. } else {
  114. console.log('提交失败')
  115. }
  116. } catch (e) {
  117. uni.showToast({
  118. title: '提交失败,请重试',
  119. icon: 'error'
  120. });
  121. }
  122. }
  123. onLoad(async (options) => {
  124. // 使用 uni.getStorage 获取存储的数据,而不是从 URL 参数解析
  125. uni.getStorage({
  126. key: 'orderDetailsData',
  127. success: function(res) {
  128. const data = res.data;
  129. console.log(data, '》》》》》》 获取传递的 listData');
  130. // 设置图片
  131. if (data.volunteerPicture) {
  132. src.value = data.volunteerPicture;
  133. } else {
  134. src.value = '/static/default-avatar.png';
  135. }
  136. // 设置项目名称和志愿者姓名
  137. projectName.value = data.businessManagementName || '未知项目';
  138. volunteerName.value = data.volunteerName || '未知姓名';
  139. // 获取 secondOrderId 从 URL 参数
  140. const secondOrderId = options.secondOrderId;
  141. if (secondOrderId) {
  142. IfonForm.value.secondOrderId = secondOrderId;
  143. }
  144. // 获取 volunteerInfoId
  145. IfonForm.value.volunteerInfoId = data.volunteerInfoId || '';
  146. },
  147. fail: function(err) {
  148. console.error('获取存储数据失败:', err);
  149. uni.showToast({
  150. title: '获取数据失败',
  151. icon: 'error'
  152. });
  153. }
  154. });
  155. });
  156. </script>
  157. <style scoped>
  158. .container {
  159. display: flex;
  160. flex-direction: column;
  161. padding: 20rpx;
  162. }
  163. .evaluation-title {
  164. font-size: 32rpx;
  165. font-weight: bold;
  166. margin-bottom: 30rpx;
  167. }
  168. .info-section {
  169. display: flex;
  170. align-items: center;
  171. margin-bottom: 30rpx;
  172. }
  173. .info-image {
  174. margin-right: 20rpx;
  175. }
  176. .info-text {
  177. display: flex;
  178. flex-direction: column;
  179. flex: 1;
  180. }
  181. .project-name,
  182. .volunteer-name {
  183. font-size: 28rpx;
  184. margin-bottom: 10rpx;
  185. }
  186. .rating-section {
  187. margin-bottom: 30rpx;
  188. }
  189. .rating-item {
  190. display: flex;
  191. align-items: center;
  192. margin-bottom: 20rpx;
  193. }
  194. .rating-label {
  195. font-size: 28rpx;
  196. margin-right: 15rpx;
  197. min-width: 120rpx;
  198. /* 保持标签宽度一致 */
  199. }
  200. .rating-stars {
  201. margin-left: 0;
  202. /* 移除左边距,使星星紧贴文字 */
  203. }
  204. .comment-textarea {
  205. margin-bottom: 20rpx;
  206. }
  207. .upload-section {
  208. margin-bottom: 30rpx;
  209. }
  210. .upload-box {
  211. display: flex;
  212. flex-wrap: wrap;
  213. }
  214. .upload-img-item {
  215. position: relative;
  216. margin-right: 20rpx;
  217. margin-bottom: 20rpx;
  218. }
  219. .delete-icon {
  220. position: absolute;
  221. top: -10rpx;
  222. right: -10rpx;
  223. z-index: 1;
  224. }
  225. .upload-img {
  226. width: 150rpx;
  227. height: 150rpx;
  228. border-radius: 8rpx;
  229. }
  230. .button-section {
  231. display: flex;
  232. justify-content: flex-end;
  233. }
  234. .submit-button {
  235. width: 200rpx;
  236. }
  237. </style>