userComment.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view>
  3. <view>
  4. 服务评价:
  5. <up-image :show-loading="true" :src="src" width="80px" height="80px" @click="click"></up-image>
  6. </view>
  7. <view>
  8. <view>
  9. <text>服务礼仪:</text>
  10. <template>
  11. <up-rate :count="count" v-model="IfonForm.protocolScore" count="5"></up-rate>
  12. </template>
  13. </view>
  14. <view>
  15. <text>着装整洁:</text>
  16. <template>
  17. <up-rate :count="count" v-model="IfonForm.clothingScore" count="5"></up-rate>
  18. </template>
  19. </view>
  20. <view>
  21. <text>专业能力:</text>
  22. <template>
  23. <up-rate :count="count" v-model="IfonForm.abilityScore" count="5"></up-rate>
  24. </template>
  25. </view>
  26. <view>
  27. <text>服务质量:</text>
  28. <template>
  29. <up-rate :count="count" v-model="IfonForm.qualityScore" count="5"></up-rate>
  30. </template>
  31. </view>
  32. </view>
  33. <view class="service-info order-card">
  34. <!-- 回顯 -->
  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)"><up-icon name="close-circle-fill"
  38. color="#f64a1f" size="18"></up-icon></view>
  39. <img class="upload-img" :src="item.url" :alt="item.fileName" srcset="">
  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. <up-textarea v-model="IfonForm.userReview" placeholder="请输入评论内容"></up-textarea>
  46. <up-button type="error" text="发布" @click="handlButClick"></up-button>
  47. </view>
  48. </template>
  49. <script setup>
  50. import {
  51. onMounted,
  52. ref
  53. } from 'vue';
  54. import {
  55. usersUserFinishOrder
  56. } from "@/api/userList.js";
  57. import {
  58. onLoad,
  59. } from '@dcloudio/uni-app';
  60. import {
  61. wxUploadFile
  62. } from '@/utils/wxRequest.js'
  63. const count = ref(4);
  64. const fileList = ref([]);
  65. const src = ref('https://cdn.uviewui.com/uview/album/1.jpg');
  66. const IfonForm = ref({
  67. protocolScore: 0, //服务礼仪
  68. clothingScore: 0, //服装整洁
  69. abilityScore: 0, //专业能力
  70. qualityScore: 0, //服务质量
  71. userReview:'',
  72. })
  73. // 删除图片
  74. const deletePic = (event) => {
  75. fileList.value.splice(event.index, 1);
  76. };
  77. const uploadClick = async (type) => {
  78. const res = await wxUploadFile(type);
  79. fileList.value = [...fileList.value, ...res];
  80. console.log('xxxxres', res, fileList.value);
  81. }
  82. const handlButClick = async () => {
  83. // 提取所有图片的 URL
  84. const imageUrls = fileList.value.map(item => item.url);
  85. const volunteerInfoId = IfonForm.value.volunteerInfoId;
  86. const secondOrderId = IfonForm.value.secondOrderId;
  87. try {
  88. const params = {
  89. ...IfonForm.value,
  90. images: imageUrls,
  91. volunteerInfoId: volunteerInfoId,
  92. secondOrderId: secondOrderId,
  93. }
  94. console.log(params, 'params>>>')
  95. const res = await usersUserFinishOrder(params)
  96. if (res.code == 200) {
  97. uni.navigateTo({
  98. url: '/pages/classify'
  99. })
  100. uni.showToast({
  101. title: '评价提交成功',
  102. icon: 'success'
  103. });
  104. } else {
  105. console.log('提交失败')
  106. }
  107. } catch (e) {
  108. uni.showToast({
  109. title: '提交失败,请重试',
  110. icon: 'error'
  111. });
  112. }
  113. }
  114. onLoad(async (options) => {
  115. const data = JSON.parse(decodeURIComponent(options.data));
  116. console.log(data, '》》》》》》 获取传递的 listData'); // 获取传递的 listData
  117. const secondOrderList = data.secondOrderList || [];
  118. // 获取第一个 secondOrderId
  119. const secondOrderId = secondOrderList.length > 0 ? secondOrderList[0].secondOrderId : null;
  120. // 如果 secondOrderId 存在,则设置到 IfonForm 中
  121. if (secondOrderId) {
  122. IfonForm.value.secondOrderId = secondOrderId;
  123. }
  124. // 获取 volunteerInfoId
  125. const volunteerInfoId = data.volunteerInfo?.volunteerInfoId || data.volunteerInfoId;
  126. IfonForm.value.volunteerInfoId = volunteerInfoId;
  127. });
  128. </script>
  129. <style>
  130. </style>