index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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.name }}</view>
  9. <view style="display: flex;">服务类别: <dict-tag :options="lrr_service_category"
  10. :value="detaile.serviceCategory" /></view>
  11. <view @click="onPhone">电话号码:<label class="phone">{{ detaile.telephone }}</label></view>
  12. <view>地址:{{ detaile.address }}</view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="service-info order-card">
  17. <view class="font-title ">备注信息</view>
  18. <view class="info-list">
  19. {{ detaile.remark }}
  20. </view>
  21. </view>
  22. <view class="service-info order-card">
  23. <view class="font-title">图片上传</view>
  24. <view class="upload-box">
  25. <view class="upload-img-item" v-for="(item, index) in fileList" :key="item.url">
  26. <view class="delete-icon" @click="deletePic(index)"><up-icon name="close-circle-fill"
  27. color="#f64a1f" size="18" v-if="detaile.orderStatus === 1"></up-icon></view>
  28. <img class="upload-img" :src="item.url" :alt="item.fileName" srcset="">
  29. </view>
  30. <img src="/static/img/upload.png" alt="" class="upload-img" @click="uploadClick('img')"
  31. v-if="fileList.length < 10 && detaile.orderStatus === 1">
  32. </view>
  33. </view>
  34. <view class=" footer-g" v-if="detaile.orderStatus === 1">
  35. <up-button type="primary" text="确定结束" @click="onSubmit"></up-button>
  36. </view>
  37. </view>
  38. </template>
  39. <script setup>
  40. import { ref, toRaw } from 'vue';
  41. import { onLoad } from '@dcloudio/uni-app';
  42. import { getVolunteerOrderInfo, getVolunteerFinishSecondOrder } from '@/api/volunteer.js'
  43. import { getAddress } from '@/api/address.js'
  44. import { wxUploadFile, wxMakePhoneCall } from '@/utils/wxRequest.js'
  45. import { useDict } from '@/utils/dict.js';
  46. import DictTag from '@/components/DictTag/index.vue'
  47. const fileList = ref([]);
  48. const orderId = ref('');
  49. const detaile = ref({});
  50. const {
  51. lrr_service_category
  52. } = useDict('lrr_service_category');
  53. // 删除图片
  54. const deletePic = (index) => {
  55. fileList.value.splice(index, 1);
  56. };
  57. const uploadClick = async (type) => {
  58. const res = await wxUploadFile(type);
  59. fileList.value = [...fileList.value, ...res];
  60. console.log('xxxxres', res, fileList.value);
  61. }
  62. const onPhone = (phone) => {
  63. wxMakePhoneCall(phone)
  64. }
  65. const getOrderDetail = async () => {
  66. try {
  67. uni.showLoading({
  68. title: '数据加载中...'
  69. });
  70. const res = await getVolunteerOrderInfo({ orderId: orderId.value });
  71. const ad_res = await getAddress(res.data.addressId);
  72. let data = res.data;
  73. if (ad_res.data) {
  74. data = {
  75. ...data,
  76. address: ad_res.data.address,
  77. name: ad_res.data.name,
  78. telephone: ad_res.data.telephone
  79. }
  80. }
  81. if (data.serviceLog) {
  82. fileList.value = data.serviceLog.split(',').map(item => {
  83. return { url: item }
  84. });
  85. }
  86. detaile.value = data;
  87. console.log('detaile.value', detaile.value);
  88. } catch (error) {
  89. console.log('error', error);
  90. uni.showToast({
  91. title: error.msg,
  92. icon: 'error',
  93. })
  94. } finally {
  95. uni.hideLoading();
  96. }
  97. }
  98. const onSubmit = () => {
  99. const img_urls = fileList.value.map(item => item.url).join(',');
  100. console.log('submit', fileList.value, img_urls);
  101. getVolunteerFinishSecondOrder({
  102. secondOrderId: orderId.value,
  103. serviceLog: img_urls,
  104. volunteerId: detaile.value.volunteerId
  105. }).then(res => {
  106. if (res.code === 200) {
  107. uni.showToast({
  108. title: '服务结束',
  109. icon: 'success',
  110. success: () => {
  111. setTimeout(() => {
  112. uni.switchTab({
  113. url: '/pages/classify'
  114. });
  115. }, 800)
  116. }
  117. })
  118. }else{
  119. uni.showToast({
  120. title: res.data,
  121. icon: 'error',
  122. })
  123. }
  124. })
  125. }
  126. onLoad((options) => {
  127. console.log('options', options);
  128. orderId.value = options.orderId;
  129. // orderId.value = '1911685346559660034';
  130. getOrderDetail();
  131. })
  132. </script>
  133. <style lang="scss" scoped>
  134. .order-detail {
  135. position: fixed;
  136. top: 0;
  137. left: 0;
  138. right: 0;
  139. bottom: 0;
  140. padding: 12px 12px 24px;
  141. background: rgba(245, 245, 245, 1);
  142. .order-card {
  143. border-radius: 8px;
  144. background: rgba(255, 255, 255, 1);
  145. padding: 12px;
  146. margin-bottom: 12px;
  147. }
  148. .font-title {
  149. margin-bottom: 12px;
  150. }
  151. .user-box {
  152. display: flex;
  153. .user-img {
  154. width: 65.8px;
  155. height: 65.8px;
  156. margin-right: 12px;
  157. }
  158. }
  159. .register-box {
  160. display: flex;
  161. margin-bottom: 12px;
  162. .register-img {
  163. width: 90px;
  164. height: 90px;
  165. margin-right: 12px;
  166. }
  167. }
  168. .info-list {
  169. flex: 1;
  170. font-size: 14px;
  171. font-weight: 500;
  172. letter-spacing: 0px;
  173. line-height: 23.27px;
  174. color: rgba(51, 51, 51, 1);
  175. }
  176. .price {
  177. font-size: 18px;
  178. font-weight: 500;
  179. color: rgba(246, 74, 31, 1);
  180. .price-yuan {
  181. font-size: 13px;
  182. font-weight: 700;
  183. color: rgba(246, 74, 31, 1);
  184. }
  185. }
  186. .footer-g {
  187. padding: 12px;
  188. position: absolute;
  189. bottom: 18px;
  190. left: 0px;
  191. right: 0px;
  192. }
  193. .upload-img {
  194. height: 68px;
  195. width: 68px;
  196. margin-right: 12px;
  197. margin-bottom: 12px;
  198. }
  199. .upload-box {
  200. display: flex;
  201. flex-wrap: wrap;
  202. .upload-img-item {
  203. position: relative;
  204. .delete-icon {
  205. position: absolute;
  206. top: -7px;
  207. right: 7px;
  208. z-index: 1;
  209. }
  210. }
  211. }
  212. .phone {
  213. color: #3c9cff;
  214. }
  215. }
  216. </style>