userComment.vue 6.6 KB

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