equipment-img.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="mt-3 px3">
  3. <view class="f-size-30 f-weight-bold py2 border-bottom my3">设备图片</view>
  4. <u-upload
  5. width="180"
  6. height="180"
  7. :action="action"
  8. :file-list="fileList"
  9. max-count="3"
  10. :max-size="5 * 100 * 1024"
  11. @on-success="uploadSuccess"
  12. @on-remove="uploadRemove"
  13. :header="header">
  14. </u-upload>
  15. <view class="d-flex j-around a-center footer">
  16. <view
  17. class="main-color-bg text-color-white common"
  18. @tap="handleSubmit"
  19. >提交</view
  20. >
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. infoData: {},
  29. detailId: '',
  30. fileList: [],
  31. action: this.$BaseTool.UserUtil.getUploadUrl(),
  32. header: {
  33. Authorization: 'Bearer ' + uni.getStorageSync('accessToken')
  34. },
  35. imagesList: []
  36. };
  37. },
  38. onLoad(options) {
  39. this.detailId = options.detailId;
  40. this.initData();
  41. },
  42. methods: {
  43. initData() {
  44. this.$Http
  45. .fetchSbInfoIgnores({
  46. id: this.detailId
  47. })
  48. .then((res) => {
  49. this.fileList = res.data.sbFileList
  50. this.imagesList = JSON.parse(JSON.stringify(res.data.sbFileList))
  51. this.fileList.forEach((d) => {
  52. d.url = this.$BaseTool.UserUtil.getFileUrl(d.url);
  53. });
  54. });
  55. },
  56. // 删除成功
  57. uploadRemove(index, lists, name) {
  58. this.fileList = lists;
  59. this.imagesList.splice(index, 1)
  60. console.log(this.imagesList);
  61. },
  62. // 上传成功
  63. uploadSuccess(data, index, lists, name) {
  64. this.fileList = lists;
  65. this.imagesList.push(data.data)
  66. console.log(this.imagesList);
  67. },
  68. handleSubmit() {
  69. const params = {
  70. sbFileList: this.imagesList,
  71. id: this.detailId
  72. };
  73. this.imagesList.map((item) => {
  74. return item.url;
  75. });
  76. this.$Http.updateSbInfoImagesIgnores(params).then((res) => {
  77. uni.showToast({ title: '添加成功' });
  78. });
  79. }
  80. }
  81. };
  82. </script>
  83. <style lang="less" scoped>
  84. .main {
  85. .img {
  86. width: 76rpx;
  87. height: 76rpx;
  88. border-radius: 10rpx;
  89. image {
  90. width: 76rpx;
  91. height: 76rpx;
  92. border-radius: 10rpx;
  93. }
  94. }
  95. .content {
  96. .text-color-3 {
  97. width: 500rpx;
  98. }
  99. }
  100. }
  101. .footer {
  102. bottom: 150rpx;
  103. left: 0;
  104. right: 0;
  105. z-index: 10000;
  106. border-top: 1rpx solid #f4f4f4;
  107. height: 100rpx;
  108. .common {
  109. padding: 15rpx 200rpx;
  110. border-radius: 30rpx;
  111. background-color: #0082ff;
  112. color: #fff;
  113. }
  114. }
  115. </style>