index.vue 4.6 KB

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