index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <!-- 订单详情 -->
  2. <template>
  3. <view class="order-detail">
  4. <view class="user-info order-card">
  5. <view class="font-title">基本信息</view>
  6. <view class="user-box">
  7. <view class="info-list">
  8. <view>被服务人员:{{ detaile.clientName }}</view>
  9. <view style="display: flex;">服务类别:
  10. <!-- <dict-tag :options="lrr_service_category"
  11. :value="detaile.businessTireName" /> -->
  12. {{ detaile.businessTireName }}
  13. </view>
  14. <view @click="onPhone">电话号码:<label class="phone">{{ detaile.clientPhoneNumber }}</label></view>
  15. <view>地址:{{ detaile.address }}</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="service-info order-card">
  20. <view class="font-title ">备注信息</view>
  21. <view class="info-list">
  22. {{ detaile.remark }}
  23. </view>
  24. </view>
  25. <view class="service-info order-card" v-if="detaile.orderStatus === '3'">
  26. <view class="font-title ">反馈信息</view>
  27. <view class="info-list">
  28. <up-textarea v-model="detaile.volunteerReview" placeholder="请输入内容" ></up-textarea>
  29. </view>
  30. </view>
  31. <view v-if="detaile.orderStatus !== '3'">
  32. <view class="user-info order-card">
  33. <view class="font-title">志愿者反馈信息</view>
  34. <view class="user-box">
  35. <view class="info-list">
  36. <view class="info-item">{{ detaile.volunteerReview }}</view>
  37. </view>
  38. </view>
  39. <view class="upload-box-see">
  40. <view class="upload-img-item" v-for="(item) in volunteerPicture" :key="item.url">
  41. <up-image class="upload-img-see" :show-loading="true" :src="item.url" :alt="item.fileName"></up-image>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="user-info order-card">
  46. <view class="font-title">用户评价信息</view>
  47. <view class="user-box">
  48. <view class="info-list">
  49. <view class="info-item">{{ detaile.userReview || '用户未完成评价'}}</view>
  50. </view>
  51. </view>
  52. <view class="upload-box-see">
  53. <view class="upload-img-item" v-for="(item) in userPicture" :key="item.url">
  54. <up-image class="upload-img-see" :show-loading="true" :src="item.url" :alt="item.fileName"></up-image>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="service-info order-card" v-if="detaile.orderStatus === '3'">
  60. <view class="font-title">图片上传</view>
  61. <view class="upload-box">
  62. <view class="upload-img-item" v-for="(item, index) in fileList" :key="item.url">
  63. <view class="delete-icon" @click="deletePic(index)"><up-icon name="close-circle-fill"
  64. color="#f64a1f" size="18" v-if="detaile.orderStatus === '3'"></up-icon></view>
  65. <img class="upload-img" :src="item.url" :alt="item.fileName" srcset="">
  66. </view>
  67. <img src="/static/img/upload.png" alt="" class="upload-img" @click="uploadClick('img')"
  68. v-if="fileList.length < 10 && detaile.orderStatus === '3'">
  69. </view>
  70. </view>
  71. <view class=" footer-g" v-if="detaile.orderStatus === '3'">
  72. <!-- <up-button type="primary" text="确定结束" @click="onSubmit"></up-button> -->
  73. <view class="status-btn" @click="onSubmit">确定结束</view>
  74. </view>
  75. </view>
  76. </template>
  77. <script setup>
  78. import { ref, toRaw, computed } from 'vue';
  79. import { onLoad } from '@dcloudio/uni-app';
  80. import { getVolunteerOrderInfo, getVolunteerFinishSecondOrder } from '@/api/volunteer.js'
  81. import { getAddress } from '@/api/address.js'
  82. import { wxUploadFile, wxMakePhoneCall } from '@/utils/wxRequest.js'
  83. import { useDict } from '@/utils/dict.js';
  84. import DictTag from '@/components/DictTag/index.vue'
  85. const fileList = ref([]);
  86. const secondOrderId = ref('');
  87. const detaile = ref({
  88. volunteerReview:''
  89. });
  90. const {
  91. lrr_service_category
  92. } = useDict('lrr_service_category');
  93. // 删除图片
  94. const deletePic = (index) => {
  95. fileList.value.splice(index, 1);
  96. };
  97. const uploadClick = async (type) => {
  98. const res = await wxUploadFile(type);
  99. fileList.value = [...fileList.value, ...res];
  100. console.log('xxxxres', res, fileList.value);
  101. }
  102. const onPhone = (phone) => {
  103. wxMakePhoneCall(phone)
  104. }
  105. //志愿者图片反馈
  106. const volunteerPicture = computed(() => {
  107. if (detaile.value.volunteerPicture) {
  108. return detaile.value.volunteerPicture.split(',').map(item => {
  109. return { url: item }
  110. });
  111. }
  112. return [];
  113. })
  114. //用户图片评价
  115. const userPicture = computed(() => {
  116. if (detaile.value.userPicture) {
  117. return detaile.value.userPicture.split(',').map(item => {
  118. return { url: item }
  119. });
  120. }
  121. return [];
  122. })
  123. const getOrderDetail = async () => {
  124. try {
  125. uni.showLoading({
  126. title: '数据加载中...'
  127. });
  128. const res = await getVolunteerOrderInfo({ secondOrderId: secondOrderId.value });
  129. console.log('API response:', res);
  130. // Check if the response was successful
  131. if (res.code === 200) {
  132. // Directly assign the data from response
  133. detaile.value = res.data;
  134. // Check if volunteer pictures exist and process them
  135. if (res.data.volunteerPicture) {
  136. fileList.value = res.data.volunteerPicture.split(',').map(item => {
  137. return { url: item }
  138. });
  139. }
  140. } else {
  141. uni.showToast({
  142. title: res.msg || '获取数据失败',
  143. icon: 'error',
  144. });
  145. }
  146. console.log('detaile.value after assignment:', detaile.value);
  147. } catch (error) {
  148. console.log('error', error);
  149. uni.showToast({
  150. title: error.msg || '获取数据失败',
  151. icon: 'error',
  152. })
  153. } finally {
  154. uni.hideLoading();
  155. }
  156. }
  157. const onSubmit = () => {
  158. const img_urls = fileList.value.map(item => item.url).join(',');
  159. console.log('submit', fileList.value, img_urls);
  160. getVolunteerFinishSecondOrder({
  161. secondOrderId: secondOrderId.value,
  162. volunteerPicture: img_urls,
  163. // volunteerId: detaile.value.volunteerId,
  164. volunteerReview: detaile.value.volunteerReview
  165. }).then(res => {
  166. if (res.code === 200) {
  167. uni.showToast({
  168. title: '服务结束',
  169. icon: 'success',
  170. success: () => {
  171. setTimeout(() => {
  172. uni.switchTab({
  173. url: '/pages/classify'
  174. });
  175. }, 800)
  176. }
  177. })
  178. } else {
  179. uni.showToast({
  180. title: res.data,
  181. icon: 'error',
  182. })
  183. }
  184. })
  185. }
  186. onLoad((options) => {
  187. console.log('options received:', options);
  188. secondOrderId.value = options.secondOrderId;
  189. console.log('secondOrderId set to:', secondOrderId.value);
  190. // orderId.value = '1911685346559660034';
  191. getOrderDetail();
  192. })
  193. </script>
  194. <style lang="scss" scoped>
  195. .order-detail {
  196. position: fixed;
  197. top: 0;
  198. left: 0;
  199. right: 0;
  200. bottom: 0;
  201. padding: 12px 12px 24px;
  202. background: rgba(245, 245, 245, 1);
  203. overflow-y: auto;
  204. .order-card {
  205. border-radius: 8px;
  206. background: rgba(255, 255, 255, 1);
  207. padding: 12px;
  208. margin-bottom: 12px;
  209. }
  210. .font-title {
  211. margin-bottom: 12px;
  212. }
  213. .user-box {
  214. display: flex;
  215. .user-img {
  216. width: 65.8px;
  217. height: 65.8px;
  218. margin-right: 12px;
  219. }
  220. }
  221. .register-box {
  222. display: flex;
  223. margin-bottom: 12px;
  224. .register-img {
  225. width: 90px;
  226. height: 90px;
  227. margin-right: 12px;
  228. }
  229. }
  230. .info-list {
  231. flex: 1;
  232. font-size: 14px;
  233. font-weight: 500;
  234. letter-spacing: 0px;
  235. line-height: 23.27px;
  236. color: rgba(51, 51, 51, 1);
  237. }
  238. .price {
  239. font-size: 18px;
  240. font-weight: 500;
  241. color: rgba(246, 74, 31, 1);
  242. .price-yuan {
  243. font-size: 13px;
  244. font-weight: 700;
  245. color: rgba(246, 74, 31, 1);
  246. }
  247. }
  248. .footer-g {
  249. padding: 12px;
  250. position: absolute;
  251. bottom: 18px;
  252. left: 0px;
  253. right: 0px;
  254. }
  255. .upload-img {
  256. height: 68px;
  257. width: 68px;
  258. margin-right: 12px;
  259. margin-bottom: 12px;
  260. }
  261. .upload-box {
  262. display: flex;
  263. flex-wrap: wrap;
  264. // display: flex;
  265. // flex-direction: column;
  266. // align-items: center;
  267. // justify-content: center;
  268. .upload-img-item {
  269. position: relative;
  270. .delete-icon {
  271. position: absolute;
  272. top: -7px;
  273. right: 7px;
  274. z-index: 1;
  275. }
  276. }
  277. }
  278. .upload-box-see {
  279. display: flex;
  280. flex-direction: column;
  281. align-items: center;
  282. justify-content: center;
  283. .upload-img-see{
  284. margin-bottom: 12px;
  285. }
  286. }
  287. .phone {
  288. color: #3c9cff;
  289. }
  290. .info-item {
  291. margin-bottom: 12px;
  292. }
  293. }
  294. .status-btn {
  295. // width: 716rpx;
  296. height: 96rpx;
  297. border-radius: 16rpx;
  298. background: rgba(221, 94, 69, 1);
  299. display: flex;
  300. align-items: center;
  301. justify-content: center;
  302. font-size: 32rpx;
  303. font-weight: 400;
  304. color: rgba(255, 255, 255, 1);
  305. margin-bottom: 88rpx;
  306. }
  307. </style>