arriveUpload.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. console.log(options)
  55. this.taskId = options.taskId;
  56. this.checkType = options.checkType;
  57. this.uptype = options.uptype;
  58. this.paramState = options.paramState;
  59. this.serveType = options.serveType;
  60. this.jumptype = options.jumptype
  61. },
  62. methods: {
  63. back() {
  64. if (this.jumptype == 0) {
  65. uni.switchTab({
  66. url: '/pages/order/index'
  67. })
  68. } else {
  69. uni.navigateBack({
  70. delta: 1
  71. });
  72. }
  73. },
  74. // 上传成功回调
  75. onUploadSuccess(res, index, lists) {
  76. if (res.code === 0) {
  77. this.uploadedFiles.push({
  78. url: this.imageHttp + res.message,
  79. response: res
  80. });
  81. } else {
  82. uni.showToast({
  83. title: '上传失败: ' + res.message,
  84. icon: 'none'
  85. });
  86. }
  87. },
  88. // 删除文件回调
  89. onRemove(index, lists) {
  90. this.uploadedFiles.splice(index, 1);
  91. },
  92. // 选择图片完成回调
  93. onChooseComplete(lists) {
  94. this.fileList = lists;
  95. },
  96. // 提交
  97. submit() {
  98. console.log(this.uploadedFiles)
  99. if (this.uploadedFiles.length < 3) {
  100. uni.showToast({
  101. title: '请至少上传3张照片',
  102. icon: 'none'
  103. });
  104. return;
  105. }
  106. // 所有图片都有内容,处理数据并发送请求
  107. let temp = []
  108. this.uploadedFiles.forEach(item => {
  109. temp.push({
  110. merchantId: uni.getStorageSync('login_user_info').merchantId,
  111. merchantName: uni.getStorageSync('login_user_info').merchantName,
  112. merchantUserId: uni.getStorageSync('login_user_info').id,
  113. businessType: this.uptype,
  114. taskId: this.taskId,
  115. imgUrl: this.imageHttp + item.response.message
  116. })
  117. });
  118. console.log(temp)
  119. this.$http.post("/ts/merchant/addImg", temp).then(res => {
  120. console.log(res);
  121. if (res.data.code == 200) {
  122. this.upSuccess()
  123. }
  124. });
  125. },
  126. upSuccess() {
  127. let data = {
  128. taskId: this.taskId,
  129. checkType: this.checkType,
  130. paramState: this.paramState, //商户上传图片成功
  131. serveType: this.serveType
  132. }
  133. console.log(data)
  134. this.$http.post("/ts/merchant/update/Serve", data).then(res => {
  135. if (res.data.code == 200) {
  136. uni.showToast({
  137. icon: 'none',
  138. title: '上传成功'
  139. });
  140. // uni.switchTab({
  141. // url:'/pages/order/index'
  142. // })
  143. this.back()
  144. } else {
  145. uni.showToast({
  146. icon: 'none',
  147. title: res.data.message
  148. })
  149. }
  150. })
  151. },
  152. }
  153. }
  154. </script>
  155. <style scoped lang="scss">
  156. .arrive_upload {
  157. width: 100vw;
  158. height: 100vh;
  159. background: #ffffff;
  160. display: flex;
  161. flex-direction: column;
  162. overflow: hidden;
  163. /*#ifdef APP-PLUS*/
  164. .top {
  165. width: 100%;
  166. height: var(--status-bar-height);
  167. background: #ffffff;
  168. }
  169. /*#endif*/
  170. .head {
  171. width: 100%;
  172. height: 112rpx;
  173. padding: 20rpx;
  174. display: flex;
  175. align-items: center;
  176. background: #ffffff;
  177. position: relative;
  178. .cuIcon-back {
  179. font-size: 40rpx;
  180. margin-right: 40rpx;
  181. }
  182. .case {
  183. position: absolute;
  184. left: 50%;
  185. transform: translateX(-50%);
  186. font-size: 36rpx;
  187. // font-weight: 600;
  188. }
  189. }
  190. .center {
  191. flex: 1;
  192. border-top: 1px solid #EEEEEE;
  193. border-bottom: 1px solid #EEEEEE;
  194. padding: 20rpx 28rpx;
  195. overflow-y: auto;
  196. .text {
  197. .title {
  198. font-size: 36rpx;
  199. color: #333333;
  200. }
  201. .describe {
  202. width: 100%;
  203. background: #F6F8FA;
  204. padding: 20rpx;
  205. font-size: 24rpx;
  206. color: #909296;
  207. margin-top: 16rpx;
  208. }
  209. }
  210. .upload {
  211. margin-top: 30rpx;
  212. }
  213. }
  214. .foot {
  215. width: 100%;
  216. height: 112rpx;
  217. padding: 16rpx 24rpx;
  218. .btn {
  219. width: 100%;
  220. height: 76rpx;
  221. background: #449AFF;
  222. border-radius: 66rpx;
  223. text-align: center;
  224. line-height: 76rpx;
  225. color: #ffffff;
  226. font-size: 28rpx;
  227. }
  228. }
  229. }
  230. ::v-deep .u-add-wrap {
  231. width: 320rpx !important;
  232. height: 194rpx !important;
  233. }
  234. ::v-deep .u-preview-wrap {
  235. width: 320rpx !important;
  236. height: 194rpx !important;
  237. }
  238. </style>