arriveUpload.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view class="arrive_upload">
  3. <view class="top">
  4. </view>
  5. <view class="head">
  6. <span class="cuIcon-back" @click="back"></span>
  7. <view class="case">
  8. 上传现场照片
  9. </view>
  10. </view>
  11. <view class="center">
  12. <view class="text">
  13. <view class="title">
  14. 请至少上传3张照片
  15. </view>
  16. <view class="describe">
  17. 照片要求:<br />
  18. 1.图片中需清晰的包含救援车辆全身<br />
  19. 2.清晰可见车牌照上的车牌号<br />
  20. 3.含被救援车全部或部分车身的整体环境照(如有因周围环境的特殊性需要纳入附加费时的情形照片)<br />
  21. </view>
  22. </view>
  23. <view class="upload">
  24. <u-upload class="upliado_cusstom" :action="action" :file-list="fileList" @on-success="onUploadSuccess"
  25. @on-remove="onRemove" @on-choose-complete="onChooseComplete" :max-count="9" :multiple="true"
  26. :auto-upload="true"></u-upload>
  27. </view>
  28. </view>
  29. <view class="foot">
  30. <view class="btn" @click="submit">
  31. 确认
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import configService from '../../common/service/config.service'
  38. export default {
  39. data() {
  40. return {
  41. action: configService.apiUrl + '/sys/common/upload',
  42. imageHttp: configService.apiUrl + '/',
  43. fileList: [],
  44. uploadedFiles: [],
  45. taskId: '',
  46. checkType: '',
  47. uptype: '',
  48. paramState: '',
  49. serveType: '',
  50. jumptype: null
  51. }
  52. },
  53. onLoad(options) {
  54. this.taskId = options.taskId;
  55. this.checkType = options.checkType;
  56. this.uptype = options.uptype;
  57. this.paramState = options.paramState;
  58. this.serveType = options.serveType;
  59. this.jumptype = options.jumptype
  60. },
  61. methods: {
  62. back() {
  63. if (this.jumptype == 0) {
  64. uni.switchTab({
  65. url: '/pages/order/index'
  66. })
  67. } else {
  68. uni.navigateBack({
  69. delta: 1
  70. });
  71. }
  72. },
  73. // 上传成功回调
  74. onUploadSuccess(res, index, lists) {
  75. if (res.code === 0) {
  76. this.uploadedFiles.push({
  77. url: this.imageHttp + res.message,
  78. response: res
  79. });
  80. } else {
  81. uni.showToast({
  82. title: '上传失败: ' + res.message,
  83. icon: 'none'
  84. });
  85. }
  86. },
  87. // 删除文件回调
  88. onRemove(index, lists) {
  89. this.uploadedFiles.splice(index, 1);
  90. },
  91. // 选择图片完成回调
  92. onChooseComplete(lists) {
  93. this.fileList = lists;
  94. },
  95. // 提交
  96. submit() {
  97. console.log(this.uploadedFiles)
  98. if (this.uploadedFiles.length < 3) {
  99. uni.showToast({
  100. title: '请至少上传3张照片',
  101. icon: 'none'
  102. });
  103. return;
  104. }
  105. // 所有图片都有内容,处理数据并发送请求
  106. let temp = []
  107. this.uploadedFiles.forEach(item => {
  108. temp.push({
  109. merchantId: uni.getStorageSync('login_user_info').merchantId,
  110. merchantName: uni.getStorageSync('login_user_info').merchantName,
  111. merchantUserId: uni.getStorageSync('login_user_info').id,
  112. businessType: this.uptype,
  113. taskId: this.taskId,
  114. imgUrl: this.imageHttp + item.response.message
  115. })
  116. });
  117. console.log(temp)
  118. this.$http.post("/ts/merchant/addImg", temp).then(res => {
  119. console.log(res);
  120. if (res.data.code == 200) {
  121. this.upSuccess()
  122. }
  123. });
  124. },
  125. upSuccess() {
  126. let data = {
  127. taskId: this.taskId,
  128. checkType: this.checkType,
  129. paramState: this.paramState, //商户上传图片成功
  130. serveType: this.serveType
  131. }
  132. console.log(data)
  133. this.$http.post("/ts/merchant/update/Serve", data).then(res => {
  134. if (res.data.code == 200) {
  135. uni.showToast({
  136. icon: 'none',
  137. title: '上传成功'
  138. });
  139. // uni.switchTab({
  140. // url:'/pages/order/index'
  141. // })
  142. this.back()
  143. } else {
  144. uni.showToast({
  145. icon: 'none',
  146. title: res.data.message
  147. })
  148. }
  149. })
  150. },
  151. }
  152. }
  153. </script>
  154. <style scoped lang="scss">
  155. .arrive_upload {
  156. width: 100vw;
  157. height: 100vh;
  158. background: #ffffff;
  159. display: flex;
  160. flex-direction: column;
  161. overflow: hidden;
  162. /*#ifdef APP-PLUS*/
  163. .top {
  164. width: 100%;
  165. height: var(--status-bar-height);
  166. background: #ffffff;
  167. }
  168. /*#endif*/
  169. .head {
  170. width: 100%;
  171. height: 112rpx;
  172. padding: 20rpx;
  173. display: flex;
  174. align-items: center;
  175. background: #ffffff;
  176. position: relative;
  177. .cuIcon-back {
  178. font-size: 40rpx;
  179. margin-right: 40rpx;
  180. }
  181. .case {
  182. position: absolute;
  183. left: 50%;
  184. transform: translateX(-50%);
  185. font-size: 36rpx;
  186. // font-weight: 600;
  187. }
  188. }
  189. .center {
  190. flex: 1;
  191. border-top: 1px solid #EEEEEE;
  192. border-bottom: 1px solid #EEEEEE;
  193. padding: 20rpx 28rpx;
  194. overflow-y: auto;
  195. .text {
  196. .title {
  197. font-size: 36rpx;
  198. color: #333333;
  199. }
  200. .describe {
  201. width: 100%;
  202. background: #F6F8FA;
  203. padding: 20rpx;
  204. font-size: 24rpx;
  205. color: #909296;
  206. margin-top: 16rpx;
  207. }
  208. }
  209. .upload {
  210. margin-top: 30rpx;
  211. }
  212. }
  213. .foot {
  214. width: 100%;
  215. height: 112rpx;
  216. padding: 16rpx 24rpx;
  217. .btn {
  218. width: 100%;
  219. height: 76rpx;
  220. background: #449AFF;
  221. border-radius: 66rpx;
  222. text-align: center;
  223. line-height: 76rpx;
  224. color: #ffffff;
  225. font-size: 28rpx;
  226. }
  227. }
  228. }
  229. ::v-deep .u-add-wrap {
  230. width: 320rpx !important;
  231. height: 194rpx !important;
  232. }
  233. ::v-deep .u-preview-wrap {
  234. width: 320rpx !important;
  235. height: 194rpx !important;
  236. }
  237. </style>