order.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. <img src="/static/img/dd.png" alt="" class="user-img" />
  8. <view class="info-list">
  9. <view>姓名:</view>
  10. <view>被服务对象:</view>
  11. <view>电话号码:</view>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="service-info order-card">
  16. <view class="font-title ">服务信息</view>
  17. <view class="info-list">
  18. <view>服务地址:</view>
  19. <view>服务类别:</view>
  20. <view>服务科目:</view>
  21. <view>备注:</view>
  22. </view>
  23. </view>
  24. <view class="register-info order-card">
  25. <view class="font-title ">志愿者信息</view>
  26. <view class="register-box">
  27. <img src="/static/img/dd.png" alt="" class="register-img" />
  28. <view class="info-list">
  29. <view>时间:2025.4.1 15:00-18:0</view>
  30. <view>姓名:</view>
  31. <view>服务地址:</view>
  32. <view>金额:<span class="price"><span class="price-yuan">¥</span> 200</span>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="service-info order-card">
  38. <view class="font-title">图片上传</view>
  39. <up-upload :fileList="fileList" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  40. :maxCount="10"></up-upload>
  41. </view>
  42. <view class=" footer-g">
  43. <up-button type="primary" text="前往沟通"></up-button>
  44. </view>
  45. </view>
  46. </template>
  47. <script setup>
  48. import { ref } from 'vue';
  49. import { getToken } from '@/utils/auth'
  50. import config from '@/config'
  51. const baseUrl = config.baseUrl
  52. const fileList = ref([]);
  53. // 删除图片
  54. const deletePic = (event) => {
  55. fileList.value.splice(event.index, 1);
  56. };
  57. // 新增图片
  58. const afterRead = async (event) => {
  59. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  60. let lists = [].concat(event.file);
  61. let fileListLen = fileList.value.length;
  62. lists.map((item) => {
  63. fileList.value.push({
  64. ...item,
  65. status: 'uploading',
  66. message: '上传中',
  67. });
  68. });
  69. for (let i = 0; i < lists.length; i++) {
  70. const result = await uploadFilePromise(lists[i]);
  71. let item = fileList.value[fileListLen];
  72. fileList.value.splice(fileListLen, 1, {
  73. ...item,
  74. status: 'success',
  75. message: '',
  76. url: result.url,
  77. });
  78. fileListLen++;
  79. }
  80. };
  81. const uploadFilePromise = (data) => {
  82. console.log('data',data);
  83. return new Promise((resolve, reject) => {
  84. wx.uploadFile({
  85. url: baseUrl + '/common/upload', // 仅为示例,非真实的接口地址
  86. filePath: data.url,
  87. name: 'file',
  88. formData: {
  89. file: data,
  90. },
  91. header: {
  92. 'Authorization': 'Bearer ' + getToken(), // 自定义请求头
  93. },
  94. success: (res) => {
  95. const data = JSON.parse(res.data);
  96. resolve(data);
  97. },
  98. fail: (err) => {
  99. uni.showToast({
  100. title: '上传失败',
  101. icon: 'none'
  102. })
  103. console.error(' 转换失败:', err);
  104. reject();
  105. }
  106. });
  107. });
  108. };
  109. </script>
  110. <style lang="scss" scoped>
  111. .order-detail {
  112. position: fixed;
  113. top: 0;
  114. left: 0;
  115. right: 0;
  116. bottom: 0;
  117. padding: 12px 12px 24px;
  118. background: rgba(245, 245, 245, 1);
  119. .order-card {
  120. border-radius: 8px;
  121. background: rgba(255, 255, 255, 1);
  122. padding: 12px;
  123. margin-bottom: 12px;
  124. }
  125. .font-title {
  126. margin-bottom: 12px;
  127. }
  128. .user-box {
  129. display: flex;
  130. .user-img {
  131. width: 65.8px;
  132. height: 65.8px;
  133. margin-right: 12px;
  134. }
  135. }
  136. .register-box {
  137. display: flex;
  138. margin-bottom: 12px;
  139. .register-img {
  140. width: 90px;
  141. height: 90px;
  142. margin-right: 12px;
  143. }
  144. }
  145. .info-list {
  146. flex: 1;
  147. font-size: 14px;
  148. font-weight: 500;
  149. letter-spacing: 0px;
  150. line-height: 23.27px;
  151. color: rgba(51, 51, 51, 1);
  152. }
  153. .price {
  154. font-size: 18px;
  155. font-weight: 500;
  156. color: rgba(246, 74, 31, 1);
  157. .price-yuan {
  158. font-size: 13px;
  159. font-weight: 700;
  160. color: rgba(246, 74, 31, 1);
  161. }
  162. }
  163. .footer-g {
  164. padding: 12px;
  165. position: absolute;
  166. bottom: 18px;
  167. left: 0px;
  168. right: 0px;
  169. }
  170. }
  171. </style>