traceCamera.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view>
  3. <uni-section :title="orderCode+'/'+shipmentName" type="line">
  4. <view class="example">
  5. <u-upload
  6. :fileList="imageList"
  7. :sizeType="imageSizeType"
  8. @delete="deletePic"
  9. @afterRead="readPic"
  10. name="1"
  11. previewImage
  12. :maxCount="3"
  13. >
  14. </u-upload>
  15. <button type="primary" @click="submitTrace()">提交</button>
  16. </view>
  17. </uni-section>
  18. </view>
  19. </template>
  20. <script>
  21. import request from '@/common/libs/request.js';
  22. export default {
  23. data() {
  24. return {
  25. orderCode:'',
  26. idOrder:'',
  27. imageSizeType:['original','compressed'],
  28. imageList: [],
  29. imageSrcList: []
  30. }
  31. },
  32. onLoad(option){
  33. if(option && option.idOrder){
  34. this.idOrder = option.idOrder
  35. this.orderCode = option.orderCode
  36. this.shipmentName = option.shipmentName
  37. this.index = option.index
  38. // this.getSrcTraceImage()
  39. }
  40. },
  41. methods: {
  42. // 删除图片
  43. deletePic(event) {
  44. this.imageList.splice(event.index, 1)
  45. },
  46. async readPic(event) {
  47. this.imageList.push(event.file)
  48. },
  49. submitTrace() {
  50. let _that = this
  51. if(_that.imageList.length<=0){
  52. uni.showToast({
  53. title: "请先拍照上传图片",
  54. icon: 'none'
  55. })
  56. return
  57. }
  58. // 请求前
  59. uni.showLoading({
  60. mask:true //是否显示透明蒙层,防止触摸穿透,默认:false
  61. });
  62. let uploadFiles = []
  63. for (let i = 0; i < _that.imageList.length; i++) {
  64. uploadFiles.push({
  65. uri: _that.imageList[i].url,
  66. name: 'traceImage' + i
  67. })
  68. }
  69. // _that.imageList.forEach(x => {
  70. // uploadFiles.push({
  71. // uri: x.url
  72. // })
  73. // })
  74. let token = uni.getStorageSync('erpToken');
  75. let uploadUrl = "http://192.168.1.24:51106/driverSign/signItem";
  76. if (process.env.NODE_ENV === 'production') {
  77. uploadUrl = "http://192.168.1.24:51106/driverSign/signItem"
  78. }
  79. console.log("111",uploadFiles);
  80. uni.uploadFile({
  81. url: uploadUrl,
  82. files: uploadFiles,
  83. header: {
  84. 'Access-Token': token
  85. },
  86. formData: {
  87. idItem: _that.idOrder
  88. },
  89. success: (res) => {
  90. console.log("222",res);
  91. uni.hideLoading();
  92. uni.navigateBack({})
  93. uni.$emit("eventName",_that.index)
  94. }
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style>
  101. .example {
  102. padding: 15px;
  103. background-color: #fff;
  104. }
  105. </style>